安装Nacos1.4.1
Github地址:https://github.com/alibaba/nacos/releases
Nacos1.4.1版本下载地址:https://github.com/alibaba/nacos/releases/download/1.4.1/nacos-server-1.4.1.tar.gz
解压tar包
tar -zxvf nacos-server-1.4.1.tar.gz
启动服务
cd nacos/bin ./startup.sh -m standalone
这时候可能会报错,提示
which: no javac in (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64//bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64//jre/bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre//bin:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre//jre/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) readlink: missing operand Try 'readlink --help' for more information. dirname: missing operand Try 'dirname --help' for more information. ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! !!
大致原因是它找不到JAVA_HOME
变量或者是找到了这个变量但是没有发现java
命令
如果是tar包安装,检查下/etc/profile
文件是否正确
如果是通过yum安装的java,先检索下我们安装的java版本
rpm -qa|grep java javapackages-tools-3.4.1-11.el7.noarch tzdata-java-2022f-1.el7.noarch java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64 python-javapackages-3.4.1-11.el7.noarch java-1.8.0-openjdk-headless-1.8.0.352.b08-2.el7_9.x86_64
查看下java版本安装的位置
rpm -ql java-1.8.0-openjdk-headless-1.8.0.352.b08-2.el7_9.x86_64
注意下bin
目录下的java
命令在什么位置
我这里的是在/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/bin/java
所以我需要指定JAVA_HOME
的位置应该是在/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/
打开/etc/profile
文件在最后一行添加
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/
重新加载配置文件
source /etc/profile • 1
再次启动Nacos服务
./startup.sh -m standalone
再次报错
which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) readlink: missing operand Try 'readlink --help' for more information. dirname: missing operand Try 'dirname --help' for more information. ERROR: Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! !!
查看下startup.sh
文件,看下是从JAVA_HOME
的什么位置下找的java
命令
可以看出是直接从$JAVA_HOME/bin/
找的目录,而实际的java
命令是在$JAVA_HOME/jre/bin/
下重新编辑/etc/profile
文件
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/ 修改成 export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre 完整添加: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
重新加载配置文件
source /etc/profile • 1
再次启动Nacos服务,服务启动成功
./startup.sh -m standalone /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/bin/java -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Dnacos.member.list= -Djava.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/jre/lib/ext:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/lib/ext -Xloggc:/dwz/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/dwz/nacos/plugins/health,/dwz/nacos/plugins/cmdb -Dnacos.home=/dwz/nacos -jar /dwz/nacos/target/nacos-server.jar --spring.config.additional-location=file:/dwz/nacos/conf/ --logging.config=/dwz/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288 nacos is starting with standalone nacos is starting,you can check the /dwz/nacos/logs/start.out
通过ip:8848
就可以访问我们的nacos服务了,默认用户名密码nacos/nacos