文章目录
本次教程是针对的nacos版本:2.0.1,不同的版本,可能略有不同。
官网下载地址:https://github.com/alibaba/nacos/tags
一、linux安装nacos
1. 解压压缩包
tar -xvf nacos-server-2.0.1.tar.gz
2.创建mysql数据库
SQL文件在解压文件下的config文件夹下,nacos-mysql.sql
nacos的各种数据存储在mysql数据库中
在MySQL服务器上创建nacos-mysql数据库,将SQL文件导入其中
3.编辑配置文件application.properties
编辑端口号:
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=5555
解开数据库的注释
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
编辑数据库连接的地址
### Connect URL of DB:
db.url.0=jdbc:mysql://mysql.xxx.tech:3306/nacos_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=nacos
添加数据库连接池的配置
### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
完整配置如下,已删掉多余的注释
#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=5555
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://mysql.xxx.tech:3306/nacos_prod?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos # mysql用户名root
db.password.0=nacos # mysql密码123456
### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
# nacos.naming.expireInstance=true
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000
### Metrics for elastic search
management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200
### Metrics for influx
management.metrics.export.influx.enabled=false
#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=false
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
### The directory of access log:
server.tomcat.basedir=
#*************** Access Control Related Configurations ***************#
### The ignore urls of auth, is deprecated in 1.2.0:
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
### The auth system to use, currently only 'nacos' is supported:
nacos.core.auth.system.type=nacos
### If turn on auth system:
nacos.core.auth.enabled=false
### The token expiration in seconds:
nacos.core.auth.default.token.expire.seconds=18000
### The default token:
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true
### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhite=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=
nacos.core.auth.server.identity.value=
#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false
若是配置集群的话,需要修改cluster.conf.example
在里边添加其他节点的nacos的IP+端口号
4.进入bin目录启动nacos
集群启动模式
./startup.sh
单机启动模式
sh startup.sh -m standalone
http://192.168.8.15:5555/nacos 查看结果
默认的账号密码都是 nacos
二、windows安装nacos
下载完直接解压
这里的bin目录里面有windows启动文件startup.cmd,cmd进去命令窗
输入startup.cmd -m standalone
启动后会有一个cmd窗口去打印命令并启动。这里我们启动成功了,启动失败后窗口会一闪而过。
http://localhost:8848/nacos
默认的账号密码都是 nacos