install.sh 20.5 KB
Newer Older
D
dailidong 已提交
1
#!/bin/sh
2

D
dailidong 已提交
3 4
workDir=`dirname $0`
workDir=`cd ${workDir};pwd`
D
dailidong 已提交
5

D
dailidong 已提交
6 7 8 9 10 11 12 13 14 15
#To be compatible with MacOS and Linux
txt=""
if [[ "$OSTYPE" == "darwin"* ]]; then
    # Mac OSX
    txt="''"
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
    # linux
    txt=""
elif [[ "$OSTYPE" == "cygwin" ]]; then
    # POSIX compatibility layer and Linux environment emulation for Windows
Q
qiaozhanwei 已提交
16
    echo "DolphinScheduler not support Windows operating system"
D
dailidong 已提交
17 18 19
    exit 1
elif [[ "$OSTYPE" == "msys" ]]; then
    # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
Q
qiaozhanwei 已提交
20
    echo "DolphinScheduler not support Windows operating system"
D
dailidong 已提交
21 22
    exit 1
elif [[ "$OSTYPE" == "win32" ]]; then
Q
qiaozhanwei 已提交
23
    echo "DolphinScheduler not support Windows operating system"
D
dailidong 已提交
24 25 26 27 28 29 30 31 32 33
    exit 1
elif [[ "$OSTYPE" == "freebsd"* ]]; then
    # ...
    txt=""
else
    # Unknown.
    echo "Operating system unknown, please tell us(submit issue) for better service"
    exit 1
fi

D
dailidong 已提交
34 35
source ${workDir}/conf/config/run_config.conf
source ${workDir}/conf/config/install_config.conf
36

Q
qiaozhanwei 已提交
37 38 39 40 41 42
# for example mysql or postgresql ...
dbtype="mysql"

# db config
# db address and port
dbhost="192.168.xx.xx:3306"
43

44
# mysql database
Q
qiaozhanwei 已提交
45
dbname="dolphinscheduler"
46

47
# mysql username
Q
qiaozhanwei 已提交
48
username="xx"
49

50 51
# mysql passwprd
# Note: if there are special characters, please use the \ transfer character to transfer
Q
qiaozhanwei 已提交
52
passowrd="xx"
53

54 55
# conf/config/install_config.conf config
# Note: the installation path is not the same as the current path (pwd)
Q
qiaozhanwei 已提交
56
installPath="/data1_1T/dolphinscheduler"
B
baoliang 已提交
57

58 59
# deployment user
# Note: the deployment user needs to have sudo privileges and permissions to operate hdfs. If hdfs is enabled, the root directory needs to be created by itself
Q
qiaozhanwei 已提交
60
deployUser="dolphinscheduler"
B
baoliang 已提交
61

62
# zk cluster
B
baoliang 已提交
63 64
zkQuorum="192.168.xx.xx:2181,192.168.xx.xx:2181,192.168.xx.xx:2181"

65 66
# install hosts
# Note: install the scheduled hostname list. If it is pseudo-distributed, just write a pseudo-distributed hostname
B
baoliang 已提交
67 68
ips="ark0,ark1,ark2,ark3,ark4"

69 70 71
# conf/config/run_config.conf config
# run master machine
# Note: list of hosts hostname for deploying master
B
baoliang 已提交
72 73
masters="ark0,ark1"

74 75
# run worker machine
# note: list of machine hostnames for deploying workers
B
baoliang 已提交
76 77
workers="ark2,ark3,ark4"

78 79
# run alert machine
# note: list of machine hostnames for deploying alert server
B
baoliang 已提交
80 81
alertServer="ark3"

82 83
# run api machine
# note: list of machine hostnames for deploying api server
B
baoliang 已提交
84 85
apiServers="ark1"

86 87
# alert config
# mail protocol
B
baoliang 已提交
88 89
mailProtocol="SMTP"

90
# mail server host
B
baoliang 已提交
91 92
mailServerHost="smtp.exmail.qq.com"

93
# mail server port
B
baoliang 已提交
94 95
mailServerPort="25"

96
# sender
B
baoliang 已提交
97 98
mailSender="xxxxxxxxxx"

