Skip to content

Instantly share code, notes, and snippets.

View imcitius's full-sized avatar

Ilya Rubinchik imcitius

View GitHub Profile
name: 'pgsql-main-0'
scope: &scope 'pgsql-main'
consul:
host: '172.29.10.58'
restapi:
listen: 172.29.10.58:8008
connect_address: 172.29.10.58:8008
auth: 'username:123123123'
авг 14 13:48:12 pgsql-main-2 patroni.py[28436]: 2018-08-14 13:48:12,792 INFO: Lock owner: pgsql-main-2; I am pgsql-main-2
авг 14 13:48:12 pgsql-main-2 patroni.py[28436]: 2018-08-14 13:48:12,800 INFO: Got response from pgsql-main-0 http://172.29.10.58:8008/patroni: {"database_system_identifier": "6589191000674292929", "postmaster_start_time": "2018-08-14 13:40:48.148 UTC", "timeline": 23, "xlog": {"received_location": 503504872, "replayed_timestamp": "2018-08-14 13:43:39.465 UTC", "paused": false, "replayed_location": 503504872}, "patroni": {"scope": "pgsql-main", "version": "1.4.5"}, "state": "running", "role": "replica", "server_version": 100005}
авг 14 13:48:12 pgsql-main-2 patroni.py[28436]: 2018-08-14 13:48:12,906 INFO: manual failover: demoting myself
авг 14 13:48:13 pgsql-main-2 patroni.py[28436]: 2018-08-14 13:48:13,057 INFO: Leader key released
авг 14 13:48:15 pgsql-main-2 patroni.py[28436]: 2018-08-14 13:48:15,063 INFO: closed patroni connection to the postgresql cluster
авг 14 13:48:15 pgsql-main-2
авг 14 13:47:48 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:48,720 INFO: Lock owner: pgsql-main-2; I am pgsql-main-0
авг 14 13:47:48 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:48,720 INFO: does not have lock
авг 14 13:47:48 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:48,724 INFO: no action. i am a secondary and i am following a leader
авг 14 13:47:58 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:58,369 INFO: Lock owner: pgsql-main-2; I am pgsql-main-0
авг 14 13:47:58 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:58,369 INFO: does not have lock
авг 14 13:47:58 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:47:58,371 INFO: no action. i am a secondary and i am following a leader
авг 14 13:48:04 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:48:04,664 INFO: Starting new HTTP connection (2): 172.29.10.58
авг 14 13:48:04 pgsql-main-0 patroni.py[3954]: 2018-08-14 13:48:04,667 INFO: received switchover request with leader=pgsql-main-2 candidate=pgsql-main-0 scheduled_at=None
авг 14 13:48:04 pgsql-main-
>> curl -v pgsql-main-0.node.cluster-dev.consul:8008/master
* Trying 172.29.10.58...
* TCP_NODELAY set
* Connected to pgsql-main-0.node.cluster-dev.consul (172.29.10.58) port 8008 (#0)
> GET /master HTTP/1.1
> Host: pgsql-main-0.node.cluster-dev.consul:8008
> User-Agent: curl/7.59.0
> Accept: */*
>
* HTTP 1.0, assume close after body
@imcitius
imcitius / walg-pitr.md
Created September 3, 2019 20:28 — forked from pohzipohzi/walg-pitr.md
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster

Keybase proof

I hereby claim:

  • I am imcitius on github.
  • I am citius (https://keybase.io/citius) on keybase.
  • I have a public key ASCyS4UwgN-oTHNPPPHdo8wrDhZWprcWdkDrgNGonc88ggo

To claim this, I am signing this object:

@imcitius
imcitius / certs.sh
Last active February 19, 2021 08:59
Acme-Lego script to issue and renew certificates
#!/bin/bash
#set -xe
LEGO_PATH=/tmp/cert-$RANDOM
mkdir -p $LEGO_PATH/accounts/acme-v02.api.letsencrypt.org/$ACC/keys
vault read -field=account.json secret/$ENV/letsencrypt/$DOMAIN > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo "Credentials found"
@imcitius
imcitius / terraform-consul1.0.py
Created July 15, 2021 09:06
Ansible dynamic inventory script for terraform
#!/usr/bin/env python3
from __future__ import print_function
import base64
import os
import sys
import json
from collections import OrderedDict
import requests
from requests.auth import HTTPBasicAuth
import re
@imcitius
imcitius / redis-master.conf
Created September 24, 2021 18:48
redis-master.conf
daemonize no
pidfile "/var/run/redis/redis.pid"
port 6379
tcp-backlog 511
bind 192.168.127.132 127.0.0.1
timeout 0
tcp-keepalive 0
loglevel notice
@imcitius
imcitius / redis-sentinel-master.conf
Last active September 24, 2021 18:50
redis-sentinel-master.conf
port 26379
logfile "/var/log/redis/sentinel.log"
dir "/tmp"
sentinel myid 7de6d6260f98eb7c045845cda4e981a2ca4b5d74
sentinel deny-scripts-reconfig yes
sentinel monitor redis 192.168.127.132 6379 2
sentinel down-after-milliseconds redis 3000