start.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License
  16. AMBARI_PATH=/root/ambari
  17. LOGSEARCH_SERVER_PATH=$AMBARI_PATH/ambari-logsearch/ambari-logsearch-portal/target/package
  18. LOGFEEDER_PATH=$AMBARI_PATH/ambari-logsearch/ambari-logsearch-logfeeder/target/package
  19. SOLR_LOCATION=/root/solr-$SOLR_VERSION.tgz
  20. SOLR_SERVER_LOCATION=/root/solr-$SOLR_VERSION
  21. ZKCLI=$SOLR_SERVER_LOCATION/server/scripts/cloud-scripts/zkcli.sh
  22. command="$1"
  23. function build_all() {
  24. echo "build all"
  25. cd $AMBARI_PATH/ambari-logsearch && mvn clean package -DskipTests && mvn -pl ambari-logsearch-logfeeder clean package -DskipTests
  26. }
  27. function create_config() {
  28. mkdir /root/config
  29. mkdir /root/config/solr
  30. cp /root/test-config/solr/log4j.properties /root/config/solr/
  31. cp /root/test-config/solr/zoo.cfg /root/config/solr/
  32. cp /root/test-config/solr/solr.xml /root/config/solr/
  33. if [ $LOGSEARCH_SOLR_SSL_ENABLED == 'true' ]
  34. then
  35. cp /root/test-config/solr/solr-env-ssl.sh /root/config/solr/solr-env.sh
  36. else
  37. cp /root/test-config/solr/solr-env.sh /root/config/solr/solr-env.sh
  38. fi
  39. mkdir /root/config/logfeeder
  40. cp -r /root/test-config/logfeeder/* /root/config/logfeeder/
  41. mkdir /root/config/logsearch
  42. cp /root/test-config/logsearch/log4j.xml /root/config/logsearch/
  43. cp /root/test-config/logsearch/logsearch-env.sh /root/config/logsearch/
  44. if [ $LOGSEARCH_HTTPS_ENABLED == 'true' ]
  45. then
  46. cp /root/test-config/logsearch/logsearch-https.properties /root/config/logsearch/logsearch.properties
  47. else
  48. cp /root/test-config/logsearch/logsearch.properties /root/config/logsearch/logsearch.properties
  49. fi
  50. chmod -R 777 /root/config
  51. }
  52. function generate_keys() {
  53. IP=`hostname --ip-address`
  54. echo "generating stores for IP: $IP"
  55. mkdir /root/config/ssl
  56. keytool -genkeypair -alias logsearch -keyalg RSA -keysize 2048 -keypass bigdata -storepass bigdata -validity 9999 -keystore /root/config/ssl/logsearch.keyStore.jks -ext SAN=DNS:localhost,IP:127.0.0.1,IP:$IP -dname "CN=Common Name, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country" -rfc
  57. cp /root/config/ssl/logsearch.keyStore.jks /root/config/ssl/logsearch.trustStore.jks
  58. }
  59. function start_solr() {
  60. echo "Starting Solr..."
  61. /root/solr-$SOLR_VERSION/bin/solr start -cloud -s /root/logsearch_solr_index/data -verbose
  62. touch /var/log/ambari-logsearch-solr/solr.log
  63. if [ $LOGSEARCH_SOLR_SSL_ENABLED == 'true' ]
  64. then
  65. echo "Setting urlScheme as https and restarting solr..."
  66. $ZKCLI -zkhost localhost:9983 -cmd clusterprop -name urlScheme -val https
  67. /root/solr-$SOLR_VERSION/bin/solr stop
  68. /root/solr-$SOLR_VERSION/bin/solr start -cloud -s /root/logsearch_solr_index/data -verbose
  69. fi
  70. }
  71. function start_logsearch() {
  72. echo "Upload configuration sets ..."
  73. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/audit_logs/conf -confname audit_logs
  74. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/hadoop_logs/conf -confname hadoop_logs
  75. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/history/conf -confname history
  76. $LOGSEARCH_SERVER_PATH/run.sh
  77. touch /var/log/ambari-logsearch-portal/logsearch-app.log
  78. }
  79. function start_logfeeder() {
  80. $LOGFEEDER_PATH/run.sh
  81. touch /var/log/ambari-logsearch-logfeeder/logsearch-logfeeder.log
  82. }
  83. function log() {
  84. component_log=${COMPONENT_LOG:-"logsearch"}
  85. case $component_log in
  86. "logfeeder")
  87. tail -f /var/log/ambari-logsearch-logfeeder/logsearch-logfeeder.log
  88. ;;
  89. "solr")
  90. tail -f /var/log/ambari-logsearch-solr/solr.log
  91. ;;
  92. *)
  93. tail -f /var/log/ambari-logsearch-portal/logsearch-app.log
  94. ;;
  95. esac
  96. }
  97. create_config
  98. generate_keys
  99. start_solr
  100. start_logsearch
  101. start_logfeeder
  102. log