sudo mkdir -p /opt/apps/nacos/logs/ #新建nacos的logs目录
sudo mkdir -p /opt/apps/nacos/init.d/
sudo vim /opt/apps/nacos/init.d/custom.properties #新建并修改nacos的配置文件
server.contextpath=/nacos
server.servlet.contextpath=/nacos
server.port=8848
spring.datasource.platform=MysqL
db.num=1
db.url.0=jdbc:MysqL://192.168.x.xxx:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=root
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskdispatchThreadCount=1
nacos.naming.distro.taskdispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataratio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true
1.
sudo docker pull nacos/nacos-server:1.4.2
2. 创建nacos的数据库
create database nacos_config
sql 文件:https://github.com/alibaba/nacos/blob/master/config/src/main/resources/meta-inf/nacos-db.sql
sudo docker run \
--name nacos -d \
-p 8848:8848 \
--privileged=true \
--restart=always \
-e JVM_xms=256m \
-e JVM_XMX=256m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /opt/apps/nacos/logs:/home/nacos/logs \
-v /opt/apps/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
nacos/nacos-server:1.4.2