环境介绍:
CentOS 7.5 Java 1.8 Tomcat 8.0.35
Nacos下载:
https://github.com/alibaba/nacos/releases
部署准备:
[root@localhost ~]# mkdir /root/nacos [root@localhost ~]# cd /root/nacos [root@localhost nacos]# wget https://github.com/alibaba/nacos/releases/download/1.2.1/nacos-server-1.2.1.tar.gz [root@localhost nacos]# ls nacos-server-1.2.1.tar.gz [root@localhost nacos]# tar -xvzf nacos-server-1.2.1.tar.gz [root@localhost nacos]# ls nacos nacos-server-1.2.1.tar.gz [root@localhost nacos]# mv nacos /usr/local/nacos
配置JAVA_HOME
[root@localhost ~]# which java //找到jdk位置 /usr/bin/java [root@localhost ~]# ll /usr/bin/java lrwxrwxrwx. 1 root root 22 2月 24 12:26 /usr/bin/java -> /etc/alternatives/java [root@localhost ~]# ll /etc/alternatives/java lrwxrwxrwx. 1 root root 73 2月 24 12:26 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java [root@localhost ~]# ll /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/ [root@centos7-2 nacos]# vi /etc/profile # 在最后增加 export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/ export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH [root@localhost ~]# source /etc/profile [root@localhost ~]# systemctl stop firewalld //停止防火墙
单机模式启动:
[root@localhost nacos]# bash bin/startup.sh -m standalone 或者: [root@localhost nacos]# sh bin/startup.sh -m standalone [root@localhost bin]# cat /usr/local/nacos/logs/start.out /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.242.b08 ... -server.max-http-header-size=524288 ,--. ,--.'| ,--,: : | Nacos 1.2.1 ,`--.'`| ' : ,---. Running in stand alone mode, All function modules | : : | | ' ,'\ .--.--. Port: 8848 : | \ | : ,--.--. ,---. / / | / / ' Pid: 3882 | : ' '; | / \ / \. ; ,. :| : /`./ Console: http://xxxxxxx:8848/nacos/index.html ' ' ;. ;.--. .-. | / / '' | |: :| : ;_ | | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io ' : | ; .' ," .--.; |' ; :__| : | `----. \ | | '`--' / / ,. |' | '.'|\ \ / / /`--' / ' : | ; : .' \ : : `----' '--'. / ; |.' | , .-./\ \ / `--'---' '---' `--`---' `----' 2020-04-14 01:03:32,993 INFO Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$364be3d9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
访问测试:
上面启动成功我们能看到Console地址是:http://xxxxxxx:8848/nacos/index.html,访问的时候注意防火墙配置。
总结:
在部署nacos服务的时候,注意一定要在/etc/profile中配置JAVA_HOME,配置后记得source,否则启动nacos服务会失败。还有防火墙配置也要注意,一定要开放8848端口。
报错解决:
Nacos启动报错解决:which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
https://blog.csdn.net/qq_44895681/article/details/105515025