• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Archives

environment

Python Virtual Environment

February 27, 2022

How to create a Python virtual environment.

On Windows

$ pip install venv
$ python3 -m venv ~/python-test

$ pip install venv $ python3 -m venv ~/python-test

On Ubuntu

$ sudo apt install python3.8-venv
$ python3 -m venv ~/python-test

$ sudo apt install python3.8-venv $ python3 -m venv ~/python-test

On Mac OS

$ brew install virtualenv
$ virtualenv python-test

$ brew install virtualenv $ virtualenv python-test

Activate

$ cd ~/python-test
$ source bin/activate

$ cd ~/python-test $ source bin/activate

Deactivate

$ deactivate

$ deactivate

Filed Under: Linux Tagged With: activate, deactivate, environment, python, virtual

Run MySQL in a Docker container

December 12, 2021

How to run MySQL commands in a Docker container.

#!/bin/bash
set -a; source <(cat .env | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g"); set +a
docker exec wp_db mysql -uroot -p${MYSQL_PASSWORD} -e " \
use db1; \
select * from wp_options where option_name='siteurl'; \
select * from wp_options where option_name='home';" 2>/dev/null

#!/bin/bash set -a; source <(cat .env | sed -e '/^#/d;/^\s*$/d' -e "s/'/'\\\''/g" -e "s/=\(.*\)/='\1'/g"); set +a docker exec wp_db mysql -uroot -p${MYSQL_PASSWORD} -e " \ use db1; \ select * from wp_options where option_name='siteurl'; \ select * from wp_options where option_name='home';" 2>/dev/null

  • The first command loads the content of .env to environment variables.
  • The MySQL password can then be used using the ${MYSQL_PASSWORD} variable.
  • I’m using sed to get around the special characters in the password.
  • The second command runs docker exec on wp_db container.
  • The last 3 commands are the actual sql commands.
  • We are selecting to use the db1 database.
  • Then we run select statements from the wp_options table.
  • Finally, 2>/dev/null suppresses errors and warning to null.

Filed Under: Cloud, Linux Tagged With: database, docker, environment, exec, mysql, password, select, tables

Remove an environment variable

November 7, 2021

How to remove an environment variable in Linux.

unset AWS_PROFILE

unset AWS_PROFILE

You can run env to validate if variable is still present.

env

env

Filed Under: Linux Tagged With: env, environment, remove, unset, variable

GCP ILB Issue Targets Not Healthy

January 14, 2020

I ran into an issue with Google Compute Engine TCP internal load balancer. The targets are unhealthy although all configs were correct installed. At one time the targets were working, but somehow they became unhealthy. In the end, 3 things needed to be checked.

  1. Make sure GCP’s guest environment is installed.
  2. Add the internal load balancer VIP address to the network properties.
  3. Add route via cmd. “route ADD VIP MASK 255.255.255.255”

You will need to change the server’s IP from DHCP to static to add ILB VIP.

Filed Under: Cloud Tagged With: add, cmd, environment, gcp, guest, internal, load balancer, network, properties, route, vip

  • Home
  • About
  • Archives

Copyright © 2023