集群部署nacos
三台服务器
| 主机系统 | 主机IP |
|---|---|
| almaLiunx | 10.1.0.108 |
| almaLiunx | 10.1.0.109 |
| almaLiunx | 10.1.0.112 |
需要提前准备数据库
下面的操作,每个主机都要做
安装依赖
dnf install java-11-openjdk-devel
下载安装包
wget https://github.com/alibaba/nacos/releases/download/2.5.1/nacos-server-2.5.1.tar.gz
修改配置
vim conf/application.properties
# 修改下面的配置
spring.sql.init.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://10.1.0.108:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai
db.user.0=admin
db.password.0=111111
nacos.core.auth.enabled=true
### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=abc
nacos.core.auth.server.identity.value=111
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=MTExMTExMTExMTExMTExMTExMTExMTExMTExMTExMTExCg==
cp conf/cluster.conf.example conf/cluster.conf
vim conf/cluster.conf
10.1.0.108:8848
10.1.0.109:8848
10.1.0.112:8848
启服务
$ bash bin/startup.sh
/usr/lib/jvm/java-11-openjdk-11.0.25.0.9-3.el9.x86_64/bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/nacos/logs/java_heapdump.hprof -XX:-UseLargePages -Dnacos.member.list= -Xlog:gc*:file=/root/nacos/logs/nacos_gc.log:time,tags:filecount=10,filesize=100m -Dloader.path=/root/nacos/plugins,/root/nacos/plugins/health,/root/nacos/plugins/cmdb,/root/nacos/plugins/selector -Dnacos.home=/root/nacos -jar /root/nacos/target/nacos-server.jar --spring.config.additional-location=file:/root/nacos/conf/ --logging.config=/root/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with cluster
nacos is starting. you can check the /root/nacos/logs/start.out
查看日志
tail -f logs/start.out
2025-04-11 16:35:49,933 INFO The server IP list of Nacos is [10.1.0.108:8848, 10.1.0.109:8848, 10.1.0.112:8848]
2025-04-11 16:35:50,934 INFO Nacos is starting...
2025-04-11 16:35:51,940 INFO Nacos is starting...
2025-04-11 16:35:52,941 INFO Nacos is starting...
2025-04-11 16:35:53,941 INFO Nacos is starting...
2025-04-11 16:35:54,942 INFO Nacos is starting...
2025-04-11 16:35:55,942 INFO Nacos is starting...
2025-04-11 16:35:56,942 INFO Nacos is starting...
2025-04-11 16:35:57,943 INFO Nacos is starting...
2025-04-11 16:35:58,943 INFO Nacos is starting...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.alipay.sofa.jraft.util.internal.UnsafeUtil (jar:file:/root/nacos/target/nacos-server.jar!/BOOT-INF/lib/jraft-core-1.3.14.jar!/) to field java.nio.Buffer.address
WARNING: Please consider reporting this to the maintainers of com.alipay.sofa.jraft.util.internal.UnsafeUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2025-04-11 16:35:59,946 INFO Nacos is starting...
2025-04-11 16:36:00,947 INFO Nacos is starting...
2025-04-11 16:36:01,951 INFO Nacos is starting...
2025-04-11 16:36:02,505 INFO Nacos started successfully in cluster mode. use external storage
这就表示成功了
然后可以访问
http://10.1.0.108:8848/nacos
http://10.1.0.109:8848/nacos
http://10.1.0.112:8848/nacos
前面可以加个LB

这里就可以看到,集群已经正常了
本文来自博客园,作者:厚礼蝎,转载请注明原文链接:https://www.cnblogs.com/guangdelw/p/18828748

浙公网安备 33010602011771号