-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-deps.sh
executable file
·54 lines (40 loc) · 1.74 KB
/
install-deps.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
set -e
cd /root
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -c -s)-pgdg main" >> /etc/apt/sources.list
apt update
apt install -y unzip postgresql-client-11 pgpool2
cd /tmp
awscli=d1vvhvl2y92vvt.cloudfront.net/awscli-exe-linux-x86_64.zip
curl https://$awscli -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install
# Fix pgpool2 config
PGPOOL_CONFIG_DIR=/etc/pgpool2
PGPOOL_CONFIG="$PGPOOL_CONFIG_DIR/pgpool.conf"
# Configure pgpool2
sed -i 's/^backend_/#backend_/g' $PGPOOL_CONFIG
sed -i 's/^\(listen_addresses\).*$/\1 = '\''*'\''/' $PGPOOL_CONFIG
sed -i 's/^\(replication_mode\).*$/\1 = on/' $PGPOOL_CONFIG
sed -i 's/^\(failover_if_affected_tuples_mismatch\).*$/\1 = on/' $PGPOOL_CONFIG
sed -i 's/^\(load_balance_mode\).*$/\1 = on/' $PGPOOL_CONFIG
# TODO: add S64 DA maintenance functions
sed -i 's/^\(black_function_list\).*$/\1 = '\''currval,lastval,nextval,setval,pg_reload_conf,add_column_to,drop_column_from,change_optimized_columns_to'\''/' $PGPOOL_CONFIG
sed -i 's/^\(allow_sql_comments\).*$/\1 = on/' $PGPOOL_CONFIG
sed -i 's/^\(health_check_period\).*$/\1 = 60/' $PGPOOL_CONFIG
sed -i 's/^\(health_check_user\).*$/\1 = '\''postgres'\''/' $PGPOOL_CONFIG
sed -i 's/^\(ssl\s\+=\).*$/\1 on/' "$PGPOOL_CONFIG"
# Set up PCP
PGPOOL_USER=pgpool
PGPOOL_PASS=pgpool
echo "$PGPOOL_USER:$( pg_md5 $PGPOOL_PASS )" > $PGPOOL_CONFIG_DIR/pcp.conf
PCPPASS="/root/.pcppass"
echo "127.0.0.1:9898:$PGPOOL_USER:$PGPOOL_PASS" > $PCPPASS
chmod 600 $PCPPASS
USER=$( ls -ld "$HOME" | awk '{print $3}' )
GROUP=$( ls -ld "$HOME" | awk '{print $4}' )
chown $USER:$GROUP $PCPPASS
# Restart pgpool
service pgpool2 restart