1.安装jdk
略
2.安装Mysql
略
3.安装nacos-server
#解压nacos-server-1.4.2.tar.gz
tar -zxf nacos-server-1.4.2.tar.gz
#修改配置文件application.properties
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://192.168.126.150:3306/nacos?
characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=okok
#复制并修改nacos/conf/cluster.conf
#添加你集群集群nacos的所有ip和端口
192.168.126.150:8849
192.168.126.150:8850
192.168.126.150:8851
#如果你机器内存很小请修改startup.sh 将xmx xms xmn内存该小
#JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -
XX:MaxMetaspaceSize=320m"
4.在mysql中创建nacos数据库
create database nacos;
use nacos;
source /opt/soft/nacos8849/conf/nacos-mysql.sql --执行脚本
#开启所有用户登录的授权
use mysql;
# 查看系统用户表
select user,host from user;
# 设置允许任意远程访问
update user set host = '%' where user = 'root';
# 刷新内存中的权限,就不用重启mysql服务了
flush PRIVILEGES;
5.启动nacos并检查注册中心集群状态
sh /opt/soft/nacos8849/bin/startup.sh
sh /opt/soft/nacos8850/bin/startup.sh
sh /opt/soft/nacos8851/bin/startup.sh
6.安装Nginx
#下载并解压nginx
#安装前置软件包、
yum instasll -y gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
#进入nginx文件夹
./configure
make
make install
# nginx启动(重启命令 nginx -s reload 停止命令 nginx -s stop)
cd /usr/local/nginx/sbin/
./nginx
#通过浏览器http://ip:80查询是否启动
7.Nginx配置负载均衡
upstream nacoscluster {
server 192.168.126.150:8849;
server 192.168.126.150:8850;
server 192.168.126.150:8851;
}
server {
listen 8847;
server_name localhost;
location /nacos/{
proxy_pass http://nacoscluster/nacos/;
}
}
8.重启Nginx 并测试nacos
nginx -s reload
http://ip:nginx监听端口(8847)/nacos
————————————————
版权声明:本文为CSDN博主「猫爷阿呆」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42433978/article/details/126535828
转载请注明:SuperIT » Nacos集群的安装