Q
qiaozhanwei 已提交
99 100 101
# user
mailUser="xxxxxxxxxx"

102
# sender password
B
baoliang 已提交
103 104
mailPassword="xxxxxxxxxx"

105
# TLS mail protocol support
106 107
starttlsEnable="false"

Q
qiaozhanwei 已提交
108 109
sslTrust="xxxxxxxxxx"

110 111 112
# SSL mail protocol support
# note: The SSL protocol is enabled by default. 
# only one of TLS and SSL can be in the true state.
113 114
sslEnable="true"

115
# download excel path
B
baoliang 已提交
116 117
xlsFilePath="/tmp/xls"

118
# Enterprise WeChat Enterprise ID Configuration
L
lgcareer 已提交
119 120
enterpriseWechatCorpId="xxxxxxxxxx"

121
# Enterprise WeChat application Secret configuration
L
lgcareer 已提交
122 123
enterpriseWechatSecret="xxxxxxxxxx"

124
# Enterprise WeChat Application AgentId Configuration
L
lgcareer 已提交
125 126
enterpriseWechatAgentId="xxxxxxxxxx"

127
# Enterprise WeChat user configuration, multiple users to , split
L
lgcareer 已提交
128 129
enterpriseWechatUsers="xxxxx,xxxxx"

Q
qiaozhanwei 已提交
130 131 132
# alert port
alertPort=7789

133

134
# whether to start monitoring self-starting scripts
135 136
monitorServerState="false"

137
# resource Center upload and select storage method:HDFS,S3,NONE
journey2018's avatar
journey2018 已提交
138
resUploadStartupType="NONE"
B
baoliang 已提交
139

140
# if resUploadStartupType is HDFS,defaultFS write namenode address,HA you need to put core-site.xml and hdfs-site.xml in the conf directory.
Q
qiaozhanwei 已提交
141 142
# if S3,write S3 address,HA,for example :s3a://dolphinscheduler,
# Note,s3 be sure to create the root directory /dolphinscheduler
journey2018's avatar
journey2018 已提交
143 144
defaultFS="hdfs://mycluster:8020"

145
# if S3 is configured, the following configuration is required.
journey2018's avatar
journey2018 已提交
146 147 148
s3Endpoint="http://192.168.xx.xx:9010"
s3AccessKey="xxxxxxxxxx"
s3SecretKey="xxxxxxxxxx"
149

150
# resourcemanager HA configuration, if it is a single resourcemanager, here is yarnHaIps=""
D
dailidong 已提交
151
yarnHaIps="192.168.xx.xx,192.168.xx.xx"
152

153
# if it is a single resourcemanager, you only need to configure one host name. If it is resourcemanager HA, the default configuration is fine.
D
dailidong 已提交
154
singleYarnIp="ark1"
155

156 157
# hdfs root path, the owner of the root path must be the deployment user. 
# versions prior to 1.1.0 do not automatically create the hdfs root directory, you need to create it yourself.
Q
qiaozhanwei 已提交
158
hdfsPath="/dolphinscheduler"
159

160 161
# have users who create directory permissions under hdfs root path /
# Note: if kerberos is enabled, hdfsRootUser="" can be used directly.
L
lgcareer 已提交
162 163
hdfsRootUser="hdfs"

164 165
# common config
# Program root path
Q
qiaozhanwei 已提交
166
programPath="/tmp/dolphinscheduler"
167

168
# download path
Q
qiaozhanwei 已提交
169
downloadPath="/tmp/dolphinscheduler/download"
170

171
# task execute path
Q
qiaozhanwei 已提交
172
execPath="/tmp/dolphinscheduler/exec"
173

174
# SHELL environmental variable path
175
shellEnvPath="$installPath/conf/env/.dolphinscheduler_env.sh"
176

177
# suffix of the resource file
D
dailidong 已提交
178
resSuffixs="txt,log,sh,conf,cfg,py,java,sql,hql,xml"
179

180 181
# development status, if true, for the SHELL script, you can view the encapsulated SHELL script in the execPath directory. 
# If it is false, execute the direct delete
D
dailidong 已提交
182
devState="true"
183

184 185
# kerberos config
# kerberos whether to start
journey2018's avatar
journey2018 已提交
186 187
kerberosStartUp="false"

