install.sh 21 KB

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