spring cloud alibaba之nacos

spring cloud nacos

  • 安装和启动nacos
# 解压nacos安装包
# tar -zvxf nacos-server-1.4.1.tar.gz

# nacos默认是以集群的模式启动,此处先用单机模式
# cd  /usr/local/mysoft/nacos/bin
# sh startup.sh -m standalone

# nacos 日志
# tail -f /usr/local/mysoft/nacos/log/nacos.log

# 本地连接,需关闭防火墙
- 查看防火墙状态:
# systemctl status firewalld.service
- 关闭防火墙:
# systemctl stop firewalld.service
- 关闭防火墙:
# systemctl start firewalld.service

spring cloud alibaba之nacos_第1张图片

修改nacos数据源为mysql
  • 在MySQL中新建shemal为nacos
  • 将nacos脚本执行,解压nacos包,在MySQL中执行脚本nacos-mysql.sql执行

spring cloud alibaba之nacos_第2张图片

  • 修改nacos数据源为mysql
# vim nacos/conf/application.properties

spring cloud alibaba之nacos_第3张图片

nacos 集群配置
  • 基于原来nacos目录复制三个,分别为nacos1,nacos2,nacos3
# cp -r nacos nacos1
# cp -r nacos nacos2
# cp -r nacos nacos3
  • 修改nacos端口 分别为8845,8846,8847
# vim nacos1/conf/application.properties ---8845
# vim nacos3/conf/application.properties ---8846
# vim nacos3/conf/application.properties ---8847
  • 重命名nacos集群配置文件,并将各节点配置进去
# mv nacos1/conf/cluster.conf.example nacos1/conf/cluster.conf
# mv nacos2/conf/cluster.conf.example nacos2/conf/cluster.conf
# mv nacos3/conf/cluster.conf.example nacos3/conf/cluster.conf

spring cloud alibaba之nacos_第4张图片

  • 启动nacos各个节点服务
# cd /usr/local/mysoft

# ./nacos1/bin/startup.sh
# ./nacos2/bin/startup.sh
# ./nacos3/bin/startup.sh

- 浏览器访问
192.168.126.66:8845/nacos
192.168.126.66:8846/nacos
192.168.126.66:8847/nacos
  • linux配置nginx
    • naginx下载
naginx下载地址:http://nginx.org/en/download.html

安装gcc的环境
# yum install gcc-c++

上传nginx包到linux进行解压
# cd /usr/local/mysoft
# tar -zvxf nginx-1.16.1.tar.gz
# mv nginx-1.16.1 nginx
  • nginx配置nacos集群反向代理地址
# 添加/修改如下配置
upstream nacos-server {
    server 192.168.110.66:8845;
    server 192.168.110.66:8846;
    server 192.168.110.66:8847;
}

location /nacos/ {
            proxy_pass http://nacos-server/nacos/
        }

你可能感兴趣的:(Spring,Cloud,Alibaba,spring,cloud)