188
# kdc krb5 config file path
journey2018's avatar
journey2018 已提交
189 190
krb5ConfPath="$installPath/conf/krb5.conf"

191
# keytab username
journey2018's avatar
journey2018 已提交
192 193
keytabUserName="hdfs-mycluster@ESZ.COM"

194
# username keytab path
journey2018's avatar
journey2018 已提交
195 196
keytabPath="$installPath/conf/hdfs.headless.keytab"

197 198
# zk config
# zk root directory
Q
qiaozhanwei 已提交
199
zkRoot="/dolphinscheduler"
200

201
# used to record the zk directory of the hanging machine
Q
qiaozhanwei 已提交
202
zkDeadServers="$zkRoot/dead-servers"
203

204 205
# masters directory
zkMasters="$zkRoot/masters"
206

207 208
# workers directory
zkWorkers="$zkRoot/workers"
209

210 211
# zk master distributed lock
mastersLock="$zkRoot/lock/masters"
212

213 214
# zk worker distributed lock
workersLock="$zkRoot/lock/workers"
215

216 217
# zk master fault-tolerant distributed lock
mastersFailover="$zkRoot/lock/failover/masters"
218

219 220
# zk worker fault-tolerant distributed lock
workersFailover="$zkRoot/lock/failover/workers"
221

222 223
# zk master start fault tolerant distributed lock
mastersStartupFailover="$zkRoot/lock/failover/startup-masters"
224

225
# zk session timeout
226 227
zkSessionTimeout="300"

228
# zk connection timeout
229 230
zkConnectionTimeout="300"

231
# zk retry interval
D
dailidong 已提交
232
zkRetrySleep="100"
233

234
# zk retry maximum number of times
D
dailidong 已提交
235
zkRetryMaxtime="5"
236 237


238 239
# master config 
# master execution thread maximum number, maximum parallelism of process instance
D
dailidong 已提交
240
masterExecThreads="100"
241

242
# the maximum number of master task execution threads, the maximum degree of parallelism for each process instance
D
dailidong 已提交
243
masterExecTaskNum="20"
244

245
# master heartbeat interval
D
dailidong 已提交
246
masterHeartbeatInterval="10"
247

248
# master task submission retries
D
dailidong 已提交
249
masterTaskCommitRetryTimes="5"
250

251
# master task submission retry interval
D
dailidong 已提交
252
masterTaskCommitInterval="100"
253

254
# master maximum cpu average load, used to determine whether the master has execution capability
D
dailidong 已提交
255
masterMaxCpuLoadAvg="10"
256

257
# master reserve memory to determine if the master has execution capability
D
dailidong 已提交
258
masterReservedMemory="1"
259

Q
qiaozhanwei 已提交
260 261 262
# master port
masterPort=5566

263

264 265
# worker config 
# worker execution thread
D
dailidong 已提交
266
workerExecThreads="100"
267

268
# worker heartbeat interval
D
dailidong 已提交
269
workerHeartbeatInterval="10"
270

271
# worker number of fetch tasks
D
dailidong 已提交
272
workerFetchTaskNum="3"
273

274
# worker reserve memory to determine if the master has execution capability
D
dailidong 已提交
275
workerReservedMemory="1"
276

Q
qiaozhanwei 已提交
277 278 279 280
# master port
workerPort=7788


281 282
# api config
# api server port
D
dailidong 已提交
283
apiServerPort="12345"
284

285
# api session timeout
D
dailidong 已提交
286
apiServerSessionTimeout="7200"
287

288
# api server context path
Q
qiaozhanwei 已提交
289
apiServerContextPath="/dolphinscheduler/"
290

291
# spring max file size
D
dailidong 已提交
292
springMaxFileSize="1024MB"
293

294
# spring max request size
D
dailidong 已提交
295
springMaxRequestSize="1024MB"
296

297
# api max http post size
298 299
apiMaxHttpPostSize="5000000"

Q
qiaozhanwei 已提交
300

