install.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. #!/bin/sh
  2. workDir=`dirname $0`
  3. workDir=`cd ${workDir};pwd`
  4. #To be compatible with MacOS and Linux
  5. txt=""
  6. if [[ "$OSTYPE" == "darwin"* ]]; then
  7. # Mac OSX
  8. txt="''"
  9. elif [[ "$OSTYPE" == "linux-gnu" ]]; then
  10. # linux
  11. txt=""
  12. elif [[ "$OSTYPE" == "cygwin" ]]; then
  13. # POSIX compatibility layer and Linux environment emulation for Windows
  14. echo "DolphinScheduler not support Windows operating system"
  15. exit 1
  16. elif [[ "$OSTYPE" == "msys" ]]; then
  17. # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
  18. echo "DolphinScheduler not support Windows operating system"
  19. exit 1
  20. elif [[ "$OSTYPE" == "win32" ]]; then
  21. echo "DolphinScheduler not support Windows operating system"
  22. exit 1
  23. elif [[ "$OSTYPE" == "freebsd"* ]]; then
  24. # ...
  25. txt=""
  26. else
  27. # Unknown.
  28. echo "Operating system unknown, please tell us(submit issue) for better service"
  29. exit 1
  30. fi
  31. source ${workDir}/conf/config/run_config.conf
  32. source ${workDir}/conf/config/install_config.conf
  33. # for example mysql or postgresql ...
  34. dbtype="mysql"
  35. # db config
  36. # db address and port
  37. dbhost="192.168.xx.xx:3306"
  38. # mysql database
  39. dbname="dolphinscheduler"
  40. # mysql username
  41. username="xx"
  42. # mysql passwprd
  43. # Note: if there are special characters, please use the \ transfer character to transfer
  44. passowrd="xx"
  45. # conf/config/install_config.conf config
  46. # Note: the installation path is not the same as the current path (pwd)
  47. installPath="/data1_1T/dolphinscheduler"
  48. # deployment user
  49. # 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
  50. deployUser="dolphinscheduler"
  51. # zk cluster
  52. zkQuorum="192.168.xx.xx:2181,192.168.xx.xx:2181,192.168.xx.xx:2181"
  53. # install hosts
  54. # Note: install the scheduled hostname list. If it is pseudo-distributed, just write a pseudo-distributed hostname
  55. ips="ark0,ark1,ark2,ark3,ark4"
  56. # conf/config/run_config.conf config
  57. # run master machine
  58. # Note: list of hosts hostname for deploying master
  59. masters="ark0,ark1"
  60. # run worker machine
  61. # note: list of machine hostnames for deploying workers
  62. workers="ark2,ark3,ark4"
  63. # run alert machine
  64. # note: list of machine hostnames for deploying alert server
  65. alertServer="ark3"
  66. # run api machine
  67. # note: list of machine hostnames for deploying api server
  68. apiServers="ark1"
  69. # alert config
  70. # mail protocol
  71. mailProtocol="SMTP"
  72. # mail server host
  73. mailServerHost="smtp.exmail.qq.com"
  74. # mail server port
  75. mailServerPort="25"
  76. # sender
  77. mailSender="xxxxxxxxxx"
  78. # user
  79. mailUser="xxxxxxxxxx"
  80. # sender password
  81. mailPassword="xxxxxxxxxx"
  82. # TLS mail protocol support
  83. starttlsEnable="false"
  84. sslTrust="xxxxxxxxxx"
  85. # SSL mail protocol support
  86. # note: The SSL protocol is enabled by default.
  87. # only one of TLS and SSL can be in the true state.
  88. sslEnable="true"
  89. # download excel path
  90. xlsFilePath="/tmp/xls"
  91. # Enterprise WeChat Enterprise ID Configuration
  92. enterpriseWechatCorpId="xxxxxxxxxx"
  93. # Enterprise WeChat application Secret configuration
  94. enterpriseWechatSecret="xxxxxxxxxx"
  95. # Enterprise WeChat Application AgentId Configuration
  96. enterpriseWechatAgentId="xxxxxxxxxx"
  97. # Enterprise WeChat user configuration, multiple users to , split
  98. enterpriseWechatUsers="xxxxx,xxxxx"
  99. # alert port
  100. alertPort=7789
  101. # whether to start monitoring self-starting scripts
  102. monitorServerState="false"
  103. # resource Center upload and select storage method:HDFS,S3,NONE
  104. resUploadStartupType="NONE"
  105. # if resUploadStartupType is HDFS,defaultFS write namenode address,HA you need to put core-site.xml and hdfs-site.xml in the conf directory.
  106. # if S3,write S3 address,HA,for example :s3a://dolphinscheduler,
  107. # Note,s3 be sure to create the root directory /dolphinscheduler
  108. defaultFS="hdfs://mycluster:8020"
  109. # if S3 is configured, the following configuration is required.
  110. s3Endpoint="http://192.168.xx.xx:9010"
  111. s3AccessKey="xxxxxxxxxx"
  112. s3SecretKey="xxxxxxxxxx"
  113. # resourcemanager HA configuration, if it is a single resourcemanager, here is yarnHaIps=""
  114. yarnHaIps="192.168.xx.xx,192.168.xx.xx"
  115. # if it is a single resourcemanager, you only need to configure one host name. If it is resourcemanager HA, the default configuration is fine.
  116. singleYarnIp="ark1"
  117. # hdfs root path, the owner of the root path must be the deployment user.
  118. # versions prior to 1.1.0 do not automatically create the hdfs root directory, you need to create it yourself.
  119. hdfsPath="/dolphinscheduler"
  120. # have users who create directory permissions under hdfs root path /
  121. # Note: if kerberos is enabled, hdfsRootUser="" can be used directly.
  122. hdfsRootUser="hdfs"
  123. # common config
  124. # Program root path
  125. programPath="/tmp/dolphinscheduler"
  126. # download path
  127. downloadPath="/tmp/dolphinscheduler/download"
  128. # task execute path
  129. execPath="/tmp/dolphinscheduler/exec"
  130. # SHELL environmental variable path
  131. shellEnvPath="$installPath/conf/env/.dolphinscheduler_env.sh"
  132. # suffix of the resource file
  133. resSuffixs="txt,log,sh,conf,cfg,py,java,sql,hql,xml"
  134. # development status, if true, for the SHELL script, you can view the encapsulated SHELL script in the execPath directory.
  135. # If it is false, execute the direct delete
  136. devState="true"
  137. # kerberos config
  138. # kerberos whether to start
  139. kerberosStartUp="false"
  140. # kdc krb5 config file path
  141. krb5ConfPath="$installPath/conf/krb5.conf"
  142. # keytab username
  143. keytabUserName="hdfs-mycluster@ESZ.COM"
  144. # username keytab path
  145. keytabPath="$installPath/conf/hdfs.headless.keytab"
  146. # zk config
  147. # zk root directory
  148. zkRoot="/dolphinscheduler"
  149. # used to record the zk directory of the hanging machine
  150. zkDeadServers="$zkRoot/dead-servers"
  151. # masters directory
  152. zkMasters="$zkRoot/masters"
  153. # workers directory
  154. zkWorkers="$zkRoot/workers"
  155. # zk master distributed lock
  156. mastersLock="$zkRoot/lock/masters"
  157. # zk worker distributed lock
  158. workersLock="$zkRoot/lock/workers"
  159. # zk master fault-tolerant distributed lock
  160. mastersFailover="$zkRoot/lock/failover/masters"
  161. # zk worker fault-tolerant distributed lock
  162. workersFailover="$zkRoot/lock/failover/workers"
  163. # zk master start fault tolerant distributed lock
  164. mastersStartupFailover="$zkRoot/lock/failover/startup-masters"
  165. # zk session timeout
  166. zkSessionTimeout="300"
  167. # zk connection timeout
  168. zkConnectionTimeout="300"
  169. # zk retry interval
  170. zkRetrySleep="100"
  171. # zk retry maximum number of times
  172. zkRetryMaxtime="5"
  173. # master config
  174. # master execution thread maximum number, maximum parallelism of process instance
  175. masterExecThreads="100"
  176. # the maximum number of master task execution threads, the maximum degree of parallelism for each process instance
  177. masterExecTaskNum="20"
  178. # master heartbeat interval
  179. masterHeartbeatInterval="10"
  180. # master task submission retries
  181. masterTaskCommitRetryTimes="5"
  182. # master task submission retry interval
  183. masterTaskCommitInterval="100"
  184. # master maximum cpu average load, used to determine whether the master has execution capability
  185. masterMaxCpuLoadAvg="10"
  186. # master reserve memory to determine if the master has execution capability
  187. masterReservedMemory="1"
  188. # master port
  189. masterPort=5566
  190. # worker config
  191. # worker execution thread
  192. workerExecThreads="100"
  193. # worker heartbeat interval
  194. workerHeartbeatInterval="10"
  195. # worker number of fetch tasks
  196. workerFetchTaskNum="3"
  197. # worker reserve memory to determine if the master has execution capability
  198. workerReservedMemory="1"
  199. # master port
  200. workerPort=7788
  201. # api config
  202. # api server port
  203. apiServerPort="12345"
  204. # api session timeout
  205. apiServerSessionTimeout="7200"
  206. # api server context path
  207. apiServerContextPath="/dolphinscheduler/"
  208. # spring max file size
  209. springMaxFileSize="1024MB"
  210. # spring max request size
  211. springMaxRequestSize="1024MB"
  212. # api max http post size
  213. apiMaxHttpPostSize="5000000"
  214. # 1,replace file
  215. echo "1,replace file"
  216. if [ $dbtype == "mysql" ];then
  217. sed -i ${txt} "s#spring.datasource.url.*#spring.datasource.url=jdbc:mysql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/application.properties
  218. sed -i ${txt} "s#spring.datasource.username.*#spring.datasource.username=${username}#g" conf/application.properties
  219. sed -i ${txt} "s#spring.datasource.password.*#spring.datasource.password=${passowrd}#g" conf/application.properties
  220. sed -i ${txt} "s#spring.datasource.driver-class-name.*#spring.datasource.driver-class-name=com.mysql.jdbc.Driver#g" conf/application.properties
  221. 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
  222. sed -i ${txt} "s#org.quartz.dataSource.myDs.user.*#org.quartz.dataSource.myDs.user=${username}#g" conf/quartz.properties
  223. sed -i ${txt} "s#org.quartz.dataSource.myDs.password.*#org.quartz.dataSource.myDs.password=${passowrd}#g" conf/quartz.properties
  224. sed -i ${txt} "s#org.quartz.dataSource.myDs.driver.*#org.quartz.dataSource.myDs.driver=com.mysql.jdbc.Driver#g" conf/quartz.properties
  225. fi
  226. if [ $dbtype == "postgresql" ];then
  227. sed -i ${txt} "s#spring.datasource.url.*#spring.datasource.url=jdbc:postgresql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/application.properties
  228. sed -i ${txt} "s#spring.datasource.username.*#spring.datasource.username=${username}#g" conf/application.properties
  229. sed -i ${txt} "s#spring.datasource.password.*#spring.datasource.password=${passowrd}#g" conf/application.properties
  230. sed -i ${txt} "s#spring.datasource.driver-class-name.*#spring.datasource.driver-class-name=org.postgresql.Driver#g" conf/application.properties
  231. sed -i ${txt} "s#org.quartz.dataSource.myDs.URL.*#org.quartz.dataSource.myDs.URL=jdbc:postgresql://${dbhost}/${dbname}?characterEncoding=UTF-8#g" conf/quartz.properties
  232. sed -i ${txt} "s#org.quartz.dataSource.myDs.user.*#org.quartz.dataSource.myDs.user=${username}#g" conf/quartz.properties
  233. sed -i ${txt} "s#org.quartz.dataSource.myDs.password.*#org.quartz.dataSource.myDs.password=${passowrd}#g" conf/quartz.properties
  234. sed -i ${txt} "s#org.quartz.dataSource.myDs.driver.*#org.quartz.dataSource.myDs.driver=org.postgresql.Driver#g" conf/quartz.properties
  235. sed -i ${txt} "s#org.quartz.jobStore.driverDelegateClass.*#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate#g" conf/quartz.properties
  236. fi
  237. sed -i ${txt} "s#fs.defaultFS.*#fs.defaultFS=${defaultFS}#g" conf/common/hadoop/hadoop.properties
  238. sed -i ${txt} "s#fs.s3a.endpoint.*#fs.s3a.endpoint=${s3Endpoint}#g" conf/common/hadoop/hadoop.properties
  239. sed -i ${txt} "s#fs.s3a.access.key.*#fs.s3a.access.key=${s3AccessKey}#g" conf/common/hadoop/hadoop.properties
  240. sed -i ${txt} "s#fs.s3a.secret.key.*#fs.s3a.secret.key=${s3SecretKey}#g" conf/common/hadoop/hadoop.properties
  241. sed -i ${txt} "s#yarn.resourcemanager.ha.rm.ids.*#yarn.resourcemanager.ha.rm.ids=${yarnHaIps}#g" conf/common/hadoop/hadoop.properties
  242. 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
  243. sed -i ${txt} "s#data.basedir.path.*#data.basedir.path=${programPath}#g" conf/common/common.properties
  244. sed -i ${txt} "s#data.download.basedir.path.*#data.download.basedir.path=${downloadPath}#g" conf/common/common.properties
  245. sed -i ${txt} "s#process.exec.basepath.*#process.exec.basepath=${execPath}#g" conf/common/common.properties
  246. sed -i ${txt} "s#hdfs.root.user.*#hdfs.root.user=${hdfsRootUser}#g" conf/common/common.properties
  247. sed -i ${txt} "s#data.store2hdfs.basepath.*#data.store2hdfs.basepath=${hdfsPath}#g" conf/common/common.properties
  248. sed -i ${txt} "s#res.upload.startup.type.*#res.upload.startup.type=${resUploadStartupType}#g" conf/common/common.properties
  249. sed -i ${txt} "s#dolphinscheduler.env.path.*#dolphinscheduler.env.path=${shellEnvPath}#g" conf/common/common.properties
  250. sed -i ${txt} "s#resource.view.suffixs.*#resource.view.suffixs=${resSuffixs}#g" conf/common/common.properties
  251. sed -i ${txt} "s#development.state.*#development.state=${devState}#g" conf/common/common.properties
  252. sed -i ${txt} "s#hadoop.security.authentication.startup.state.*#hadoop.security.authentication.startup.state=${kerberosStartUp}#g" conf/common/common.properties
  253. sed -i ${txt} "s#java.security.krb5.conf.path.*#java.security.krb5.conf.path=${krb5ConfPath}#g" conf/common/common.properties
  254. sed -i ${txt} "s#login.user.keytab.username.*#login.user.keytab.username=${keytabUserName}#g" conf/common/common.properties
  255. sed -i ${txt} "s#login.user.keytab.path.*#login.user.keytab.path=${keytabPath}#g" conf/common/common.properties
  256. sed -i ${txt} "s#zookeeper.quorum.*#zookeeper.quorum=${zkQuorum}#g" conf/zookeeper.properties
  257. sed -i ${txt} "s#zookeeper.dolphinscheduler.root.*#zookeeper.dolphinscheduler.root=${zkRoot}#g" conf/zookeeper.properties
  258. sed -i ${txt} "s#zookeeper.dolphinscheduler.dead.servers.*#zookeeper.dolphinscheduler.dead.servers=${zkDeadServers}#g" conf/zookeeper.properties
  259. sed -i ${txt} "s#zookeeper.dolphinscheduler.masters.*#zookeeper.dolphinscheduler.masters=${zkMasters}#g" conf/zookeeper.properties
  260. sed -i ${txt} "s#zookeeper.dolphinscheduler.workers.*#zookeeper.dolphinscheduler.workers=${zkWorkers}#g" conf/zookeeper.properties
  261. sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.masters.*#zookeeper.dolphinscheduler.lock.masters=${mastersLock}#g" conf/zookeeper.properties
  262. sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.workers.*#zookeeper.dolphinscheduler.lock.workers=${workersLock}#g" conf/zookeeper.properties
  263. sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.masters.*#zookeeper.dolphinscheduler.lock.failover.masters=${mastersFailover}#g" conf/zookeeper.properties
  264. sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.workers.*#zookeeper.dolphinscheduler.lock.failover.workers=${workersFailover}#g" conf/zookeeper.properties
  265. sed -i ${txt} "s#zookeeper.dolphinscheduler.lock.failover.startup.masters.*#zookeeper.dolphinscheduler.lock.failover.startup.masters=${mastersStartupFailover}#g" conf/zookeeper.properties
  266. sed -i ${txt} "s#zookeeper.session.timeout.*#zookeeper.session.timeout=${zkSessionTimeout}#g" conf/zookeeper.properties
  267. sed -i ${txt} "s#zookeeper.connection.timeout.*#zookeeper.connection.timeout=${zkConnectionTimeout}#g" conf/zookeeper.properties
  268. sed -i ${txt} "s#zookeeper.retry.sleep.*#zookeeper.retry.sleep=${zkRetrySleep}#g" conf/zookeeper.properties
  269. sed -i ${txt} "s#zookeeper.retry.maxtime.*#zookeeper.retry.maxtime=${zkRetryMaxtime}#g" conf/zookeeper.properties
  270. sed -i ${txt} "s#master.exec.threads.*#master.exec.threads=${masterExecThreads}#g" conf/master.properties
  271. sed -i ${txt} "s#master.exec.task.number.*#master.exec.task.number=${masterExecTaskNum}#g" conf/master.properties
  272. sed -i ${txt} "s#master.heartbeat.interval.*#master.heartbeat.interval=${masterHeartbeatInterval}#g" conf/master.properties
  273. sed -i ${txt} "s#master.task.commit.retryTimes.*#master.task.commit.retryTimes=${masterTaskCommitRetryTimes}#g" conf/master.properties
  274. sed -i ${txt} "s#master.task.commit.interval.*#master.task.commit.interval=${masterTaskCommitInterval}#g" conf/master.properties
  275. sed -i ${txt} "s#master.reserved.memory.*#master.reserved.memory=${masterReservedMemory}#g" conf/master.properties
  276. sed -i ${txt} "s#server.port.*#server.port=${masterPort}#g" conf/application-master.properties
  277. sed -i ${txt} "s#worker.exec.threads.*#worker.exec.threads=${workerExecThreads}#g" conf/worker.properties
  278. sed -i ${txt} "s#worker.heartbeat.interval.*#worker.heartbeat.interval=${workerHeartbeatInterval}#g" conf/worker.properties
  279. sed -i ${txt} "s#worker.fetch.task.num.*#worker.fetch.task.num=${workerFetchTaskNum}#g" conf/worker.properties
  280. sed -i ${txt} "s#worker.reserved.memory.*#worker.reserved.memory=${workerReservedMemory}#g" conf/worker.properties
  281. sed -i ${txt} "s#server.port.*#server.port=${workerPort}#g" conf/application-worker.properties
  282. sed -i ${txt} "s#server.port.*#server.port=${apiServerPort}#g" conf/application-api.properties
  283. sed -i ${txt} "s#server.servlet.session.timeout.*#server.servlet.session.timeout=${apiServerSessionTimeout}#g" conf/application-api.properties
  284. sed -i ${txt} "s#server.servlet.context-path.*#server.servlet.context-path=${apiServerContextPath}#g" conf/application-api.properties
  285. sed -i ${txt} "s#spring.servlet.multipart.max-file-size.*#spring.servlet.multipart.max-file-size=${springMaxFileSize}#g" conf/application-api.properties
  286. sed -i ${txt} "s#spring.servlet.multipart.max-request-size.*#spring.servlet.multipart.max-request-size=${springMaxRequestSize}#g" conf/application-api.properties
  287. sed -i ${txt} "s#server.jetty.max-http-post-size.*#server.jetty.max-http-post-size=${apiMaxHttpPostSize}#g" conf/application-api.properties
  288. sed -i ${txt} "s#mail.protocol.*#mail.protocol=${mailProtocol}#g" conf/alert.properties
  289. sed -i ${txt} "s#mail.server.host.*#mail.server.host=${mailServerHost}#g" conf/alert.properties
  290. sed -i ${txt} "s#mail.server.port.*#mail.server.port=${mailServerPort}#g" conf/alert.properties
  291. sed -i ${txt} "s#mail.sender.*#mail.sender=${mailSender}#g" conf/alert.properties
  292. sed -i ${txt} "s#mail.user.*#mail.user=${mailUser}#g" conf/alert.properties
  293. sed -i ${txt} "s#mail.passwd.*#mail.passwd=${mailPassword}#g" conf/alert.properties
  294. sed -i ${txt} "s#mail.smtp.starttls.enable.*#mail.smtp.starttls.enable=${starttlsEnable}#g" conf/alert.properties
  295. sed -i ${txt} "s#mail.smtp.ssl.trust.*#mail.smtp.ssl.trust=${sslTrust}#g" conf/alert.properties
  296. sed -i ${txt} "s#mail.smtp.ssl.enable.*#mail.smtp.ssl.enable=${sslEnable}#g" conf/alert.properties
  297. sed -i ${txt} "s#xls.file.path.*#xls.file.path=${xlsFilePath}#g" conf/alert.properties
  298. sed -i ${txt} "s#enterprise.wechat.corp.id.*#enterprise.wechat.corp.id=${enterpriseWechatCorpId}#g" conf/alert.properties
  299. sed -i ${txt} "s#enterprise.wechat.secret.*#enterprise.wechat.secret=${enterpriseWechatSecret}#g" conf/alert.properties
  300. sed -i ${txt} "s#enterprise.wechat.agent.id.*#enterprise.wechat.agent.id=${enterpriseWechatAgentId}#g" conf/alert.properties
  301. sed -i ${txt} "s#enterprise.wechat.users.*#enterprise.wechat.users=${enterpriseWechatUsers}#g" conf/alert.properties
  302. sed -i ${txt} "s#installPath.*#installPath=${installPath}#g" conf/config/install_config.conf
  303. sed -i ${txt} "s#deployUser.*#deployUser=${deployUser}#g" conf/config/install_config.conf
  304. sed -i ${txt} "s#ips.*#ips=${ips}#g" conf/config/install_config.conf
  305. sed -i ${txt} "s#masters.*#masters=${masters}#g" conf/config/run_config.conf
  306. sed -i ${txt} "s#workers.*#workers=${workers}#g" conf/config/run_config.conf
  307. sed -i ${txt} "s#alertServer.*#alertServer=${alertServer}#g" conf/config/run_config.conf
  308. sed -i ${txt} "s#apiServers.*#apiServers=${apiServers}#g" conf/config/run_config.conf
  309. # 2,create directory
  310. echo "2,create directory"
  311. if [ ! -d $installPath ];then
  312. sudo mkdir -p $installPath
  313. sudo chown -R $deployUser:$deployUser $installPath
  314. fi
  315. hostsArr=(${ips//,/ })
  316. for host in ${hostsArr[@]}
  317. do
  318. # create if programPath does not exist
  319. if ! ssh $host test -e $programPath; then
  320. ssh $host "sudo mkdir -p $programPath;sudo chown -R $deployUser:$deployUser $programPath"
  321. fi
  322. # create if downloadPath does not exist
  323. if ! ssh $host test -e $downloadPath; then
  324. ssh $host "sudo mkdir -p $downloadPath;sudo chown -R $deployUser:$deployUser $downloadPath"
  325. fi
  326. # create if execPath does not exist
  327. if ! ssh $host test -e $execPath; then
  328. ssh $host "sudo mkdir -p $execPath; sudo chown -R $deployUser:$deployUser $execPath"
  329. fi
  330. # create if xlsFilePath does not exist
  331. if ! ssh $host test -e $xlsFilePath; then
  332. ssh $host "sudo mkdir -p $xlsFilePath; sudo chown -R $deployUser:$deployUser $xlsFilePath"
  333. fi
  334. done
  335. # 3,stop server
  336. echo "3,stop server"
  337. sh ${workDir}/script/stop-all.sh
  338. # 4,delete zk node
  339. echo "4,delete zk node"
  340. sleep 1
  341. python ${workDir}/script/del-zk-node.py $zkQuorum $zkRoot
  342. # 5,scp resources
  343. echo "5,scp resources"
  344. sh ${workDir}/script/scp-hosts.sh
  345. if [ $? -eq 0 ]
  346. then
  347. echo 'scp copy completed'
  348. else
  349. echo 'scp copy failed to exit'
  350. exit -1
  351. fi
  352. # 6,startup
  353. echo "6,startup"
  354. sh ${workDir}/script/start-all.sh
  355. # 7,start monitoring self-starting script
  356. monitor_pid=${workDir}/monitor_server.pid
  357. if [ "true" = $monitorServerState ];then
  358. if [ -f $monitor_pid ]; then
  359. TARGET_PID=`cat $monitor_pid`
  360. if kill -0 $TARGET_PID > /dev/null 2>&1; then
  361. echo "monitor server running as process ${TARGET_PID}.Stopping"
  362. kill $TARGET_PID
  363. sleep 5
  364. if kill -0 $TARGET_PID > /dev/null 2>&1; then
  365. echo "monitor server did not stop gracefully after 5 seconds: killing with kill -9"
  366. kill -9 $TARGET_PID
  367. fi
  368. else
  369. echo "no monitor server to stop"
  370. fi
  371. echo "monitor server running as process ${TARGET_PID}.Stopped success"
  372. rm -f $monitor_pid
  373. fi
  374. nohup python -u ${workDir}/script/monitor-server.py $installPath $zkQuorum $zkMasters $zkWorkers > ${workDir}/monitor-server.log 2>&1 &
  375. echo $! > $monitor_pid
  376. echo "start monitor server success as process `cat $monitor_pid`"
  377. fi