install.sh 17 KB

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