CentOS环境下搭建Nacos(二进制、非mysql)

  Nacos中文官网:https://nacos.io/zh-cn/。

  我这里部署的Nacos版本是2.0.4,目前官网推荐版本为2.1.1。

(1).环境准备

  在Nacos2.X部署手册中,必备条件只有JDK需要1.8及其以上版本。

  JDK的安装我就不做展示了,各位看官参考CentOS7下搭建Tomcat服务器中的(3).JDK的安装和配置

(2).二进制安装Nacos

  将下载好的压缩包上传至服务器,解压配置并启动

[root@youxi1 ~]$ tar zxvf nacos-server-2.0.4.tar.gz -C /usr/local/
[root@youxi1 ~]$ cd /usr/local/nacos/bin/

//如果出现JAVA_HOME为空
[root@youxi1 bin]$ echo $JAVA_HOME
 
//或执行单机模式启动报如下错误
[root@youxi1 bin]$ sh startup.sh -m standalone
which: no javac in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/erlang/bin:/usr/local/rabbitmq/rabbitmq_server
-3.9.11/sbin:/home/admin/.local/bin:/home/admin/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! !!
//那么需要对启动脚本进行修改,在第33行添加如下内容
[root@youxi1 bin]$ vi startup.sh
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre

//保存退出后,再次执行启动命令,-m standalone表示为单机模式
[root@youxi1 bin]$ sh 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 -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 -Xms512m -Xmx5
12m -Xmn256m -Dnacos.standalone=true -Dnacos.member.list= -Xloggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDe
tails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M 
-Dloader.path=/usr/local/nacos/plugins/health,/usr/local/nacos/plugins/cmdb,/usr/local/nacos/plugins/selector -Dnacos.home=/usr
/local/nacos -jar /usr/local/nacos/target/nacos-server.jar --spring.config.additional-location=file:/usr/local/nacos/conf/ --lo
gging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with standalone
nacos is starting,you can check the /usr/local/nacos/logs/start.out

[root@youxi1 bin]$ ps -ef | grep nacos
root 24827 1 99 11:17 pts/0 00:00:34 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64/jre/bin/java -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 -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Dnacos.member.list= -Xloggc:/usr/local/nacos/logs/naco
s_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCL
ogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/usr/local/nacos/plugins/health,/usr/local/nacos/plugins/cmdb,/usr/local/nacos/p
lugins/selector -Dnacos.home=/usr/local/nacos -jar /usr/local/nacos/target/nacos-server.jar --spring.config.additional-location=
file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288 nacos.
nacos
admin 25143 21412 0 11:17 pts/0 00:00:00 grep --color=auto nacos

  注意:JAVA_HOME配置的是JDK的目录,我这里懒得安装JDK了,所以用系统自带的OpenJDK代替了

  然后在浏览器中输入[IP地址]:8848/nacos,打开nacos网页,账号密码均为nacos。

 

posted @ 2023-06-14 13:28  苦逼运维  阅读(279)  评论(0编辑  收藏  举报