Last active
June 17, 2020 13:19
-
-
Save andrewp-as-is/2e531358fdc9c2821977321c87c5b6ec to your computer and use it in GitHub Desktop.
PostgreSQL cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SSH_HOSTNAME:=ubuntu@github42 | |
NAME:=github42 | |
VERSION:=12 | |
all: | |
make sync | |
make restart | |
make status | |
sync: | |
scp pg_hba.conf $(SSH_HOSTNAME):/tmp/pg_hba.conf | |
scp postgresql.conf $(SSH_HOSTNAME):/tmp/postgresql.conf | |
ssh $(SSH_HOSTNAME) sudo cp /tmp/pg_hba.conf /etc/postgresql/$(VERSION)/$(NAME)/pg_hba.conf | |
ssh $(SSH_HOSTNAME) sudo cp /tmp/postgresql.conf /etc/postgresql/$(VERSION)/$(NAME)/postgresql.conf | |
restart: | |
ssh $(SSH_HOSTNAME) sudo systemctl restart postgresql.service # sudo systemctl stop postgresql.service | |
status: | |
ssh $(SSH_HOSTNAME) 'service postgresql status | tee';: | |
ssh $(SSH_HOSTNAME) 'ps -ax | grep -v grep | grep postgres';: | |
ssh $(SSH_HOSTNAME) 'sudo netstat -tulpn | grep :5433';: | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name="requires42" | |
version=12 | |
data_directory="/mnt/name/postgres" | |
sudo chmod -R 750 /etc/postgresql/$version | |
sudo chown postgres /etc/postgresql/$version | |
! [ -e "$data_directory" ] && sudo mkdir -p "$data_directory" | |
sudo pg_lsclusters | grep -q "$name" || sudo -u postgres pg_createcluster "$version" "$name" -d "$data_directory" | |
# sudo pg_dropcluster --stop "$version" "$name" | |
sudo -u postgres pg_ctlcluster $version "$name" restart # sudo -u postgres pg_ctlcluster $version "$name" stop | |
sudo -u postgres pg_ctlcluster $version "$name" status | |
sudo -u postgres psql -p 5432 | |
# sudo -u postgres psql | |
# \password postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment