Archive for the ‘Uncategorized’ Category

PostgreSQL table contains a lot of useful information about database sessions.

Monday, June 27th, 2022

select pid as process_id, usename as username, datname as database_name, client_addr as client_address, application_name, backend_start, state, state_change from pg_stat_activity;

Install wordpress on docker with docker-compose

Monday, June 20th, 2022

wordpress:

   image: wordpress

   links:

    – mariadb:mysql

   environment:

    – WORDPRESS_DB_PASSWORD=1qa2ws3ed

    – WORDPRESS_DB_USER=root

   ports:

    – “10.4.17.163:80:80”

   volumes:

    – ./html:/var/www/html

mariadb:

   image: mariadb:10.8.2

   environment:

    – MYSQL_ROOT_PASSWORD=1qa2ws3ed

    – MYSQL_DATABASE=wordpress

   volumes:

    – ./database:/var/lib/mysql

Create deployment with name “blue” using nginx image

Tuesday, May 3rd, 2022

kubectl create deployment blue –image=nginx

Generate string (password)

Friday, April 15th, 2022
openssl rand -base64 12

Number of connection Netstart (netstat)

Sunday, April 10th, 2022

netstat -tn 2>/dev/null | grep :3306 | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr | head

create db user and password mariadb – done as production

Sunday, February 27th, 2022

create user ‘db’user’@’10.10.5.5’ identified by ‘ ********** ’ ;

grant all privileges on `dyname`.* to ‘dbuser’@’10.10.5.5’;

How many slave lag behind the master in postgres

Monday, February 21st, 2022
select now()-pg_last_xact_replay_timestamp();

postgres rules

Tuesday, February 8th, 2022

ALTER ROLE grafana_kms_srv WITH LOGIN;
GRANT SELECT ON ALL TABLES IN SCHEMA company_domain TO grafana_kms_srv;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO grafana_kms_srv;
GRANT USAGE ON SCHEMA public TO grafana_fms_srv;
GRANT USAGE ON SCHEMA company_domain TO grafana_fms_srv;

Distribute SSH key in servers

Wednesday, February 2nd, 2022

put the ssh public key of your PC in the following command and run it in any server want to access without password

echo ‘put the public key here’ >> /root/.ssh/authorized_keys

list all the available extensions in postgres

Wednesday, February 2nd, 2022
SELECT * FROM pg_available_extensions;
or 
run this in postgres
\dx