Spring Cloud Alibaba: Nacos-集群搭建

一、安装nginx

1.1 下载nginx,保存路径为:/usr/local/software

cd /usr/local/software
wget http://nginx.org/download/nginx-1.19.6.tar.gz

在这里插入图片描述

1.2 解压安装包,得到解压目录

tar -xzvf nginx-1.19.6.tar.gz

在这里插入图片描述

1.3 进入解压目录

cd nginx-1.19.6

在这里插入图片描述

1.4 执行命令指定安装目录

./configure --prefix=/usr/local/nginx-1.19.6

在这里插入图片描述
如果出现错误:

  1. 错误为:./configure: error: the HTTP rewrite module requires the PCRE library.

    安装pcre-devel解决问题
    yum -y install pcre-devel

  2. 错误提示:./configure: error: the HTTP cache module requires md5 functions
    from OpenSSL library. You can either disable the module by using
    –without-http-cache option, or install the OpenSSL library into the system,
    or build the OpenSSL library statically from the source with nginx by using
    –with-http_ssl_module --with-openssl= options.

    解决办法:
    yum -y install openssl openssl-devel

1.5 接下来通过命令 make && make install 命令

在这里插入图片描述

1.6 进入安装位置修改配置

cd /usr/local/nginx­1.19.6
进入该目录下的配置目录conf

1.7 修改ng的conf文件

# ng配置nacos集群负载均衡 start
 upstream nacosCluster {
 	server 146.56.192.87:8848;
	server 146.56.192.87:8849;
	server 146.56.192.87:8850;
}

server {
 	listen 8847;
 	server_name 146.56.192.87;

 	location /nacos/ {
 		proxy_pass  http://nacosCluster/nacos/;
 		index  index.html index.htm index.jsp;
 	}
 }
# ng配置nacos集群负载均衡 end

以上,nginx已安装完成并配置好负载均衡。

1.8 启动nginx

在这里插入图片描述
测试访问:
在这里插入图片描述

二、初始化nacos数据库

创建一个数据库(需要自己创建一个数据库) 脚本的在 nacos/conf/nacos-mysql.sql
在这里插入图片描述

三、搭建Nacos集群

三个Nacos端口分别为8849 ,8850,8851
在这里插入图片描述

3.1 修改nacos8850/conf文件 application.properties

主要修改端口、打开mysql配置注解、配置mysql数据库连接的配置信息
在这里插入图片描述

3.2 修改nacos8850/conf文件 把原来的cluster.conf.example改为cluster.conf文件

文件内容为如下:

在这里插入图片描述

3.3 按照上面方法分表修改8848 8849两个nacos

3.4 分别启动这三个nacos

执行启动命令:

./bin/start.sh

启动成功的依据 查看日志,命令为:

tail -f logs/start.out

测试:

分别登陆地址:

  • http://${IP}:8849/nacos
  • http://${IP}:8850/nacos
  • http://${IP}:8851/nacos

NG测试

  • http://${IP}:8847/nacos/

客户端地址: 直接填写 nginx 的8847 端口的地址就可以了,nginx代理效果:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值