301 302
# 1,replace file
echo "1,replace file"
Q
qiaozhanwei 已提交
303
if [ $dbtype == "mysql" ];then
Q
qiaozhanwei 已提交
304 305 306 307
    sed -i ${txt} "s#spring.datasource.url.*#spring.datasource.url=jdbc:mysql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.username.*#spring.datasource.username=${username}#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.password.*#spring.datasource.password=${passowrd}#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.driver-class-name.*#spring.datasource.driver-class-name=com.mysql.jdbc.Driver#g" conf/application.properties
Q
qiaozhanwei 已提交
308 309 310 311 312 313 314 315 316


    sed -i ${txt} "s#org.quartz.dataSource.myDs.URL.*#org.quartz.dataSource.myDs.URL=jdbc:mysql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.user.*#org.quartz.dataSource.myDs.user=${username}#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.password.*#org.quartz.dataSource.myDs.password=${passowrd}#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.driver.*#org.quartz.dataSource.myDs.driver=com.mysql.jdbc.Driver#g" conf/quartz.properties
fi

if [ $dbtype == "postgresql" ];then
Q
qiaozhanwei 已提交
317 318 319 320
    sed -i ${txt} "s#spring.datasource.url.*#spring.datasource.url=jdbc:postgresql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.username.*#spring.datasource.username=${username}#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.password.*#spring.datasource.password=${passowrd}#g" conf/application.properties
    sed -i ${txt} "s#spring.datasource.driver-class-name.*#spring.datasource.driver-class-name=org.postgresql.Driver#g" conf/application.properties
Q
qiaozhanwei 已提交
321 322 323 324 325 326

    sed -i ${txt} "s#org.quartz.dataSource.myDs.URL.*#org.quartz.dataSource.myDs.URL=jdbc:mysql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.user.*#org.quartz.dataSource.myDs.user=${username}#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.password.*#org.quartz.dataSource.myDs.password=${passowrd}#g" conf/quartz.properties
    sed -i ${txt} "s#org.quartz.dataSource.myDs.driver.*#org.quartz.dataSource.myDs.driver=org.postgresql.Driver#g" conf/quartz.properties
fi
D
dailidong 已提交
327 328 329



journey2018's avatar
journey2018 已提交
330 331 332 333
sed -i ${txt} "s#fs.defaultFS.*#fs.defaultFS=${defaultFS}#g" conf/common/hadoop/hadoop.properties
sed -i ${txt} "s#fs.s3a.endpoint.*#fs.s3a.endpoint=${s3Endpoint}#g" conf/common/hadoop/hadoop.properties
sed -i ${txt} "s#fs.s3a.access.key.*#fs.s3a.access.key=${s3AccessKey}#g" conf/common/hadoop/hadoop.properties
sed -i ${txt} "s#fs.s3a.secret.key.*#fs.s3a.secret.key=${s3SecretKey}#g" conf/common/hadoop/hadoop.properties
D
dailidong 已提交
334 335 336
sed -i ${txt} "s#yarn.resourcemanager.ha.rm.ids.*#yarn.resourcemanager.ha.rm.ids=${yarnHaIps}#g" conf/common/hadoop/hadoop.properties
sed -i ${txt} "s#yarn.application.status.address.*#yarn.application.status.address=http://${singleYarnIp}:8088/ws/v1/cluster/apps/%s#g" conf/common/hadoop/hadoop.properties

337

