nacos安装教程

2年前 (2022) 程序员胖胖胖虎阿
262 0 0

目录

nacos安装步骤

1.解压安装包

2.创建mysql数据库

3.编辑配置文件application.properties

编辑端口号:

解开数据库的注释

编辑数据库连接的地址

添加数据库连接池的配置

完整配置如下,已删掉多余的注释

4.进入bin目录启动nacos

安装成功


nacos安装步骤

本次教程是针对的nacos版本:2.0.1,不同的版本,可能略有不同。

官网下载地址:

https://github.com/alibaba/nacos/tags

我下载的是2.0.1版本

nacos安装教程

nacos安装教程

1.解压安装包

tar -xvf nacos-server-2.0.1.tar.gz

2.创建mysql数据库

SQL文件在解压文件下的config文件夹下,nacos-mysql.sql

nacos的各种数据存储在mysql数据库中

在MySQL服务器上创建nacos-mysql数据库,将SQL文件导入其中

nacos安装教程

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
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


# 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+端口号

nacos安装教程

4.进入bin目录启动nacos

 ./startup.sh

安装成功

nacos安装教程

SpringCloud项目集成nacos请看这篇文章

SpringBoot项目集成nacos,并启动报错Failed to configure a DataSource: ‘url‘ attribute is not speci_小小张自由—>张有博-CSDN博客_springboot整合nacos启动报错本文详细介绍了nacos,常用的nacos的名词。springboot项目集成nacos的全过程,并从多个角度解决启动报错 Failed to configure a DataSource: ‘url‘ attribute is not specinacos安装教程https://blog.csdn.net/promsing/article/details/121123765

如果本篇博客对您有一定的帮助,大家记得留言+点赞+收藏哦。 

版权声明:程序员胖胖胖虎阿 发表于 2022年10月30日 下午10:56。
转载请注明:nacos安装教程 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...