-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmInstallPSQL-13.1
executable file
·100 lines (74 loc) · 3.02 KB
/
mmInstallPSQL-13.1
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
#
# Instalacja ze zrodel servera PostgreSQL 13.1
# Autor Piotr Najman (c) 2021 MIT License
# pnajman@vespe.pl
#
set -e
cd ~/
#### instalacja pakietów
apt-get -y install vim-scripts make build-essential
apt-get -y install libreadline-dev libzzip-dev zlib1g-dev
apt-get -y install bison flex
apt-get -y install zip unzip
#### kompilacja postgresa ze zrodla
wget -c https://ftp.postgresql.org/pub/source/v13.1/postgresql-13.1.tar.bz2
bunzip2 postgresql-13.1.tar.bz2
tar xf ./postgresql-13.1.tar
rm ./postgresql-13.1.tar
cd ~/postgresql-13.1
#./configure
./configure --prefix=/usr/local/pgsql13/
make
make world
#make check (uruchamiamy jako user)
make install
make install-docs
make install-world
echo "Dodawanie użytkownika postgres"
#adduser postgres
useradd postgres
mkdir /usr/local/pgsql13/data
mkdir /usr/local/pgsql13/log
chown postgres:postgres /usr/local/pgsql13/data
chown postgres:postgres /usr/local/pgsql13/log
#### podmiana plików
cd ~/
wget -c https://mmedica-download.asseco.pl/inst/Migrator_PG13/PG-linux13.1.tar
tar xf ./PG-linux13.1.tar
rm ./PG-linux13.1.tar
cd ~/PG-linux13.1
cp ./bin/* /usr/local/pgsql13/bin/
cp ./lib/* /usr/local/pgsql13/lib/
cd ~/
rm -rf ./PG-linux13.1
su - postgres -c "/usr/local/pgsql13/bin/initdb -D /usr/local/pgsql13/data/"
su - postgres -c "/usr/local/pgsql13/bin/pg_ctl start -D /usr/local/pgsql13/data/ -l /usr/local/pgsql13/log/postgresql.log"
#### modyfikacje dla polaczen zdalnych i restart uslugi - UWAGA ustawić podsieć w zmianie pg_hba jaka potrzebna i adres ip hosta w poleceniu sed !!!!
echo "host all all 192.168.0.0/16 md5" >> /usr/local/pgsql13/data/pg_hba.conf
sed -i 's/'#listen_addresses\ =\ \'localhost\''/'listen_addresses\ =\ \'localhost,192.168.1.18\''/' /usr/local/pgsql13/data/postgresql.conf
sed -i 's/'#search_path\ =\ \'\"\$user\",\ public\''/'search_path\ =\ \'public,restricted\''/' /usr/local/pgsql13/data/postgresql.conf
su - postgres -c "/usr/local/pgsql13//bin/pg_ctl restart -D /usr/local/pgsql13//data/ -l /usr/local/pgsql13/log/postgresql.log"
su - postgres -c "/usr/local/pgsql13/bin/pg_ctl stop -D /usr/local/pgsql13/data/ -l /usr/local/pgsql13/log/postgresql.log"
#### utworzenie serwisu
cat << EOF > /lib/systemd/system/postgresql.service
[Unit]
Description=Postgresql-13.1 Service
After=syslog.target systemd-user-sessions.service
[Service]
User=postgres
Group=postgres
Type=forking
TimeoutSec=120
ExecStart=/usr/local/pgsql13/bin/pg_ctl start -D /usr/local/pgsql13/data -l /usr/local/pgsql13/log/postgresql.log
ExecStop=/usr/local/pgsql13/bin/pg_ctl stop -D /usr/local/pgsql13/data -l /usr/local/pgsql13/log/postgresql.log
ExecReload=/usr/local/pgsql13/bin/pg_ctl reload -D /usr/local/pgsql13/data -l /usr/local/pgsql13/log/postgresql.log
Restart=/usr/local/pgsql13/bin/pg_ctl restart -D /usr/local/pgsql13/data -l /usr/local/pgsql13/log/postgresql.log
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
#### start postgresa jako serwisu
systemctl enable postgresql.service
systemctl start postgresql.service
#### sprzatanie po instalacji