Skip to content

Instantly share code, notes, and snippets.

@imcookie
imcookie / pg_replication_9.4.txt
Created August 20, 2021 21:33
pg_replication_9.4.txt
On master:
-> postgresql.conf
hot_standby = on
wal_level = hot_standby
max_replication_slots = 2
-> pg_hba.conf
host replication repluser 192.168.1.100/32 md5
# set -e errexit When set, the shell exits when a simple command in a command list exits non-zero (FALSE). This is not done in situations, where the exit code is already checked (if, while, until,||, &&)
# set -x xtrace Режим отладки. Перед выполнением команды печатает её со всеми уже развернутыми подстановками и вычислениями.
set -ex
export HTTP_PROXY="http://"
export HTTPS_PROXY="http://"
export NO_PROXY="localhost,127.0.0.1"
curl --proxy $HTTP_PROXY -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io
@imcookie
imcookie / wal-e.md
Created August 22, 2020 22:37 — forked from ruckus/gist:2293434
Basic setup of WAL-E for continuous archiving and recovery

WAL-E needs to be installed on all machines, masters and slaves.

How to install WAL-E

Only one machine, the master, writes WAL segments via continuous archiving. The configuration for the master postgresql.conf is:

archive_mode = on
archive_command = 'envdir /etc/wal-e.d/env wal-e wal-push %p'
archive_timeout = 60
[win]
win-web1.localdomain
[win:vars]
ansible_user = Administrator
ansible_password = password
ansible_connection = winrm
ansible_winrm_transport = basic
ansible_winrm_server_cert_validation = ignore
@imcookie
imcookie / ansible_local_playbooks.md
Last active June 16, 2019 13:34 — forked from alces/ansible_local_playbooks.md
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local --inventory 127.0.0.1, playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
В PostgreSQL версий ниже 9.6 нет функции pg_blocking_pids, но блокирующий процесс можно вычислить, используя запросы к таблице блокировок. Запрос покажет две строки: одна транзакция получила блокировку (granted), другая - нет и ожидает.
SELECT locktype, transactionid, pid, mode, granted
FROM pg_locks
WHERE transactionid IN (
SELECT transactionid FROM pg_locks WHERE pid = :blocked_pid AND NOT granted
(LightWeight|ISATAP|WAN Miniport|Microsoft Kernel Debug|Teredo|Connection-QoS|Pseudo-Interface|Packet Scheduler|RAS Async Adapter)
Swap file management must be set to manual first:
wmic.exe computersystem where name="ComputerName " set AutomaticManagedPagefile=False [Enter]
Then, we delete the swap file:
wmic.exe pagefileset where name="c:\\pagefile.sys" delete [Enter]
NOTE: Case sensitive AND the double backslashes are required.
#!/usr/bin/env bash
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
sudo usermod -aG docker $USER
sudo pkill -u $USER #logout
!#/usr/bin/env python
sudo apt-get install virtualenv
virtualenv --no-site-packages .venv
source .venv/bin/activate
pip install molecule ansible docker-py
molecule init role -r role-name -d docker