-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEDBPostgreSQL-Installer-MAIN.sh
1566 lines (1321 loc) · 70.3 KB
/
EDBPostgreSQL-Installer-MAIN.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
GREEN='\033[0;32m'
NC='\033[0m'
RED='\e[0;31m'
BLUE='\e[0;34m'
echo -e "${GREEN}***********************************************************************${NC}"
echo -e "${GREEN}******* Tool : EDB Advanced Server Installer ************************${NC}"
echo -e "${GREEN}******* Version: 1.1 ************************${NC}"
echo -e "${GREEN}***********************************************************************${NC}"
echo -e ""
echo -e "Before running this script please make sure that:"
echo -e "++ the AWS Image used to create this virtual machine is: ${RED}Amazon Linux 2${NC}"
echo -e ""
# Check if the script is being run as root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
dbVersion="xx"
while [ "$dbVersion" != "14" ] && [ "$dbVersion" != "15" ]; do
if [[ $dbVersion == "0" ]]; then
echo "Install canceled by user"
exit 1
fi
echo "You are going to install EDB Advanced Server"
read -p ">>>> Select the database version [ 14, 15, 0 (to exit) ]: " dbVersion
done
EDBdatabase_Version="edb-as${dbVersion}-server"
base_dir="/var/lib/edb/as${dbVersion}"
data_dir="/var/lib/edb/as${dbVersion}/data"
service_name="edb-as-${dbVersion}.service"
############################## BEGIN DISK LAYOUT
echo "************************************************"
echo "******* Configuration of Logical Volumes *******"
echo "************************************************"
echo ""
echo "Setup of the logical volumes for DATA and PG_WAL"
echo ""
echo "Available disks:"
# List the attached disks but not configured as a physical volume for LVM
for I in $(lvmdiskscan |grep --invert-match LVM |grep '/dev/sd[f-z]' | awk '{print $1}'); do echo -n "${I} "; ls -l ${I} | awk '{print "[ /dev/" $(NF) " ]"}'; done
echo ""
yes_no="xxx"
### PG_WAL disk layout
while [ "$yes_no" != "yes" ]; do
echo "-----------------"
echo -e "${GREEN}PG_WAL${NC} - choose the nvme disks to be part of the PG_WAL volume (will be mounted in /pg_wal) "
echo ">>> values separated by space: /dev/nvme1n1 /dev/nvme2n1 "
echo ""
read -p "(enter for none): " pg_wal_disks
echo ""
read -p "Is this correct? ( $pg_wal_disks ) [yes / no]: " yes_no
done
if [[ -n "$pg_wal_disks" ]]
then
# create physical disks
echo "Running pvcreate $pg_wal_disks "
pvcreate $pg_wal_disks
echo "Running pvs"
pvs
# Striping
pg_wal_disks_array=($pg_wal_disks)
pg_wal_striping=${#pg_wal_disks_array[@]}
echo "Striping will be = $pg_wal_striping"
echo "Running vgcreate vg_pgwal $pg_wal_disks "
vgcreate vg_pgwal $pg_wal_disks
echo "Running vgs"
vgs
echo "Running lvcreate -l +100%FREE -i $pg_wal_striping -I64 -n lv_pgwal vg_pgwal "
lvcreate -l +100%FREE -i $pg_wal_striping -I64 -n lv_pgwal vg_pgwal
echo "Running lvs -a -o lv_name,vg_name,lv_layout,lv_size,origin,copy_percent,devices,stripes,seg_count"
lvs -a -o lv_name,vg_name,lv_layout,lv_size,origin,copy_percent,devices,stripes,seg_count
echo "Running fdisk -l |grep mapper"
fdisk -l |grep mapper
echo "Running mkfs.xfs -d su=64k,sw=$pg_wal_striping /dev/mapper/vg_pgwal-lv_pgwal"
mkfs.xfs -d su=64k,sw=$pg_wal_striping /dev/mapper/vg_pgwal-lv_pgwal
# If /pg_wal doesn't exist, create it
echo "If /pg_wal doesn't exist, create it"
if [[ ! -f /pg_wal ]]
then
mkdir /pg_wal
fi
chmod 777 /pg_wal
echo "Running mount /dev/mapper/vg_pgwal-lv_pgwal /pg_wal"
mount /dev/mapper/vg_pgwal-lv_pgwal /pg_wal
echo "Updating /etc/fstab"
echo "Running echo \"/dev/mapper/vg_pgwal-lv_pgwal /pg_wal xfs defaults,noatime 1 1\" >> /etc/fstab "
echo "/dev/mapper/vg_pgwal-lv_pgwal /pg_wal xfs defaults,noatime 1 1" >> /etc/fstab
df -h
else
echo -e "${BLUE}** No disks choosen for PG_WAL volume group. Skiping...${NC}"
fi
echo ""
echo "Available disks:"
# List the attached disks but not configured as a physical volume for LVM
for I in $(lvmdiskscan |grep --invert-match LVM |grep '/dev/sd[f-z]' | awk '{print $1}'); do echo -n "${I} "; ls -l ${I} | awk '{print "[ /dev/" $(NF) " ]"}'; done
echo ""
yes_no="xxx"
### DATA disk layout
while [ "$yes_no" != "yes" ]; do
echo "-----------------"
echo -e "${GREEN}DATA${NC} - choose the nvme disks to be part of the DATA volume (will be mounted in $data_dir) "
echo ">>> values separated by space: /dev/nvme1n1 /dev/nvme2n1 "
echo ""
read -p "(enter for none): " data_disks
echo ""
read -p "Is this correct? ( $data_disks ) [yes / no]: " yes_no
done
if [[ -n "$data_disks" ]]
then
# create physical disks
echo "Running pvcreate $data_disks "
pvcreate $data_disks
echo "Running pvs"
pvs
# Striping
data_disks_array=($data_disks)
data_striping=${#data_disks_array[@]}
echo "Striping will be = $data_striping"
echo "Running vgcreate vg_edbdata $data_disks "
vgcreate vg_edbdata $data_disks
echo "Running vgs"
vgs
echo "Running lvcreate -l +100%FREE -i $data_striping -I64 -n lv_edbdata vg_edbdata "
lvcreate -l +100%FREE -i $data_striping -I64 -n lv_edbdata vg_edbdata
echo "Running lvs -a -o lv_name,vg_name,lv_layout,lv_size,origin,copy_percent,devices,stripes,seg_count"
lvs -a -o lv_name,vg_name,lv_layout,lv_size,origin,copy_percent,devices,stripes,seg_count
echo "Running fdisk -l |grep mapper"
fdisk -l |grep mapper
echo "Running mkfs.xfs -d su=64k,sw=$data_striping /dev/mapper/vg_edbdata-lv_edbdata"
mkfs.xfs -d su=64k,sw=$data_striping /dev/mapper/vg_edbdata-lv_edbdata
# If directory /var/lib/edb/as<version>/data doesn't exist, create it
if [[ ! -f $data_dir ]]
then
mkdir -p $data_dir
fi
chmod 777 $data_dir
echo "Running mount /dev/mapper/vg_edbdata-lv_edbdata $data_dir"
mount /dev/mapper/vg_edbdata-lv_edbdata $data_dir
echo "Updating /etc/fstab"
echo "Running echo \"/dev/mapper/vg_pgwal-vg_edbdata $data_dir xfs defaults,noatime 1 1\" >> /etc/fstab "
echo "/dev/mapper/vg_pgwal-vg_edbdata $data_dir xfs defaults,noatime 1 1" >> /etc/fstab
df -h
else
echo -e "${BLUE}** No disks choosen for DATA volume group. Skiping...${NC}"
fi
echo ""
echo ""
echo "========== Continue with the Database Installation =========="
############################## END DISK LAYOUT
cat <<EOF > /root/.vimrc
syntax on
set mouse-=a
set noincsearch
EOF
cat << EOF > /root/.bashrc
alias vmi='vim'
# EDB
alias edb='su - enterprisedb'
EOF
# Remove Python 3.7
echo "Removing Python 3.7"
yum -y remove python3
# Install Ncurses Compat Library and Tuned
echo "Installing ncurses-compat-libs dependency and tuned "
yum -y install ncurses-compat-libs tuned
# Steps to prepare EDB Repository
echo "***************************************************"
echo "*************Preparing EDB Repo********************"
echo "***************************************************"
curl -1sLf 'https://downloads.enterprisedb.com/J6F8C0qXX4alGhAPhIBKlAPAlLfHMGOL/enterprise/setup.rpm.sh' | sudo -E bash
yum install -y yum-utils pygpgme
echo -e "${RED} -------> You might get warning "Another app is currently holding the yum lock waiting for it to exit..." ${NC}"
echo -e "${RED} -------> ++ Kill the PID which is coming on the screen from a parallel screen ${NC}"
echo -e "${RED} -------> ++ If you are lazy like me, JUST WAIT!! and it will automatcally goes in to SLEEP and message will go away ${NC}"
rpm --import 'https://downloads.enterprisedb.com/J6F8C0qXX4alGhAPhIBKlAPAlLfHMGOL/enterprise/gpg.E71EB0829F1EF813.key'
curl -1sLf 'https://downloads.enterprisedb.com/J6F8C0qXX4alGhAPhIBKlAPAlLfHMGOL/enterprise/config.rpm.txt?distro=el&codename=7' > /tmp/enterprisedb-enterprise.repo
yum-config-manager --add-repo '/tmp/enterprisedb-enterprise.repo'
yum -q makecache -y --disablerepo='*' --enablerepo='enterprisedb-enterprise'
# Adding Epel repository
if [[ ! -f /etc/yum.repos.d/epel.repo ]]
then
echo "Adding Epel repository"
cat <<EOF > /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - \$basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/\$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=\$basearch&infra=\$infra&content=\$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - \$basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/\$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=\$basearch&infra=\$infra&content=\$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - \$basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
#baseurl=http://download.example/pub/epel/7/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=\$basearch&infra=\$infra&content=\$contentdir
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
EOF
fi
# Adding Centos 7 repository
if [[ ! -f /etc/yum.repos.d/centos7.repo ]]
then
echo "Adding Centos 7 repository"
cat <<EOF > /etc/yum.repos.d/centos7.repo
[Centos7]
name=Centos 7 (x86_64)
baseurl=http://mirror.centos.org/centos/7/os/x86_64/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
gpgcheck=1
enabled=1
EOF
fi
# Disable Amazon Core Repository
echo "Disabling Amazon Core Repo"
sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/amzn2-core.repo
yum check-update
cat <<EOF > /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.5 (GNU/Linux)
mQINBFOn/0sBEADLDyZ+DQHkcTHDQSE0a0B2iYAEXwpPvs67cJ4tmhe/iMOyVMh9
Yw/vBIF8scm6T/vPN5fopsKiW9UsAhGKg0epC6y5ed+NAUHTEa6pSOdo7CyFDwtn
4HF61Esyb4gzPT6QiSr0zvdTtgYBRZjAEPFVu3Dio0oZ5UQZ7fzdZfeixMQ8VMTQ
4y4x5vik9B+cqmGiq9AW71ixlDYVWasgR093fXiD9NLT4DTtK+KLGYNjJ8eMRqfZ
Ws7g7C+9aEGHfsGZ/SxLOumx/GfiTloal0dnq8TC7XQ/JuNdB9qjoXzRF+faDUsj
WuvNSQEqUXW1dzJjBvroEvgTdfCJfRpIgOrc256qvDMp1SxchMFltPlo5mbSMKu1
x1p4UkAzx543meMlRXOgx2/hnBm6H6L0FsSyDS6P224yF+30eeODD4Ju4BCyQ0jO
IpUxmUnApo/m0eRelI6TRl7jK6aGqSYUNhFBuFxSPKgKYBpFhVzRM63Jsvib82rY
438q3sIOUdxZY6pvMOWRkdUVoz7WBExTdx5NtGX4kdW5QtcQHM+2kht6sBnJsvcB
JYcYIwAUeA5vdRfwLKuZn6SgAUKdgeOtuf+cPR3/E68LZr784SlokiHLtQkfk98j
NXm6fJjXwJvwiM2IiFyg8aUwEEDX5U+QOCA0wYrgUQ/h8iathvBJKSc9jQARAQAB
tEJDZW50T1MtNyBLZXkgKENlbnRPUyA3IE9mZmljaWFsIFNpZ25pbmcgS2V5KSA8
c2VjdXJpdHlAY2VudG9zLm9yZz6JAjUEEwECAB8FAlOn/0sCGwMGCwkIBwMCBBUC
CAMDFgIBAh4BAheAAAoJECTGqKf0qA61TN0P/2730Th8cM+d1pEON7n0F1YiyxqG
QzwpC2Fhr2UIsXpi/lWTXIG6AlRvrajjFhw9HktYjlF4oMG032SnI0XPdmrN29lL
F+ee1ANdyvtkw4mMu2yQweVxU7Ku4oATPBvWRv+6pCQPTOMe5xPG0ZPjPGNiJ0xw
4Ns+f5Q6Gqm927oHXpylUQEmuHKsCp3dK/kZaxJOXsmq6syY1gbrLj2Anq0iWWP4
Tq8WMktUrTcc+zQ2pFR7ovEihK0Rvhmk6/N4+4JwAGijfhejxwNX8T6PCuYs5Jiv
hQvsI9FdIIlTP4XhFZ4N9ndnEwA4AH7tNBsmB3HEbLqUSmu2Rr8hGiT2Plc4Y9AO
aliW1kOMsZFYrX39krfRk2n2NXvieQJ/lw318gSGR67uckkz2ZekbCEpj/0mnHWD
3R6V7m95R6UYqjcw++Q5CtZ2tzmxomZTf42IGIKBbSVmIS75WY+cBULUx3PcZYHD
ZqAbB0Dl4MbdEH61kOI8EbN/TLl1i077r+9LXR1mOnlC3GLD03+XfY8eEBQf7137
YSMiW5r/5xwQk7xEcKlbZdmUJp3ZDTQBXT06vavvp3jlkqqH9QOE8ViZZ6aKQLqv
pL+4bs52jzuGwTMT7gOR5MzD+vT0fVS7Xm8MjOxvZgbHsAgzyFGlI1ggUQmU7lu3
uPNL0eRx4S1G4Jn5
=OGYX
-----END PGP PUBLIC KEY BLOCK-----
EOF
# Here we are installing the required version of the EDB software
yum -y install $EDBdatabase_Version
echo "********************************"
echo "$EDBdatabase_Version is Installed"
echo "********************************"
# If limits.conf exists, add the following lines
if [[ -f /etc/security/limits.conf ]]
then
echo "enterprisedb soft nofile 1024" >> /etc/security/limits.conf
echo "enterprisedb hard nofile 65535" >> /etc/security/limits.conf
fi
# If /pg_wal doesn't exist, create it
if [[ ! -f /pg_wal ]]
then
mkdir /pg_wal
fi
chmod 777 /pg_wal
# Change ownership of data and wal directories to enterprisedb
echo "Change ownership of data and wal directories to enterprisedb"
chown enterprisedb:enterprisedb /pg_wal
chown enterprisedb:enterprisedb $data_dir
# Configure tuned.conf
echo "Configure tuned.conf for enterprisedb"
mkdir -p /etc/tuned/enterprisedb
tunedConfigFile="/etc/tuned/enterprisedb/tuned.conf"
touch $tunedConfigFile
echo "[main]" >> $tunedConfigFile
echo "summary=Tuned profile for PostgreSQL Instances" >> $tunedConfigFile
echo "[bootloader]" >> $tunedConfigFile
echo "cmdline=transparent_hugepage=never" >> $tunedConfigFile
echo "[cpu]" >> $tunedConfigFile
echo "governor=performance" >> $tunedConfigFile
echo "energy_perf_bias=performance" >> $tunedConfigFile
echo "min_perf_pct=100" >> $tunedConfigFile
echo "[sysctl]" >> $tunedConfigFile
echo "vm.swappiness = 10Í" >> $tunedConfigFile
echo "vm.dirty_expire_centisecs = 500" >> $tunedConfigFile
echo "vm.dirty_writeback_centisecs = 250" >> $tunedConfigFile
echo "vm.dirty_ratio = 10" >> $tunedConfigFile
echo "vm.dirty_background_ratio = 5" >> $tunedConfigFile
echo "vm.overcommit_memory=2" >> $tunedConfigFile
echo "net.ipv4.tcp_timestamps=0" >> $tunedConfigFile
# low value for testing - change it to 51200 for SR
echo "vm.nr_hugepages = 51200" >> $tunedConfigFile
echo "fs.file-max = 26290322" >> $tunedConfigFile
echo "kernel.sem = 250 32000 100 128" >> $tunedConfigFile
# low value for testing - change it to 4096 for SR
echo "kernel.shmmni = 4096" >> $tunedConfigFile
# low value for testing - change it to 1073741824 for SR
echo "kernel.shmall = 1073741824" >> $tunedConfigFile
# low value for testing - change it to 4398046511104 for SR
echo "kernel.shmmax = 4398046511104" >> $tunedConfigFile
echo "kernel.panic_on_oops = 1" >> $tunedConfigFile
echo "net.core.rmem_default = 262144" >> $tunedConfigFile
echo "net.core.rmem_max = 4194304" >> $tunedConfigFile
echo "net.core.wmem_default = 262144" >> $tunedConfigFile
echo "net.core.wmem_max = 1048576" >> $tunedConfigFile
echo "net.ipv4.conf.all.rp_filter = 2" >> $tunedConfigFile
echo "net.ipv4.conf.default.rp_filter = 2" >> $tunedConfigFile
echo "fs.aio-max-nr = 1048576" >> $tunedConfigFile
echo "net.ipv4.ip_local_port_range = 9000 65500" >> $tunedConfigFile
echo "" >> $tunedConfigFile
echo "[vm]" >> $tunedConfigFile
echo "transparent_hugepages=never" >> $tunedConfigFile
# Startup tuned
echo "Starting tuned"
systemctl start tuned
# Activating enterprisedb profile
echo "Activating enterprisedb profile"
/usr/sbin/tuned-adm profile enterprisedb &
sleep 5
# Displaying active profile
echo "Displaying active profile"
/usr/sbin/tuned-adm active
cat << EOF > /var/lib/edb/.enterprisedb_profile
export PATH=/usr/edb/as${dbVersion}/bin:\$PATH
alias vmi='vim'
export PS1='[\u@\h \W]\$ '
EOF
chown enterprisedb:enterprisedb /var/lib/edb/.enterprisedb_profile
# Initial Database Setup:
echo "Initial Database Setup"
initialPath="/usr/edb/as${dbVersion}/bin/edb-as-${dbVersion}-setup"
PGSETUP_INITDB_OPTIONS="-E UTF-8" $initialPath initdb
# Changing pg_wal and extra_wal directories to inside the storage
echo "Modifying pg_wal and extra_wal directories"
cd $data_dir
echo "I'am at $(pwd)"
# Moving pg_wal to /pg_wal/pg_wal
mv pg_wal /pg_wal/.
mkdir -p /pg_wal/extra_wal
chown enterprisedb:enterprisedb /pg_wal/extra_wal
ln -s /pg_wal/pg_wal pg_wal
ln -s /pg_wal/extra_wal extra_wal
# Changing ownership of symlinks to enterprisedb
chown enterprisedb:enterprisedb --no-dereference pg_wal
chown enterprisedb:enterprisedb --no-dereference extra_wal
# Configuring postgresql.conf and pg_hba.conf
echo "Configuring postgresql.conf and pg_hba.conf"
echo "Backing up original files"
cp -p $data_dir/postgresql.conf $data_dir/postgresql.conf_ORIGINAL
cp -p $data_dir/pg_hba.conf $data_dir/pg_hba.conf_ORIGINAL
cat << EOF > $data_dir/pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 ident
host replication all ::1/128 ident
host all all 0.0.0.0/0 trust
EOF
cat << EOF > $data_dir/postgresql.conf
# -----------------------------
# PostgreSQL configuration file
# -----------------------------
#
# This file consists of lines of the form:
#
# name = value
#
# (The "=" is optional.) Whitespace may be used. Comments are introduced with
# "#" anywhere on a line. The complete list of parameter names and allowed
# values can be found in the PostgreSQL documentation.
#
# The commented-out settings shown in this file represent the default values.
# Re-commenting a setting is NOT sufficient to revert it to the default value;
# you need to reload the server.
#
# This file is read on server startup and when the server receives a SIGHUP
# signal. If you edit the file on a running system, you have to SIGHUP the
# server for the changes to take effect, run "pg_ctl reload", or execute
# "SELECT pg_reload_conf()". Some parameters, which are marked below,
# require a server shutdown and restart to take effect.
#
# Any parameter can also be given as a command-line option to the server, e.g.,
# "postgres -c log_connections=on". Some parameters can be changed at run time
# with the "SET" SQL command.
#
# Memory units: B = bytes Time units: us = microseconds
# kB = kilobytes ms = milliseconds
# MB = megabytes s = seconds
# GB = gigabytes min = minutes
# TB = terabytes h = hours
# d = days
#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.
#data_directory = 'ConfigDir' # use data in another directory
# (change requires restart)
#hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
# (change requires restart)
#ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
# (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
#external_pid_file = '' # write an extra PID file
# (change requires restart)
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
port = 5444 # (change requires restart)
#max_connections = 100 # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/tmp' # comma-separated list of directories
# (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
#bonjour_name = '' # defaults to the computer name
# (change requires restart)
# - TCP settings -
# see "man tcp" for details
#tcp_keepalives_idle = 0 # TCP_KEEPIDLE, in seconds;
# 0 selects the system default
#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;
# 0 selects the system default
#tcp_keepalives_count = 0 # TCP_KEEPCNT;
# 0 selects the system default
#tcp_user_timeout = 0 # TCP_USER_TIMEOUT, in milliseconds;
# 0 selects the system default
#client_connection_check_interval = 0 # time between checks for client
# disconnection while running queries;
# 0 for never
# - Authentication -
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#db_user_namespace = off
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:\${sysconfdir}/krb5.keytab'
#krb_caseins_users = off
# - SSL -
#ssl = off
#ssl_ca_file = ''
#ssl_cert_file = 'server.crt'
#ssl_crl_file = ''
#ssl_crl_dir = ''
#ssl_key_file = 'server.key'
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
#ssl_prefer_server_ciphers = on
#ssl_ecdh_curve = 'prime256v1'
#ssl_min_protocol_version = 'TLSv1.2'
#ssl_max_protocol_version = ''
#ssl_dh_params_file = ''
#ssl_passphrase_command = ''
#ssl_passphrase_command_supports_reload = off
#------------------------------------------------------------------------------
# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------
# - Memory -
#shared_buffers = 128MB # min 128kB
# (change requires restart)
#huge_pages = try # on, off, or try
# (change requires restart)
#huge_page_size = 0 # zero for system default
# (change requires restart)
#temp_buffers = 8MB # min 800kB
#max_prepared_transactions = 0 # zero disables the feature
# (change requires restart)
# Caution: it is not advisable to set max_prepared_transactions nonzero unless
# you actively intend to use prepared transactions.
#work_mem = 4MB # min 64kB
#hash_mem_multiplier = 1.0 # 1-1000.0 multiplier on hash table work_mem
#maintenance_work_mem = 64MB # min 1MB
#autovacuum_work_mem = -1 # min 1MB, or -1 to use maintenance_work_mem
#logical_decoding_work_mem = 64MB # min 64kB
#max_stack_depth = 2MB # min 100kB
#shared_memory_type = mmap # the default is the first option
# supported by the operating system:
# mmap
# sysv
# windows
# (change requires restart)
dynamic_shared_memory_type = posix # the default is the first option
# supported by the operating system:
# posix
# sysv
# windows
# mmap
# (change requires restart)
#min_dynamic_shared_memory = 0MB # (change requires restart)
# - Disk -
#temp_file_limit = -1 # limits per-process temp file space
# in kilobytes, or -1 for no limit
# - Kernel Resources -
#max_files_per_process = 1000 # min 64
# (change requires restart)
# - Cost-Based Vacuum Delay -
#vacuum_cost_delay = 0 # 0-100 milliseconds (0 disables)
#vacuum_cost_page_hit = 1 # 0-10000 credits
#vacuum_cost_page_miss = 2 # 0-10000 credits
#vacuum_cost_page_dirty = 20 # 0-10000 credits
#vacuum_cost_limit = 200 # 1-10000 credits
# - Background Writer -
#bgwriter_delay = 200ms # 10-10000ms between rounds
#bgwriter_lru_maxpages = 100 # max buffers written/round, 0 disables
#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
#bgwriter_flush_after = 512kB # measured in pages, 0 disables
# - Asynchronous Behavior -
#backend_flush_after = 0 # measured in pages, 0 disables
#effective_io_concurrency = 1 # 1-1000; 0 disables prefetching
#maintenance_io_concurrency = 10 # 1-1000; 0 disables prefetching
#max_worker_processes = 8 # (change requires restart)
#max_parallel_workers_per_gather = 2 # taken from max_parallel_workers
#max_parallel_maintenance_workers = 2 # taken from max_parallel_workers
#max_parallel_workers = 8 # maximum number of max_worker_processes that
# can be used in parallel operations
#parallel_leader_participation = on
#old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate
# (change requires restart)
# - EDB Resource Manager -
#edb_max_resource_groups = 16 # 0-65536; (change requires restart)
#edb_resource_group = ''
#------------------------------------------------------------------------------
# WRITE-AHEAD LOG
#------------------------------------------------------------------------------
# - Settings -
#wal_level = replica # minimal, replica, or logical
# (change requires restart)
#fsync = on # flush data to disk for crash safety
# (turning this off can cause
# unrecoverable data corruption)
#synchronous_commit = on # synchronization level;
# off, local, remote_write, remote_apply, or on
#wal_sync_method = fsync # the default is the first option
# supported by the operating system:
# open_datasync
# fdatasync (default on Linux and FreeBSD)
# fsync
# fsync_writethrough
# open_sync
#full_page_writes = on # recover from partial page writes
#wal_log_hints = off # also do full page writes of non-critical updates
# (change requires restart)
#wal_compression = off # enable compression of full-page writes
#wal_init_zero = on # zero-fill new WAL files
#wal_recycle = on # recycle WAL files
#wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers
# (change requires restart)
#wal_writer_delay = 200ms # 1-10000 milliseconds
#wal_writer_flush_after = 1MB # measured in pages, 0 disables
#wal_skip_threshold = 2MB
#commit_delay = 0 # range 0-100000, in microseconds
#commit_siblings = 5 # range 1-1000
# - Checkpoints -
#checkpoint_timeout = 5min # range 30s-1d
#checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
#checkpoint_flush_after = 256kB # measured in pages, 0 disables
#checkpoint_warning = 30s # 0 disables
max_wal_size = 60GB
##min_wal_size = 80MB
# - Archiving -
#archive_mode = off # enables archiving; off, on, or always
# (change requires restart)
#archive_command = '' # command to use to archive a logfile segment
# placeholders: %p = path of file to archive
# %f = file name only
# e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
#archive_timeout = 0 # force a logfile segment switch after this
# number of seconds; 0 disables
# - Archive Recovery -
# These are only used in recovery mode.
#restore_command = '' # command to use to restore an archived logfile segment
# placeholders: %p = path of file to restore
# %f = file name only
# e.g. 'cp /mnt/server/archivedir/%f %p'
#archive_cleanup_command = '' # command to execute at every restartpoint
#recovery_end_command = '' # command to execute at completion of recovery
# - Recovery Target -
# Set these only when performing a targeted recovery.
#recovery_target = '' # 'immediate' to end recovery as soon as a
# consistent state is reached
# (change requires restart)
#recovery_target_name = '' # the named restore point to which recovery will proceed
# (change requires restart)
#recovery_target_time = '' # the time stamp up to which recovery will proceed
# (change requires restart)
#recovery_target_xid = '' # the transaction ID up to which recovery will proceed
# (change requires restart)
#recovery_target_lsn = '' # the WAL LSN up to which recovery will proceed
# (change requires restart)
#recovery_target_inclusive = on # Specifies whether to stop:
# just after the specified recovery target (on)
# just before the recovery target (off)
# (change requires restart)
#recovery_target_timeline = 'latest' # 'current', 'latest', or timeline ID
# (change requires restart)
#recovery_target_action = 'pause' # 'pause', 'promote', 'shutdown'
# (change requires restart)
#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------
# - Sending Servers -
# Set these on the primary and on any standby that will send replication data.
#max_wal_senders = 10 # max number of walsender processes
# (change requires restart)
#max_replication_slots = 10 # max number of replication slots
# (change requires restart)
#wal_keep_size = 0 # in megabytes; 0 disables
#max_slot_wal_keep_size = -1 # in megabytes; -1 disables
#wal_sender_timeout = 60s # in milliseconds; 0 disables
#track_commit_timestamp = off # collect timestamp of transaction commit
# (change requires restart)
# - Primary Server -
# These settings are ignored on a standby server.
#synchronous_standby_names = '' # standby servers that provide sync rep
# method to choose sync standbys, number of sync standbys,
# and comma-separated list of application_name
# from standby(s); '*' = all
#synchronous_replication_availability = wait
#vacuum_defer_cleanup_age = 0 # number of xacts by which cleanup is delayed
# - Standby Servers -
# These settings are ignored on a primary server.
#primary_conninfo = '' # connection string to sending server
#primary_slot_name = '' # replication slot on sending server
#promote_trigger_file = '' # file name whose presence ends recovery
#hot_standby = on # "off" disallows queries during recovery
# (change requires restart)
#max_standby_archive_delay = 30s # max delay before canceling queries
# when reading WAL from archive;
# -1 allows indefinite delay
#max_standby_streaming_delay = 30s # max delay before canceling queries
# when reading streaming WAL;
# -1 allows indefinite delay
#wal_receiver_create_temp_slot = off # create temp slot if primary_slot_name
# is not set
#wal_receiver_status_interval = 10s # send replies at least this often
# 0 disables
#hot_standby_feedback = off # send info from standby to prevent
# query conflicts
#wal_receiver_timeout = 60s # time that receiver waits for
# communication from primary
# in milliseconds; 0 disables
#wal_retrieve_retry_interval = 5s # time to wait before retrying to
# retrieve WAL after a failed attempt
#recovery_min_apply_delay = 0 # minimum delay for applying changes during recovery
# - Subscribers -
# These settings are ignored on a publisher.
#max_logical_replication_workers = 4 # taken from max_worker_processes
# (change requires restart)
#max_sync_workers_per_subscription = 2 # taken from max_logical_replication_workers
#------------------------------------------------------------------------------
# QUERY TUNING
#------------------------------------------------------------------------------
# - Planner Method Configuration -
#enable_async_append = on
#enable_bitmapscan = on
#enable_gathermerge = on
#enable_hashagg = on
#enable_hashjoin = on
#enable_incremental_sort = on
#enable_indexscan = on
#enable_indexonlyscan = on
#enable_material = on
#enable_memoize = on
#enable_mergejoin = on
#enable_nestloop = on
#enable_parallel_append = on
#enable_parallel_hash = on
#enable_partition_pruning = on
#enable_partitionwise_join = off
#enable_partitionwise_aggregate = off
#enable_seqscan = on
#enable_sort = on
#enable_tidscan = on
#enable_hints = on # enable optimizer hints in SQL statements.
#edb_enable_pruning = on # fast pruning for EDB-partitioned tables
# - Planner Cost Constants -
#seq_page_cost = 1.0 # measured on an arbitrary scale
#random_page_cost = 4.0 # same scale as above
#cpu_tuple_cost = 0.01 # same scale as above
#cpu_index_tuple_cost = 0.005 # same scale as above
#cpu_operator_cost = 0.0025 # same scale as above
#parallel_setup_cost = 1000.0 # same scale as above
#parallel_tuple_cost = 0.1 # same scale as above
#min_parallel_table_scan_size = 8MB
#min_parallel_index_scan_size = 512kB
#effective_cache_size = 4GB
#jit_above_cost = 100000 # perform JIT compilation if available
# and query more expensive than this;
# -1 disables
#jit_inline_above_cost = 500000 # inline small functions if query is
# more expensive than this; -1 disables
#jit_optimize_above_cost = 500000 # use expensive JIT optimizations if
# query is more expensive than this;
# -1 disables
# - Genetic Query Optimizer -
#geqo = on
#geqo_threshold = 12
#geqo_effort = 5 # range 1-10
#geqo_pool_size = 0 # selects default based on effort
#geqo_generations = 0 # selects default based on effort
#geqo_selection_bias = 2.0 # range 1.5-2.0
#geqo_seed = 0.0 # range 0.0-1.0
# - Other Planner Options -
#default_statistics_target = 100 # range 1-10000
#constraint_exclusion = partition # on, off, or partition
#cursor_tuple_fraction = 0.1 # range 0.0-1.0
#from_collapse_limit = 8
#jit = on # allow JIT compilation
#join_collapse_limit = 8 # 1 disables collapsing of explicit
# JOIN clauses
#plan_cache_mode = auto # auto, force_generic_plan or
# force_custom_plan
#------------------------------------------------------------------------------
# REPORTING AND LOGGING
#------------------------------------------------------------------------------
# - Where to Log -
log_destination = 'stderr' # Valid values are combinations of
# stderr, csvlog, syslog, and eventlog,
# depending on platform. csvlog
# requires logging_collector to be on.
# This is used when logging to stderr:
logging_collector = on # Enable capturing of stderr and csvlog
# into log files. Required to be on for
# csvlogs.
# (change requires restart)
# These are only used if logging_collector is on:
#log_directory = 'log' # directory where log files are written,
# can be absolute or relative to PGDATA
#log_filename = 'edb-%Y-%m-%d_%H%M%S.log' # log file name pattern,
# can include strftime() escapes
#log_file_mode = 0600 # creation mode for log files,
# begin with 0 to use octal notation
#log_rotation_age = 1d # Automatic rotation of logfiles will
# happen after that time. 0 disables.
#log_rotation_size = 10MB # Automatic rotation of logfiles will
# happen after that much log output.
# 0 disables.
#log_truncate_on_rotation = off # If on, an existing log file with the
# same name as the new log file will be
# truncated rather than appended to.
# But such truncation only occurs on
# time-driven rotation, not on restarts
# or size-driven rotation. Default is
# off, meaning append to existing files
# in all cases.
# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'
#syslog_sequence_numbers = on
#syslog_split_messages = on
# This is only relevant when logging to eventlog (Windows):
# (change requires restart)
#event_source = 'EnterpriseDB'
# - When to Log -
#log_min_messages = warning # values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# info
# notice
# warning
# error
# log
# fatal
# panic
#log_min_error_statement = error # values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# info
# notice
# warning
# error
# log
# fatal
# panic (effectively off)
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds
#log_min_duration_sample = -1 # -1 is disabled, 0 logs a sample of statements
# and their durations, > 0 logs only a sample of
# statements running at least this number
# of milliseconds;
# sample fraction is determined by log_statement_sample_rate
#log_statement_sample_rate = 1.0 # fraction of logged statements exceeding
# log_min_duration_sample to be logged;
# 1.0 logs all such statements, 0.0 never logs
#log_transaction_sample_rate = 0.0 # fraction of transactions whose statements
# are logged regardless of their duration; 1.0 logs all
# statements from all transactions, 0.0 never logs
# - What to Log -
#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = on
#log_autovacuum_min_duration = -1 # log autovacuum activity;
# -1 disables, 0 logs all actions and
# their durations, > 0 logs only
# actions running at least this number
# of milliseconds.
#log_checkpoints = off
#log_connections = off