D
dailidong 已提交
338 339 340
sed -i ${txt} "s#data.basedir.path.*#data.basedir.path=${programPath}#g" conf/common/common.properties
sed -i ${txt} "s#data.download.basedir.path.*#data.download.basedir.path=${downloadPath}#g" conf/common/common.properties
sed -i ${txt} "s#process.exec.basepath.*#process.exec.basepath=${execPath}#g" conf/common/common.properties
L
lgcareer 已提交
341
sed -i ${txt} "s#hdfs.root.user.*#hdfs.root.user=${hdfsRootUser}#g" conf/common/common.properties
D
dailidong 已提交
342
sed -i ${txt} "s#data.store2hdfs.basepath.*#data.store2hdfs.basepath=${hdfsPath}#g" conf/common/common.properties
journey2018's avatar
journey2018 已提交
343
sed -i ${txt} "s#res.upload.startup.type.*#res.upload.startup.type=${resUploadStartupType}#g" conf/common/common.properties
Q
qiaozhanwei 已提交
344
sed -i ${txt} "s#dolphinscheduler.env.path.*#dolphinscheduler.env.path=${shellEnvPath}#g" conf/common/common.properties
D
dailidong 已提交
345 346
sed -i ${txt} "s#resource.view.suffixs.*#resource.view.suffixs=${resSuffixs}#g" conf/common/common.properties
sed -i ${txt} "s#development.state.*#development.state=${devState}#g" conf/common/common.properties
347 348 349 350
sed -i ${txt} "s#hadoop.security.authentication.startup.state.*#hadoop.security.authentication.startup.state=${kerberosStartUp}#g" conf/common/common.properties
sed -i ${txt} "s#java.security.krb5.conf.path.*#java.security.krb5.conf.path=${krb5ConfPath}#g" conf/common/common.properties
sed -i ${txt} "s#login.user.keytab.username.*#login.user.keytab.username=${keytabUserName}#g" conf/common/common.properties
sed -i ${txt} "s#login.user.keytab.path.*#login.user.keytab.path=${keytabPath}#g" conf/common/common.properties
D
dailidong 已提交
351 352

sed -i ${txt} "s#zookeeper.quorum.*#zookeeper.quorum=${zkQuorum}#g" conf/zookeeper.properties
Q
qiaozhanwei 已提交
353 354 355 356 357 358 359 360 361
sed -i ${txt} "s#zookeeper.dolphinscheduler.root.*#zookeeper.dolphinscheduler.root=${zkRoot}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.dead.servers.*#zookeeper.dolphinscheduler.dead.servers=${zkDeadServers}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.masters.*#zookeeper.dolphinscheduler.masters=${zkMasters}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.workers.*#zookeeper.dolphinscheduler.workers=${zkWorkers}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.masters.*#zookeeper.dolphinscheduler.lock.masters=${mastersLock}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.workers.*#zookeeper.dolphinscheduler.lock.workers=${workersLock}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.masters.*#zookeeper.dolphinscheduler.lock.failover.masters=${mastersFailover}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.workers.*#zookeeper.dolphinscheduler.lock.failover.workers=${workersFailover}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.startup.masters.*#zookeeper.dolphinscheduler.lock.failover.startup.masters=${mastersStartupFailover}#g" conf/zookeeper.properties
D
dailidong 已提交
362 363 364 365 366 367 368 369 370 371 372
sed -i ${txt} "s#zookeeper.session.timeout.*#zookeeper.session.timeout=${zkSessionTimeout}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.connection.timeout.*#zookeeper.connection.timeout=${zkConnectionTimeout}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.retry.sleep.*#zookeeper.retry.sleep=${zkRetrySleep}#g" conf/zookeeper.properties
sed -i ${txt} "s#zookeeper.retry.maxtime.*#zookeeper.retry.maxtime=${zkRetryMaxtime}#g" conf/zookeeper.properties

sed -i ${txt} "s#master.exec.threads.*#master.exec.threads=${masterExecThreads}#g" conf/master.properties
sed -i ${txt} "s#master.exec.task.number.*#master.exec.task.number=${masterExecTaskNum}#g" conf/master.properties
sed -i ${txt} "s#master.heartbeat.interval.*#master.heartbeat.interval=${masterHeartbeatInterval}#g" conf/master.properties
sed -i ${txt} "s#master.task.commit.retryTimes.*#master.task.commit.retryTimes=${masterTaskCommitRetryTimes}#g" conf/master.properties
sed -i ${txt} "s#master.task.commit.interval.*#master.task.commit.interval=${masterTaskCommitInterval}#g" conf/master.properties
sed -i ${txt} "s#master.reserved.memory.*#master.reserved.memory=${masterReservedMemory}#g" conf/master.properties
Q
qiaozhanwei 已提交
373
sed -i ${txt} "s#server.port.*#server.port=${masterPort}#g" conf/application-master.properties
D
dailidong 已提交
374 375 376 377 378 379


