本文已参与「新人创作礼」活动,一起开启掘金创作之路。
- 下载Nacos压缩包:github.com/alibaba/Nac…
-
解压:tar包:
tar -zxvf nacos-server-1.3.1.tar.gz nacos
,zip包:unzip nacos-server-1.3.1.zip
-
初始化数据库,登录MySQL创建nacos数据库:
CREATE DATABASE nacos DEFAULT charset utf8mb4 COLLATE utf8mb4_general_ci
; 执行:source nacos/conf/nacos-mysql.sql
-
修改Nacos配置,修改数据库配置:
vi nacos/conf/application.properties
# 常用配置:
#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=8080
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user=xxxxxxxx
db.password=xxxxxxxx
### Metrics for elastic search
management.metrics.export.elastic.enabled=false
### Metrics for influx
management.metrics.export.influx.enabled=false
#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=true
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
### The directory of access log:
server.tomcat.basedir=
### The ignore urls of auth, is deprecated in 1.2.0:
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/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
#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false
-
启动服务(单机):
bash -f ./startup.sh -m standalone
-
查看启动日志,确认启动结果:
tail -f nacos/logs/start.out
# 省略......
,--.
,--.'|
,--,: : | Nacos 1.3.1
,`--.'`| ' : ,---. Running in stand alone mode, All function modules
| : : | | ' ,'\ .--.--. Port: 8080
: | \ | : ,--.--. ,---. / / | / / ' Pid: 14950
| : ' '; | / \ / \. ; ,. :| : /`./ Console: http://127.0.0.1:8080/nacos/index.html
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
| | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /
' : | ; : .' \ : : `----' '--'. /
; |.' | , .-./\ \ / `--'---'
'---' `--`---' `----'
2021-07-27 10:21:50,760 INFO Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$628924ad] is not eligible fo
r getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
# 省略......
2021-07-27 10:21:51,330 INFO Tomcat initialized with port(s): 8080 (http)
- 浏览器访问并登录:
http://127.0.0.1:8080/nacos/index.html
,默认账号密码:nacos/nacos