-
Notifications
You must be signed in to change notification settings - Fork 6
/
install.sh
executable file
·199 lines (158 loc) · 5.19 KB
/
install.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
#!/bin/bash
#
# Copyright (c) 2013-2014 PgPool Global Development Group
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# granted, provided that the above copyright notice appear in all
# copies and that both that copyright notice and this permission
# notice appear in supporting documentation, and that the name of the
# author not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. The author makes no representations about the
# suitability of this software for any purpose. It is provided "as
# is" without express or implied warranty.
#
# [ About this sctipt ]
# install.sh: Install script for pgpool-II
# If you change the defalt vaklue, modify lib/params.sh.
# ===================================================================
# main
# ===================================================================
source lib/params.sh
source lib/0_common.sh
source lib/1_check.sh
source lib/2_nodes.sh
source lib/3_pgpool.sh
source lib/4_install.sh
clearScreen
# -------------------------------------------------------------------
# [1] check
# -------------------------------------------------------------------
# 1-1. check environment
#checkEnv
#if [ $? -ne 0 ]; then exit 1; fi
# 1-2. license agreement
agreeLiense
if [ $? -ne 0 ]; then exit 1; fi
#} 1-3. editing config?
echo
editConfigs
if [ $? -ne 0 ]; then exit 1; fi
if [ -e installer.conf ]; then
ynQuestion "There is the file installer.conf. Do you use it?"
if [ $? -eq 0 ]; then
source installer.conf > /dev/null 2>&1
mv installer.conf installer-`date +'%Y%m%d_%H%M'`.conf
echo "Loaded."
else
mv installer.conf installer-`date +'%Y%m%d_%H%M'`.conf
echo "Deleted."
touch installer.conf
fi
fi
if [ $# -ne 0]; then
FI
goNext
# -------------------------------------------------------------------
# [2] Node information
# -------------------------------------------------------------------
title "Configuring Hosts, User, SSH"
subtitle "Watchdog"
ynQuestion "Do you use the watchdog feature of pgpool?"
if [ $? -eq 0 ]; then
USE_WATCHDOG="yes"
fi
echo
subtitle "Specify the nodes in this cluster"
specifyNodes
specifyNetmask
# -------------------------------------------------------------------
goNext
title "Configuring Hosts, User, SSH"
setupSSHwoPW
if [ $? -ne 0 ]; then
echo "Failed."
exit 1
fi
echo
subtitle "Check PostgreSQL installed in each backends"
checkPostgresInstalled || exit 1
# Copy install scripts to pgpool#1.
if [ "${USE_WATCHDOG}" == "yes" ]; then
scp -r ${WORK_DIR} ${PGPOOL_HOST_ARR[1]}:${REMOTE_WORK_DIR} > /dev/null 2>&1
fi
goNext
# -------------------------------------------------------------------
# [3] Editting conf files
# -------------------------------------------------------------------
# create temporary config files in editted directory
rm -rf editted/
mkdir editted/
# create editted/pgpool.conf.node{0, 1}
title "Editting conf files (pgpool#0: ${PGPOOL_HOST_ARR[0]})"
pgpoolConfNode0
if [ "${USE_WATCHDOG}" == "yes" ]; then
title "Editting conf files (pgpool#1: ${PGPOOL_HOST_ARR[1]})"
pgpoolConfNode1
fi
goNext
# -------------------------------------------------------------------
# [4] Install
# -------------------------------------------------------------------
title "Installation (pgpool#0: ${PGPOOL_HOST_ARR[0]})"
subtitle "Setup pgpool-II"
setupPgpool 0 || exit 1
subtitle "Setup pgpoolAdmin"
setupPgpoolAdmin || exit 1
if [ "${USE_WATCHDOG}" == "yes" ]; then
goNext
title "Installation (pgpool#1: ${PGPOOL_HOST_ARR[1]})"
subtitle "Setup pgpool-II"
doViaSSH root ${PGPOOL_HOST_ARR[1]} "
mkdir ${REMOTER_WORK_DIR}
" > /dev/null 2>&1
scp -r ./* ${PGPOOL_HOST_ARR[1]}:${REMOTE_WORK_DIR}/ > /dev/null 2>&1
echo
doViaSSH root ${PGPOOL_HOST_ARR[1]} "
cd ${REMOTE_WORK_DIR}
echo \"USE_WATCHDOG=yes\" >> lib/params.sh
source lib/params.sh
source lib/0_common.sh
source lib/4_install.sh
setupPgpool 1
" || exit 1
subtitle "Setup pgpoolAdmin"
doViaSSH root ${PGPOOL_HOST_ARR[1]} "
cd ${REMOTE_WORK_DIR}
source lib/params.sh
source lib/0_common.sh
source lib/4_install.sh
setupPgpoolAdmin
" || exit 1
fi
goNext
# -------------------------------------------------------------------
# [5] initdb and put config files
# -------------------------------------------------------------------
title "Setup backend nodes of PostgreSQL"
_VAL=""
_NODE_NUM=0
for _VAL in `arrayUnique ${BACKEND_HOST_ARR[@]}`; do
subtitle "Setup backend node (postgres#${_NODE_NUM}: ${_VAL})"
setupBackend ${_NODE_NUM}
_NODE_NUM=`expr ${_NODE_NUM} + 1`
done
subtitle "Prepare the first failover"
prepareFailOver
goNext
# -------------------------------------------------------------------
title "Completed!"
service httpd start > /dev/null 2>&1
if [ "${USE_WATCHDOG}" == "yes" ]; then
doViaSSH root ${PGPOOL_HOST_ARR[1]} "service httpd start > /dev/null 2>&1"
fi
echo " * See pgpoolAdmin."
echo " http://${THIS_HOST}/pgpoolAdmin/"
echo " * Do online recovery of node 1 from pgpoolAdmin"
exit 0