sed -i ${txt} "s#worker.exec.threads.*#worker.exec.threads=${workerExecThreads}#g" conf/worker.properties
sed -i ${txt} "s#worker.heartbeat.interval.*#worker.heartbeat.interval=${workerHeartbeatInterval}#g" conf/worker.properties
sed -i ${txt} "s#worker.fetch.task.num.*#worker.fetch.task.num=${workerFetchTaskNum}#g" conf/worker.properties
sed -i ${txt} "s#worker.reserved.memory.*#worker.reserved.memory=${workerReservedMemory}#g" conf/worker.properties
Q
qiaozhanwei 已提交
380
sed -i ${txt} "s#server.port.*#server.port=${workerPort}#g" conf/application-worker.properties
D
dailidong 已提交
381 382


Q
qiaozhanwei 已提交
383 384 385 386 387 388
sed -i ${txt} "s#server.port.*#server.port=${apiServerPort}#g" conf/application-api.properties
sed -i ${txt} "s#server.servlet.session.timeout.*#server.servlet.session.timeout=${apiServerSessionTimeout}#g" conf/application-api.properties
sed -i ${txt} "s#server.servlet.context-path.*#server.servlet.context-path=${apiServerContextPath}#g" conf/application-api.properties
sed -i ${txt} "s#spring.servlet.multipart.max-file-size.*#spring.servlet.multipart.max-file-size=${springMaxFileSize}#g" conf/application-api.properties
sed -i ${txt} "s#spring.servlet.multipart.max-request-size.*#spring.servlet.multipart.max-request-size=${springMaxRequestSize}#g" conf/application-api.properties
sed -i ${txt} "s#server.jetty.max-http-post-size.*#server.jetty.max-http-post-size=${apiMaxHttpPostSize}#g" conf/application-api.properties
D
dailidong 已提交
389 390 391 392 393 394


sed -i ${txt} "s#mail.protocol.*#mail.protocol=${mailProtocol}#g" conf/alert.properties
sed -i ${txt} "s#mail.server.host.*#mail.server.host=${mailServerHost}#g" conf/alert.properties
sed -i ${txt} "s#mail.server.port.*#mail.server.port=${mailServerPort}#g" conf/alert.properties
sed -i ${txt} "s#mail.sender.*#mail.sender=${mailSender}#g" conf/alert.properties
Q
qiaozhanwei 已提交
395
sed -i ${txt} "s#mail.user.*#mail.user=${mailUser}#g" conf/alert.properties
D
dailidong 已提交
396
sed -i ${txt} "s#mail.passwd.*#mail.passwd=${mailPassword}#g" conf/alert.properties
397
sed -i ${txt} "s#mail.smtp.starttls.enable.*#mail.smtp.starttls.enable=${starttlsEnable}#g" conf/alert.properties
Q
qiaozhanwei 已提交
398
sed -i ${txt} "s#mail.smtp.ssl.trust.*#mail.smtp.ssl.trust=${sslTrust}#g" conf/alert.properties
399
sed -i ${txt} "s#mail.smtp.ssl.enable.*#mail.smtp.ssl.enable=${sslEnable}#g" conf/alert.properties
D
dailidong 已提交
400
sed -i ${txt} "s#xls.file.path.*#xls.file.path=${xlsFilePath}#g" conf/alert.properties
L
lgcareer 已提交
401 402 403 404
sed -i ${txt} "s#enterprise.wechat.corp.id.*#enterprise.wechat.corp.id=${enterpriseWechatCorpId}#g" conf/alert.properties
sed -i ${txt} "s#enterprise.wechat.secret.*#enterprise.wechat.secret=${enterpriseWechatSecret}#g" conf/alert.properties
sed -i ${txt} "s#enterprise.wechat.agent.id.*#enterprise.wechat.agent.id=${enterpriseWechatAgentId}#g" conf/alert.properties
sed -i ${txt} "s#enterprise.wechat.users.*#enterprise.wechat.users=${enterpriseWechatUsers}#g" conf/alert.properties
Q
qiaozhanwei 已提交
405 406
sed -i ${txt} "s#server.port.*#server.port=${alertPort}#g" conf/application-alert.properties

D
dailidong 已提交
407 408 409 410 411 412 413 414 415 416 417


