forked from jobinau/pgscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpgdg_ubuntu.sh
More file actions
27 lines (22 loc) · 1.26 KB
/
pgdg_ubuntu.sh
File metadata and controls
27 lines (22 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
##Environment Variables
export PGVER=$1
export PG=postgresql$PGVER
export PATH=$PATH:/usr/lib/postgresql/$PGVER/bin
##Edit the bashrc
echo 'export PGBIN=/usr/lib/postgresql/'"$PGVER"'/bin/' >> ~/.bashrc
#sed -i 's/PATH=.*/&:\/usr\/lib\/postgresql\/'"$PGVER"'\/bin/' ~/.bashrc
echo 'export PATH=$PGBIN:$PATH' >> ~/.bashrc
echo 'export PGDATA=/var/lib/postgresql/'"$PGVER"'/main/' >> ~/.bashrc
##Installation
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt search postgresql-$PGVER
sudo apt install -y postgresql-$PGVER
##Parameter modifications
sed -i '/listen_addresses/c\listen_addresses = \x27*\x27' /etc/postgresql/$PGVER/main/postgresql.conf
sed -i '/max_wal_senders/c\max_wal_senders = 5' /etc/postgresql/$PGVER/main/postgresql.conf
sed -i '/^#logging_collector/c\logging_collector = on' /etc/postgresql/$PGVER/main/postgresql.conf
sed -i '/^#hot_standby/c\hot_standby = on' /etc/postgresql/$PGVER/main/postgresql.conf
##Direct command
/usr/lib/postgresql/$PGVER/bin/pg_ctl status -D /var/lib/postgresql/$PGVER/main -o '--config-file=/etc/postgresql/$PGVER/main/postgresql.conf'