Skip to content

Instantly share code, notes, and snippets.

View codesenju's full-sized avatar

Lehlogonolo N. Masubelele codesenju

View GitHub Profile

Docker Container Name

A one paragraph description about the container.

Getting Started

These instructions will cover usage information and for the docker container

Prerequisities

@codesenju
codesenju / docker_setup_replication.sh
Last active May 18, 2020 19:07
docker_setup_replication
# configure postgresql for real-time replication
docker_setup_replication() {
psql -U postgres -c "CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'passw0rd';" && \
psql -U postgres -c "ALTER SYSTEM SET listen_addresses TO '*'" && \
psql -U postgres -c "alter system set wal_level = replica ;" && \
psql -U postgres -c "alter system set max_wal_senders = 18;" && \
psql -U postgres -c "alter system set hot_standby = on;" && \
echo host replication replicator 0.0.0.0/0 trust >> "$PGDATA/pg_hba.conf"
echo "User Replicator added!"
@codesenju
codesenju / Dockerfile
Created June 19, 2020 13:35
postgresql-replication Dockerfile
FROM postgres:12
COPY ./setup-master.sh /docker-entrypoint-initdb.d/setup-master.sh
COPY ./setup-db.sh /docker-entrypoint-initdb.d/setup-db.sh
WORKDIR /tables/
COPY actors.tar.gz .
COPY basics.tar.gz .
@codesenju
codesenju / setup-master.sh
Created June 19, 2020 13:37
postgresql-replication setup-master.sh
#!/usr/bin/env bash
# configure postgresql for real-time replication
psql -U postgres -c "CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'passw0rd';" && \
psql -U postgres -c "ALTER SYSTEM SET listen_addresses TO '*'" && \
psql -U postgres -c "alter system set wal_level = replica ;" && \
psql -U postgres -c "alter system set max_wal_senders = 18;" && \
psql -U postgres -c "alter system set hot_standby = on;" && \
psql -U postgres -c "alter system set promote_trigger_file='promote.signal'" && \
echo host replication replicator 0.0.0.0/0 trust >> "$PGDATA/pg_hba.conf"
echo "User Replicator added!"
@codesenju
codesenju / setup-db.sh
Created June 19, 2020 13:44
postgresql-replication setup-db.sh
#!/bin/bash
# pg_restore is a utility for restoring a PostgreSQL database from an archive created by pg_dump.
# Here we are restoring tables that have records of movie titles(basics.tar.gz) and actors(actors.tar.gz) into the movie database.
pg_restore -d movie /tables/actors.tar.gz
pg_restore -d movie /tables/basics.tar.gz
@codesenju
codesenju / grafana-HA.md
Last active March 26, 2021 19:17
Setup Grafana High Availability in 5 min.

Grafana High Avialability

Architecture

Breakdown:

  • Nginx will serve as our Load Balancer.
  • PostgreSQL 12 will store our data.

Quick start:

@codesenju
codesenju / paramiko
Last active March 25, 2022 13:10
open_connection_paramiko
import paramiko
hostname = 'localhost'
username = 'codesenju'
password = 'passw0rd'
PORT = '2222'
ssh = paramiko.SSHClient()
def execRemoteCommand(cmd_, client):
@codesenju
codesenju / Converting_keys_to _pem.txt
Created April 1, 2022 09:53
Converting_keys_to _pem
Converting Keys to .pem
openssl x509 -in certificate.crt -out certificate.pem -outform PEM
openssl rsa -in private.key -text > privatekey.pem
[defaults]
# (pathlist) Comma separated list of Ansible inventory sources
inventory = inventory
# (string) Path to the Python interpreter to be used for module execution on remote targets, or an automatic discovery mode. Supported discovery modes are ``auto`` (the default), ``auto_silent``, ``auto_legacy``, and ``auto_legacy_silent``. All discovery modes employ a lookup table to use the included system Python (on distributions known to include one), falling back to a fixed ordered list of well-known Python interpreter locations if a platform-specific default is not available. The fallback behavior will issue a warning that the interpreter should be set explicitly (since interpreters installed later may change which one is used). This warning behavior can be disabled by setting ``auto_silent`` or ``auto_legacy_silent``. The value of ``auto_legacy`` provides all the same behavior, but for backwards-compatibility with older Ansible releases that always defaulted to ``/usr/bin/python``, will use that interpreter
@codesenju
codesenju / main.py
Last active April 5, 2022 11:52
Paramiko Skeleton
import paramiko, sys, os
hostname = ''
username = ''
password = ''
PORT = '22'
ssh = paramiko.SSHClient()
def run_local_cmd(your_command):