sed -i ${txt} "s#installPath.*#installPath=${installPath}#g" conf/config/install_config.conf
sed -i ${txt} "s#deployUser.*#deployUser=${deployUser}#g" conf/config/install_config.conf
sed -i ${txt} "s#ips.*#ips=${ips}#g" conf/config/install_config.conf


sed -i ${txt} "s#masters.*#masters=${masters}#g" conf/config/run_config.conf
sed -i ${txt} "s#workers.*#workers=${workers}#g" conf/config/run_config.conf
sed -i ${txt} "s#alertServer.*#alertServer=${alertServer}#g" conf/config/run_config.conf
sed -i ${txt} "s#apiServers.*#apiServers=${apiServers}#g" conf/config/run_config.conf
418 419


420 421
# 2,create directory
echo "2,create directory"
422 423

if [ ! -d $installPath ];then
D
dailidong 已提交
424 425
  sudo mkdir -p $installPath
  sudo chown -R $deployUser:$deployUser $installPath
426 427
fi

D
dailidong 已提交
428 429
hostsArr=(${ips//,/ })
for host in ${hostsArr[@]}
430 431
do

432
# create if programPath does not exist
D
dailidong 已提交
433 434
if ! ssh $host test -e $programPath; then
  ssh $host "sudo mkdir -p $programPath;sudo chown -R $deployUser:$deployUser $programPath"
435 436
fi

437
# create if downloadPath does not exist
438
if ! ssh $host test -e $downloadPath; then
D
dailidong 已提交
439
  ssh $host "sudo mkdir -p $downloadPath;sudo chown -R $deployUser:$deployUser $downloadPath"
440 441
fi

442
# create if execPath does not exist
443
if ! ssh $host test -e $execPath; then
D
dailidong 已提交
444
  ssh $host "sudo mkdir -p $execPath; sudo chown -R $deployUser:$deployUser $execPath"
445 446
fi

447
# create if xlsFilePath does not exist
448
if ! ssh $host test -e $xlsFilePath; then
D
dailidong 已提交
449
  ssh $host "sudo mkdir -p $xlsFilePath; sudo chown -R $deployUser:$deployUser $xlsFilePath"
450 451 452 453 454
fi

done


455 456 457
# 3,stop server
echo "3,stop server"
sh ${workDir}/script/stop-all.sh
458

459 460
# 4,delete zk node
echo "4,delete zk node"
461
sleep 1
462
python ${workDir}/script/del-zk-node.py $zkQuorum $zkRoot
463

464 465 466
# 5,scp resources
echo "5,scp resources"
sh ${workDir}/script/scp-hosts.sh
467 468
if [ $? -eq 0 ]
then
469
	echo 'scp copy completed'
470
else
471
	echo 'scp copy failed to exit'
472 473 474
	exit -1
fi

475 476 477
# 6,startup
echo "6,startup"
sh ${workDir}/script/start-all.sh
L
ligang 已提交
478

479
# 7,start monitoring self-starting script
L
ligang 已提交
480
monitor_pid=${workDir}/monitor_server.pid
L
ligang 已提交
481
if [ "true" = $monitorServerState ];then
L
ligang 已提交
482 483 484 485 486 487 488
        if [ -f $monitor_pid ]; then
                TARGET_PID=`cat $monitor_pid`
                if kill -0 $TARGET_PID > /dev/null 2>&1; then
                        echo "monitor server running as process ${TARGET_PID}.Stopping"
                        kill $TARGET_PID
                        sleep 5
                        if kill -0 $TARGET_PID > /dev/null 2>&1; then
L
ligang 已提交
489
                                echo "monitor server did not stop gracefully after 5 seconds: killing with kill -9"
L
ligang 已提交
490 491 492 493 494 495 496 497
                                kill -9 $TARGET_PID
                        fi
                else
                        echo "no monitor server to stop"
                fi
                echo "monitor server running as process ${TARGET_PID}.Stopped success"
                rm -f $monitor_pid
        fi
498
        nohup python -u ${workDir}/script/monitor-server.py $installPath $zkQuorum $zkMasters $zkWorkers > ${workDir}/monitor-server.log 2>&1 &
L
ligang 已提交
499 500 501
        echo $! > $monitor_pid
        echo "start monitor server success as process `cat $monitor_pid`"

502
fi