CentOS7 部署 nacos 集群

集群架构:

三个节点

172.27.132.22
172.27.132.24
172.27.132.37

nacos version: 1.2.1
OS version: centos7.5

vip:172.27.133.200

1、下载安装 jdk

$ yum install -y jdk-8u211-linux-x64.rpm

$ vim /etc/profile.d/java.sh

export JAVA_HOME=/usr/java/latest
export PATH=$JAVA_HOME/bin:$PATH

2、下载安装maven

$ vim /etc/profile

export PATH=/usr/local/maven/bin:$PATH

3、下载代码包解压

unzip nacos-server-1.2.1.zip

4、修改集群配置

$ vim conf/cluster.conf

#it is ip
#example
172.27.132.22:8848
172.27.132.24:8848
172.27.132.37:8848

5、修改数据库配置

$ vim conf/application.properties

### If user MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://172.27.133.201:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=nacos
db.password=TJNLZQjH

6、修改启动脚本中的监听地址,如果监听 127.0.0.1 会导致无法选举

$ vim bin/startup.sh

JAVA_OPT="${JAVA_OPT} -Dnacos.server.ip=172.27.132.22"

7、启动实例

sh bin/startup.sh
tailf /usr/local/nacos/logs/start.out
tailf /usr/local/nacos/logs/nacos.log

8、配置代理(有两个 haproxy 节点,keepalived 高可用这里就不赘述了)

vim /etc/haproxy/haproxy.cfg

listen nacos :8848
      mode http
      balance roundrobin
      server nacos01 172.27.132.22:8848 check
      server nacos02 172.27.132.24:8848 check
      server nacos03 172.27.132.37:8848 check

systemctl reload haproxy
netstat -tnlp | grep 8848

9、通过 vip 访问控制台,http://172.27.133.200:8848/nacos/

参考文档
https://nacos.io/zh-cn/docs/cluster-mode-quick-start.html
https://github.com/alibaba/nacos
https://blog.csdn.net/ooyhao/article/details/102745641
https://blog.csdn.net/ljz9425/article/details/105220867

posted @ 2020-04-29 00:30  KeithTt  阅读(2323)  评论(0编辑  收藏  举报