nacos启动报错

在linux中启动nacos报错:

 

 

后查询资料,发现nacos默认是以集群方式启动的,所以需要把启动文件中的 cluster修改为standalone;

  1 #!/bin/sh
  2 
  3 # Copyright 1999-2018 Alibaba Group Holding Ltd.
  4 # Licensed under the Apache License, Version 2.0 (the "License");
  5 # you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 
  8 #      http://www.apache.org/licenses/LICENSE-2.0
  9 #
 10 # Unless required by applicable law or agreed to in writing, software
 11 # distributed under the License is distributed on an "AS IS" BASIS,
 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13 # See the License for the specific language governing permissions and
 14 # limitations under the License.
 15 
 16 cygwin=false
 17 darwin=false
 18 os400=false
 19 case "`uname`" in
 20 CYGWIN*) cygwin=true;;
 21 Darwin*) darwin=true;;
 22 OS400*) os400=true;;
 23 esac
 24 error_exit ()
 25 {
 26     echo "ERROR: $1 !!"
 27     exit 1
 28 }
 29 [ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
 30 [ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
 31 [ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/opt/taobao/java
 32 [ ! -e "$JAVA_HOME/bin/java" ] && unset JAVA_HOME
 33 
 34 if [ -z "$JAVA_HOME" ]; then
 35   if $darwin; then
 36 
 37     if [ -x '/usr/libexec/java_home' ] ; then
 38       export JAVA_HOME=`/usr/libexec/java_home`
 39 
 40     elif [ -d "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
 41       export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home"
 42     fi
 43   else
 44     JAVA_PATH=`dirname $(readlink -f $(which javac))`
 45     if [ "x$JAVA_PATH" != "x" ]; then
 46       export JAVA_HOME=`dirname $JAVA_PATH 2>/dev/null`
 47     fi
 48   fi
 49   if [ -z "$JAVA_HOME" ]; then
 50         error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!"
 51   fi
 52 fi
 53 
 54 #注,此处设置了默认值是以及群模式启动,所以我就把此处改成了standalone,集群为cluster
 55 export SERVER="nacos-server"
 56 export MODE="standalone"
 57 export FUNCTION_MODE="all"
 58 while getopts ":m:f:s:" opt
 59 do
 60     case $opt in
 61         m)
 62             MODE=$OPTARG;;
 63         f)
 64             FUNCTION_MODE=$OPTARG;;
 65         s)
 66             SERVER=$OPTARG;;
 67         ?)
 68         echo "Unknown parameter"
 69         exit 1;;
 70     esac
 71 done
 72 
 73 export JAVA_HOME
 74 export JAVA="$JAVA_HOME/bin/java"
 75 export BASE_DIR=`cd $(dirname $0)/..; pwd`
 76 export DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/"
 77 export CUSTOM_SEARCH_LOCATIONS=${DEFAULT_SEARCH_LOCATIONS},file:${BASE_DIR}/conf/
 78 
 79 #===========================================================================================
 80 # JVM Configuration
 81 #===========================================================================================
 82 if [[ "${MODE}" == "standalone" ]]; then
 83     JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -Xmn256m"
 84     JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
 85 else
 86     JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
 87     JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof"
 88     JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
 89 
 90 fi
 91 
 92 if [[ "${FUNCTION_MODE}" == "config" ]]; then
 93     JAVA_OPT="${JAVA_OPT} -Dnacos.functionMode=config"
 94 elif [[ "${FUNCTION_MODE}" == "naming" ]]; then
 95     JAVA_OPT="${JAVA_OPT} -Dnacos.functionMode=naming"
 96 fi
 97 
 98 
 99 JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
100 if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then
101   JAVA_OPT="${JAVA_OPT} -cp .:${BASE_DIR}/plugins/cmdb/*.jar:${BASE_DIR}/plugins/mysql/*.jar"
102   JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400"
103 else
104   JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/cmdb:${BASE_DIR}/plugins/mysql"
105   JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M"
106 fi
107 
108 JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
109 JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
110 JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
111 JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}"
112 JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml"
113 JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288"
114 
115 if [ ! -d "${BASE_DIR}/logs" ]; then
116   mkdir ${BASE_DIR}/logs
117 fi
118 
119 echo "$JAVA ${JAVA_OPT}"
120 
121 if [[ "${MODE}" == "standalone" ]]; then
122     echo "nacos is starting with standalone"
123 else
124     echo "nacos is starting with cluster"
125 fi
126 
127 # check the start.out log output file
128 if [ ! -f "${BASE_DIR}/logs/start.out" ]; then
129   touch "${BASE_DIR}/logs/start.out"
130 fi
131 # start
132 echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 &
133 nohup $JAVA ${JAVA_OPT} nacos.nacos >> ${BASE_DIR}/logs/start.out 2>&1 &
134 echo "nacos is starting,you can check the ${BASE_DIR}/logs/start.out"

 

启动命令为:

bash startup.sh -m standalone

官方提供的启动命令为

sh startup.sh -m standalone

至于启动命令的bash和sh的区别,待了解




posted @ 2020-09-25 11:30  记录学习之路  阅读(4697)  评论(0编辑  收藏  举报