configureClusterAdvanced.sh 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. #!/bin/sh
  2. #/*
  3. # * Licensed to the Apache Software Foundation (ASF) under one
  4. # * or more contributor license agreements. See the NOTICE file
  5. # * distributed with this work for additional information
  6. # * regarding copyright ownership. The ASF licenses this file
  7. # * to you under the Apache License, Version 2.0 (the
  8. # * "License"); you may not use this file except in compliance
  9. # * with the License. You may obtain a copy of the License at
  10. # *
  11. # * http://www.apache.org/licenses/LICENSE-2.0
  12. # *
  13. # * Unless required by applicable law or agreed to in writing, software
  14. # * distributed under the License is distributed on an "AS IS" BASIS,
  15. # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # * See the License for the specific language governing permissions and
  17. # * limitations under the License.
  18. # */
  19. baseDir=`dirname ${0}`;
  20. source ${baseDir}/easyInstallerLib.sh;
  21. source ${baseDir}/dbLib.sh;
  22. source ${baseDir}/servicesLib.sh;
  23. ###########################
  24. ### FILE-SCOPED GLOBALS ###
  25. ###########################
  26. # TODO XXX Take this in from the UI in the future (and likely store it as a
  27. # marker on disk, to really be of any use).
  28. clusterName="MyHDPCluster";
  29. #############################
  30. ### FILE-SCOPED FUNCTIONS ###
  31. #############################
  32. function getServiceHost
  33. {
  34. local serviceHost="";
  35. local serviceName="${1}";
  36. if [ "x" != "x${serviceName}" ]
  37. then
  38. serviceHostFile=`fetchDbFileForCluster "${clusterName}" "${serviceName}"`;
  39. serviceHost=`getFirstWordFromFile "${serviceHostFile}"`;
  40. fi
  41. echo "${serviceHost}";
  42. }
  43. function generateServiceConfigChoiceXml
  44. {
  45. local serviceConfigChoiceXml="";
  46. local serviceHostFileName="${1}";
  47. local serviceConfigKey="${2}";
  48. if [ "x" != "x${serviceHostFileName}" ] && [ "x" != "x${serviceConfigKey}" ]
  49. then
  50. local serviceHostValue=`getServiceHost "${serviceHostFileName}"`;
  51. serviceConfigChoiceXml="<hudson.model.ChoiceParameterDefinition>\
  52. <name>${serviceConfigKey}</name>\
  53. <description></description>\
  54. <choices class=\\\"java.util.Arrays\\\$ArrayList\\\">\
  55. <a class=\\\"string-array\\\">\
  56. <string>${serviceHostValue}</string>\
  57. </a>\
  58. </choices>\
  59. </hudson.model.ChoiceParameterDefinition>";
  60. fi
  61. echo "${serviceConfigChoiceXml}";
  62. }
  63. function generateOptionalServicesConfigChoicesXml
  64. {
  65. local optionalServicesConfigChoicesXml="";
  66. local isHBaseInstalled="${1}";
  67. local isHCatalogInstalled="${2}";
  68. local isTempletonInstalled="${3}";
  69. local isOozieInstalled="${4}";
  70. if [ "xyes" == "x${isHBaseInstalled}" ]
  71. then
  72. hBaseConfigChoicesXml=`generateServiceConfigChoiceXml "hbasemaster" "HDPHBaseMasterHost"`;
  73. optionalServicesConfigChoicesXml="${optionalServicesConfigChoicesXml}${hBaseConfigChoicesXml}";
  74. fi
  75. if [ "xyes" == "x${isHCatalogInstalled}" ]
  76. then
  77. hCatalogConfigChoicesXml=`generateServiceConfigChoiceXml "hcatserver" "HDPHCatalogServerHost"`;
  78. optionalServicesConfigChoicesXml="${optionalServicesConfigChoicesXml}${hCatalogConfigChoicesXml}";
  79. fi
  80. if [ "xyes" == "x${isTempletonInstalled}" ]
  81. then
  82. templetonConfigChoicesXml=`generateServiceConfigChoiceXml "templetonnode" "HDPTempletonNodeHost"`;
  83. optionalServicesConfigChoicesXml="${optionalServicesConfigChoicesXml}${templetonConfigChoicesXml}";
  84. fi
  85. if [ "xyes" == "x${isOozieInstalled}" ]
  86. then
  87. oozieConfigChoicesXml=`generateServiceConfigChoiceXml "oozieserver" "HDPOozieServerHost"`;
  88. optionalServicesConfigChoicesXml="${optionalServicesConfigChoicesXml}${oozieConfigChoicesXml}";
  89. fi
  90. echo "${optionalServicesConfigChoicesXml}";
  91. }
  92. #############
  93. ### SETUP ###
  94. #############
  95. # XXX XXX RESUME FROM HERE
  96. ###checkpointedStageNumber=`fetchDbCookieForCluster "${clusterName}" "${CHECKPOINTED_STAGE_NUMBER_COOKIE_NAME}"`;
  97. ###
  98. ###currentStageName="1-HDP-Initialize-Cluster";
  99. ###currentStageNumber=`getStageNumberFromName "${currentStageName}"`;
  100. ###
  101. ###currentStageCanRun=`isStageTransitionAdmissable "${checkpointedStageNumber}" "${currentStageNumber}"`;
  102. ###
  103. ###if [ "${currentStageCanRun}" != "1" ]
  104. ###then
  105. ### echo "Inadmissable stage transition attempted - bailing out.";
  106. ### exit 1;
  107. ###fi
  108. # Create our per-build workspace - it's a shame Jenkins doesn't provide this for us.
  109. perBuildWorkspace=${WORKSPACE}/${BUILD_NUMBER};
  110. cmd="mkdir ${perBuildWorkspace}";
  111. echo "${cmd}";
  112. eval "${cmd}";
  113. ######################
  114. ### PRE-PROCESSING ###
  115. ######################
  116. # Do nothing.
  117. ######################
  118. ### THE MAIN EVENT ###
  119. ######################
  120. # Do nothing.
  121. #######################
  122. ### POST-PROCESSING ###
  123. #######################
  124. # Store the data we've gotten from the user into our DB.
  125. read -r -d '' gsClusterConf << EOConf
  126. s!@HDPHadoopHeapSize@!${HDPHadoopHeapSize}!g
  127. s!@HDPNameNodeHeapSize@!${HDPNameNodeHeapSize}!g
  128. s!@HDPFSInMemorySize@!${HDPFSInMemorySize}!g
  129. s!@HDPNameNodeOptNewSize@!${HDPNameNodeOptNewSize}!g
  130. s!@HDPDataNodeDuReserved@!${HDPDataNodeDuReserved}!g
  131. s!@HDPDataNodeHeapSize@!${HDPDataNodeHeapSize}!g
  132. s!@HDPJobTrackerOptNewSize@!${HDPJobTrackerOptNewSize}!g
  133. s!@HDPJobTrackerOptMaxNewSize@!${HDPJobTrackerOptMaxNewSize}!g
  134. s!@HDPJobTrackerHeapSize@!${HDPJobTrackerHeapSize}!g
  135. s!@HDPMapRedMapTasksMax@!${HDPMapRedMapTasksMax}!g
  136. s!@HDPMapRedReduceTasksMax@!${HDPMapRedReduceTasksMax}!g
  137. s!@HDPMapRedClusterMapMemoryMB@!${HDPMapRedClusterMapMemoryMB}!g
  138. s!@HDPMapRedClusterReduceMemoryMB@!${HDPMapRedClusterReduceMemoryMB}!g
  139. s!@HDPMapRedClusterMaxMapMemoryMB@!${HDPMapRedClusterMaxMapMemoryMB}!g
  140. s!@HDPMapRedClusterMaxReduceMemoryMB@!${HDPMapRedClusterMaxReduceMemoryMB}!g
  141. s!@HDPMapRedJobMapMemoryMB@!${HDPMapRedJobMapMemoryMB}!g
  142. s!@HDPMapRedJobReduceMemoryMB@!${HDPMapRedJobReduceMemoryMB}!g
  143. s!@HDPMapRedChildJavaOptsSize@!${HDPMapRedChildJavaOptsSize}!g
  144. s!@HDPIoSortMB@!${HDPIoSortMB}!g
  145. s!@HDPIoSortSpillPercent@!${HDPIoSortSpillPercent}!g
  146. s!@HDPMapReduceUserLogRetainHours@!${HDPMapReduceUserLogRetainHours}!g
  147. s!@HDPMaxTasksPerJob@!${HDPMaxTasksPerJob}!g
  148. s!@HDPDFSDataNodeFailedVolumeTolerated@!${HDPDFSDataNodeFailedVolumeTolerated}!g
  149. s!@HDPHBaseMasterHeapSize@!${HDPHBaseMasterHeapSize:-1024m}!g
  150. s!@HDPHBaseRegionServerHeapSize@!${HDPHBaseRegionServerHeapSize:-1024m}!g
  151. EOConf
  152. # The escaped quotes around ${gsClusterConf} are important because
  153. # we're passing in a multi-line blob as a string, so the command-line
  154. # invocation needs to have the blob quoted so storeDbConfForCluster can treat
  155. # it as a single string.
  156. cmd="storeDbConfForCluster ${clusterName} ${GSCLUSTER_PROPERTIES_CONF_NAME} \"${gsClusterConf}\"";
  157. echo "${cmd}";
  158. eval "${cmd}";
  159. # Fetch the next stage's configuration
  160. nextJobName="5-HDP-Deploy";
  161. nextJobConfigFile="${perBuildWorkspace}/${nextJobName}.config.xml";
  162. cmd="fetchJobConfigTemplate ${nextJobName} ${nextJobConfigFile}";
  163. echo "${cmd}";
  164. eval "${cmd}";
  165. # Modify this fetched config to take into account the output of all the jobs till now.
  166. isHBaseInstalled=`isServiceInstalledForCluster "${clusterName}" "HBase"`;
  167. isPigInstalled=`isServiceInstalledForCluster "${clusterName}" "Pig"`;
  168. isHCatalogInstalled=`isServiceInstalledForCluster "${clusterName}" "HCatalog"`;
  169. isTempletonInstalled=`isServiceInstalledForCluster "${clusterName}" "Templeton"`;
  170. isOozieInstalled=`isServiceInstalledForCluster "${clusterName}" "Oozie"`;
  171. isSqoopInstalled=`isServiceInstalledForCluster "${clusterName}" "Sqoop"`;
  172. nameNodeHost=`getServiceHost "namenode"`;
  173. secondaryNameNodeHost=`getServiceHost "snamenode"`;
  174. jobTrackerHost=`getServiceHost "jobtracker"`;
  175. gangliaCollectorHost=`getServiceHost "gangliaserver"`;
  176. nagiosServerHost=`getServiceHost "nagiosserver"`;
  177. optionalServicesConfigChoicesXml=`generateOptionalServicesConfigChoicesXml \
  178. "${isHBaseInstalled}" "${isHCatalogInstalled}" "${isTempletonInstalled}" "${isOozieInstalled}"`;
  179. cmd="sed -i.prev \
  180. -e \"s!@HDPInstallHBaseChoice@!${isHBaseInstalled}!g\" \
  181. -e \"s!@HDPInstallPigChoice@!${isPigInstalled}!g\" \
  182. -e \"s!@HDPInstallHCatalogChoice@!${isHCatalogInstalled}!g\" \
  183. -e \"s!@HDPInstallTempletonChoice@!${isTempletonInstalled}!g\" \
  184. -e \"s!@HDPInstallOozieChoice@!${isOozieInstalled}!g\" \
  185. -e \"s!@HDPInstallSqoopChoice@!${isSqoopInstalled}!g\" \
  186. -e \"s!@HDPNameNodeHostChoice@!${nameNodeHost}!g\" \
  187. -e \"s!@HDPSecondaryNameNodeHostChoice@!${secondaryNameNodeHost}!g\" \
  188. -e \"s!@HDPJobTrackerHostChoice@!${jobTrackerHost}!g\" \
  189. -e \"s!@HDPGangliaCollectorHostChoice@!${gangliaCollectorHost}!g\" \
  190. -e \"s!@HDPNagiosServerHostChoice@!${nagiosServerHost}!g\" \
  191. -e \"s!@HDPOptionalServicesConfigChoices@!${optionalServicesConfigChoicesXml}!g\" \
  192. ${nextJobConfigFile}";
  193. echo "${cmd}";
  194. eval "${cmd}";
  195. # "Pipe" the output of this job into the next one's configuration.
  196. cmd="curl -H \"Content-Type: text/xml\" -d @${nextJobConfigFile} ${JENKINS_URL}job/${nextJobName}/config.xml";
  197. echo "${cmd}";
  198. eval "${cmd}";
  199. # XXX TODO Advance the stage disk cookie.