linux安装nacos集群

下载nacos源码

git clone https://github.com/alibaba/nacos.git
cd nacos/distribution
vi conf/application.properties

添加数据库配置

spring.datasource.platform=mysql
db.num=2
db.url.0=jdbc:mysql://11.162.196.16:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.url.1=jdbc:mysql://11.163.152.9:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=nacos_devtest
db.password=nacos

更改集群配置

cd conf/
cp cluster.conf.example cluster.conf
vi cluster.conf
192.168.2.147:8848
192.168.175.128:8848
192.168.175.130:8848

初始化mmysql

在mysql中执行 nacos-mysql.sql

测试环境jvm调优

#===========================================================================================
# JVM Configuration
#===========================================================================================
if [[ "${MODE}" == "standalone" ]]; then
JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -Xmn256m"
JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
else
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"

fi

启动nacos

# 在nacos的根部目录中执行
mvn -Prelease-nacos clean install -U

cd nacos/distribution/target/nacos-server{vers}/nacos/bin
sh startup.sh

问题解决

数据库连接失败

  1. 可能版本不一致
    如果使用8.0mysql 手动更换mysql版本

更改根目录xml

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>

本文总阅读量