1/ Install:
##sudo apt-get update
##sudo apt-get install --fix-missing
##sudo apt-get -y upgrade
##sudo apt -y autoremove
##sudo apt-get -y install python-pip
##sudo apt-get -y install python3-pip
##sudo apt-get install --fix-missing
##sudo apt-get -y upgrade
##sudo apt -y autoremove
##sudo apt-get -y install python-pip
##sudo apt-get -y install python3-pip
PIP_CACHE="/opt/setup/pip"
mkdir -p $PIP_CACHE
sudo pip --cache-dir=$PIP_CACHE
##sudo pip3 --cache-dir=$PIP_CACHE install --upgrade pip
##sudo pip3 --cache-dir=$PIP_CACHE install psychopy
\\##sudo pip3 --cache-dir=$PIP_CACHE install psycopg2: ERR
##sudo pip3 --cache-dir=$PIP_CACHE install psycopg2-binary
##sudo pip --cache-dir=$PIP_CACHE install --upgrade setuptools
##sudo pip --cache-dir=$PIP_CACHE install patroni
##sudo pip --cache-dir=$PIP_CACHE install wheel
mkdir -p $PIP_CACHE
sudo pip --cache-dir=$PIP_CACHE
##sudo pip3 --cache-dir=$PIP_CACHE install --upgrade pip
##sudo pip3 --cache-dir=$PIP_CACHE install psychopy
\\##sudo pip3 --cache-dir=$PIP_CACHE install psycopg2: ERR
##sudo pip3 --cache-dir=$PIP_CACHE install psycopg2-binary
##sudo pip --cache-dir=$PIP_CACHE install --upgrade setuptools
##sudo pip --cache-dir=$PIP_CACHE install patroni
##sudo pip --cache-dir=$PIP_CACHE install wheel
2/ Result:
/usr/local/bin/patronictl version -> "patronictl version 2.0.1"
/usr/bin/patronictl version -> "patronictl version 1.4.2"
/usr/local/bin/patroni --version -> "patroni 2.0.1"
3/ #/etc/systemd/system/patroni.service
#/etc/systemd/system/patroni.service
#LastUpdate: #11:36 2020.10.22
################################################################
#cat /etc/systemd/system/patroni.service | grep LastUpdate
################################################################
#scp /etc/systemd/system/patroni.service root@srv112:/etc/systemd/system/patroni.service
#scp /etc/systemd/system/patroni.service root@srv113:/etc/systemd/system/patroni.service
#RESTART PATRONI:
#systemctl daemon-reload; sudo systemctl restart patroni; sleep 5; sudo systemctl status patroni --no-pager;
#10.0.2.111*
#10.0.2.112*
#10.0.2.113*
################################################################
[Unit]
Description=High availability PostgreSQL Cluster
After=syslog.target network.target
[Service]
Type=simple
User=postgres
Group=postgres
ExecStart=/usr/local/bin/patroni /etc/patroni.yml
KillMode=process
TimeoutSec=30
Restart=no
[Install]
WantedBy=multi-user.targ
4/ #/opt/script/patroni-restart.sh
#/opt/script/patroni-restart.sh
#LastUpdate: #12:01 2020.10.22
################################################################
#cat /opt/script/patroni-restart.sh | grep LastUpdate
################################################################
#scp /opt/script/patroni-restart.sh root@srv112:/opt/script/patroni-restart.sh
#scp /opt/script/patroni-restart.sh root@srv113:/opt/script/patroni-restart.sh
#RESTART PATRONI:
#systemctl daemon-reload; sudo systemctl restart patroni; sleep 5; sudo systemctl status patroni --no-pager;
#10.0.2.111*
#10.0.2.112*
#10.0.2.113*
################################################################
#systemctl status patroni.service
#systemctl enable patroni.service
#sudo systemctl start patroni.service
#sudo systemctl status patroni.service
#################################################
#REF: https://www.linode.com/docs/databases/postgresql/create-a-highly-available-postgresql-cluster-using-patroni-and-haproxy/#install-patroni
#https://www.cybertec-postgresql.com/en/patroni-setting-up-a-highly-available-postgresql-cluster/
sudo systemctl restart patroni
sleep 2
echo "############################################"
echo "DAEMON STATUS:"
sudo systemctl status patroni --no-pager;
echo "--------------------------------------------"
echo "PROCESS STATUS:"
ps aux| egrep "PID|py"
echo "--------------------------------------------"
echo "TCP STATUS:"
netstat -ntlup | egrep "PID|LISTEN" | egrep "PID|python|etcd|postgres|haproxy" | sort -t: -k2 -n
#THE_END
5/#/opt/script/patroni-status.sh
#LastUpdate: #14:32 2020.10.22
################################################################
#cat /opt/script/patroni-status.sh | grep LastUpdate
################################################################
#scp /opt/script/patroni-status.sh root@srv112:/opt/script/patroni-status.sh
#scp /opt/script/patroni-status.sh root@srv113:/opt/script/patroni-status.sh
#RESTART PATRONI:
#systemctl daemon-reload; sudo systemctl restart patroni; sleep 5; sudo systemctl status patroni --no-pager;
#10.0.2.111*
#10.0.2.112*
#10.0.2.113*
################################################################
#systemctl status patroni.service
#systemctl enable patroni.service
#sudo systemctl start patroni.service
#sudo systemctl status patroni.service
################################################################
#REF: https://www.cybertec-postgresql.com/en/patroni-setting-up-a-highly-available-postgresql-cluster/
echo "############################################"
echo "DAEMON STATUS:"
sudo systemctl status patroni --no-pager;
echo "--------------------------------------------"
echo "PROCESS STATUS:"
ps aux| egrep "PID|py"
echo "--------------------------------------------"
echo "TCP STATUS:"
netstat -ntlup | egrep "PID|LISTEN" | egrep "PID|python|etcd|postgres|haproxy" | sort -t: -k2 -n
echo "--------------------------------------------"
echo "PATRONI CLUSTER STATUS:"
patronictl -c /etc/patroni.yml list postgres
echo ""
#curl http://10.0.2.111:8008 | json_pp
curl http://$(hostname -I | awk '{print $1}'):8008 | json_pp
echo "---"
echo "DONE"
#THE_END
6/ #/opt/script/patroni-stop.sh
#LastUpdate: #12:54 2020.10.22
################################################################
#cat /opt/script/patroni-stop.sh | grep LastUpdate
################################################################
#scp /opt/script/patroni-stop.sh root@srv112:/opt/script/patroni-stop.sh
#scp /opt/script/patroni-stop.sh root@srv113:/opt/script/patroni-stop.sh
#RESTART PATRONI:
#systemctl daemon-reload; sudo systemctl restart patroni; sleep 5; sudo systemctl status patroni --no-pager;
#10.0.2.111*
#10.0.2.112*
#10.0.2.113*
################################################################
#systemctl status patroni.service
#systemctl enable patroni.service
#sudo systemctl start patroni.service
#sudo systemctl status patroni.service
#################################################
#REF: https://www.cybertec-postgresql.com/en/patroni-setting-up-a-highly-available-postgresql-cluster/
sudo systemctl stop patroni
sleep 2
echo "############################################"
echo "DAEMON STATUS:"
sudo systemctl status patroni --no-pager;
echo "--------------------------------------------"
echo "PROCESS STATUS:"
ps aux| egrep "PID|py"
echo "--------------------------------------------"
echo "TCP STATUS:"
netstat -ntlup | egrep "PID|LISTEN" | egrep "PID|python|etcd|postgres|haproxy" | sort -t: -k2 -n
#THE_END
No comments:
Post a Comment