1 2 3 4 5 6 7 8 9 |
# 拉取nacos docker pull nacos/nacos-server # 创建挂载目录 mkdir -p /data/nacos/logs/ mkdir -p /data/nacos/init.d/ # mysql新建nacos的数据库,并执行脚本 sql脚本地址如下: https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql # 在/data/nacos/init.d文件夹中增加配置文件custom.properties ,并修改配置文件 vim /data/nacos/init.d/custom.properties |
custom.properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
server.contextPath=/nacos server.servlet.contextPath=/nacos server.port=8848 spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://127.0.0.1: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 |
启动nacos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 运行nacos docker run \ --name nacos -d \ -p 8848:8848 \ -p 9848:9848 \ -p 9849:9849 \ --privileged=true \ --restart=always \ -e JVM_XMS=256m \ -e JVM_XMX=256m \ -e MODE=standalone \ -e PREFER_HOST_MODE=hostname \ -e SPRING_DATASOURCE_PLATFORM=mysql \ -e MYSQL_SERVICE_HOST=127.0.0.1 \ -e MYSQL_SERVICE_PORT=3306 \ -e MYSQL_SERVICE_USER=root \ -e MYSQL_SERVICE_PASSWORD=root \ -e MYSQL_SERVICE_DB_NAME=dbname \ -v /data/nacos/logs:/etc/nacos/logs \ -v /data/nacos/init.d/custom.properties:/etc/nacos/init.d/custom.properties \ nacos/nacos-server:latest |
Nacos2.0增加了9848,9849端口来进行GRPC通信,所以在docker环境中我们需要开放8849 9848 9849 三个端口
注:如果不加对应的数据库信息好像不能有些版本不能生效
1 2 3 4 5 6 |
-e SPRING_DATASOURCE_PLATFORM=mysql \ -e MYSQL_SERVICE_HOST=127.0.0.1 \ -e MYSQL_SERVICE_PORT=3306 \ -e MYSQL_SERVICE_USER=root \ -e MYSQL_SERVICE_PASSWORD=root \ -e MYSQL_SERVICE_DB_NAME=fxz_cloud_nacos \ |
浏览器输入服务器地址:http://xxx.xxx.xx.xx:8848/nacos/index.html,
账号nacos 密码nacos,登陆成功!
from:https://zhuanlan.zhihu.com/p/623460630?utm_id=0