start.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 start_solr() {
  28. echo "Starting Solr..."
  29. /root/solr-$SOLR_VERSION/bin/solr start -cloud -s /root/logsearch_solr_index/data -verbose
  30. touch /var/log/ambari-logsearch-solr/solr.log
  31. }
  32. function start_logsearch() {
  33. echo "Upload configuration sets ..."
  34. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/audit_logs/conf -confname audit_logs
  35. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/hadoop_logs/conf -confname hadoop_logs
  36. $ZKCLI -zkhost localhost:9983 -cmd upconfig -confdir $LOGSEARCH_SERVER_PATH/solr_configsets/history/conf -confname history
  37. cp $LOGSEARCH_CONFIG_LOCATION/logsearch.properties /root/ambari/ambari-logsearch/ambari-logsearch-portal/target/package/classes/logsearch.properties
  38. cp $LOGSEARCH_CONFIG_LOCATION/log4j.xml /root/ambari/ambari-logsearch/ambari-logsearch-portal/target/package/classes/logsearch.properties
  39. $LOGSEARCH_SERVER_PATH/run.sh
  40. touch /var/log/ambari-logsearch-portal/logsearch-app.log
  41. }
  42. function start_logfeeder() {
  43. cp $LOGFEEDER_CONFIG_LOCATION/logfeeder.properties /root/ambari/ambari-logsearch/ambari-logsearch-logfeeder/target/package/classes/logfeeder.properties
  44. cp $LOGFEEDER_CONFIG_LOCATION/log4j.xml /root/ambari/ambari-logsearch/ambari-logsearch-logfeeder/target/package/classes/log4j.xml
  45. $LOGFEEDER_PATH/run.sh
  46. touch /var/log/ambari-logsearch-logfeeder/logsearch-logfeeder.log
  47. }
  48. function log() {
  49. component_log=${COMPONENT_LOG:-"logsearch"}
  50. case $component_log in
  51. "logfeeder")
  52. tail -f /var/log/ambari-logsearch-logfeeder/logsearch-logfeeder.log
  53. ;;
  54. "solr")
  55. tail -f /var/log/ambari-logsearch-solr/solr.log
  56. ;;
  57. *)
  58. tail -f /var/log/ambari-logsearch-portal/logsearch-app.log
  59. ;;
  60. esac
  61. }
  62. start_solr
  63. start_logsearch
  64. start_logfeeder
  65. log