快速搭建开发环境 - Nacos

快速搭建开发环境 - Nacos

官网 https://nacos.io/zh-cn/docs/use-nacos-with-springcloud.html

Nacos Server

下载 https://github.com/alibaba/nacos/releases

[root@localhost local]# tar -zxf nacos-server-1.2.1.tar.gz 
[root@localhost local]# ll nacos
total 24
drwxr-xr-x. 2 root root     82 May  6 04:25 bin
drwxr-xr-x. 2  501 games   168 Apr 30 04:00 conf
-rw-r--r--. 1  501 games 17336 Apr  8  2019 LICENSE
-rw-r--r--. 1  501 games  1305 Apr  8  2019 NOTICE
drwxr-xr-x. 2 root root     30 May  6 04:25 target
[root@localhost nacos]# ll bin/
total 20
-rwxr-xr-x. 1 501 games  954 Apr  8  2019 shutdown.cmd
-rwxr-xr-x. 1 501 games  949 Apr 28 02:10 shutdown.sh
-rwxr-xr-x. 1 501 games 2836 Apr 30 04:00 startup.cmd
-rwxr-xr-x. 1 501 games 4730 Apr 30 04:00 startup.sh
[root@localhost nacos]# ll conf/
total 60
-rw-r--r--. 1 501 games  4226 Apr 30 04:00 application.properties
-rw-r--r--. 1 501 games   504 Apr 30 04:00 application.properties.example
-rw-r--r--. 1 501 games    58 Apr  8  2019 cluster.conf.example
-rw-r--r--. 1 501 games 21079 Apr 30 04:00 nacos-logback.xml
-rw-r--r--. 1 501 games 10043 Apr 30 04:00 nacos-mysql.sql
启动
[root@localhost nacos]# sh ./bin/startup.sh -m standalone && tail -f logs/start.out 
nacos is starting with standalone
nacos is starting,you can check the /usr/local/nacos/logs/start.out
/usr/local/java/bin/java  -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Djava.ext.dirs=/usr/local/java/jre/lib/ext:/usr/local/java/lib/ext -X
loggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -X
X:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/usr/local/nacos/plugins/health,/usr/local/nacos/plugins/cmdb,/usr/local/nacos/plugins
/mysql -Dnacos.home=/usr/local/nacos -jar /usr/local/nacos/target/nacos-server.jar  --spring.config.location=classpath:/,classpath:/config/,file:./
,file:./config/,file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288

         ,--.
       ,--.'|
   ,--,:  : |                                           Nacos 1.2.1
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 3674
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.1.113:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'

2020-05-06 05:45:58,922 INFO Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.spri
ngframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$218493a1] is not eligible for getting
 processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-06 05:45:59,062 INFO Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryOb
jectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-06 05:45:59,077 INFO Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@431cd9b2' of type [
org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPost
Processors (for example: not eligible for auto-proxying)

2020-05-06 05:45:59,080 INFO Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [
org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$46593653] is not elig
ible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-06 05:45:59,092 INFO Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetada
taSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)

2020-05-06 05:46:00,217 INFO Tomcat initialized with port(s): 8848 (http)

2020-05-06 05:46:00,555 INFO Root WebApplicationContext: initialization completed in 6699 ms

2020-05-06 05:46:07,925 INFO Initializing ExecutorService 'applicationTaskExecutor'

2020-05-06 05:46:08,412 INFO Adding welcome page: class path resource [static/index.html]

2020-05-06 05:46:09,157 INFO Creating filter chain: Ant [pattern='/**'], []

2020-05-06 05:46:09,228 INFO Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegration
Filter@4264b240, org.springframework.security.web.context.SecurityContextPersistenceFilter@5ce33a58, org.springframework.security.web.header.Header
WriterFilter@3c435123, org.springframework.security.web.csrf.CsrfFilter@73db4768, org.springframework.security.web.authentication.logout.LogoutFilt
er@25748410, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@546ccad7, org.springframework.security.web.servletapi.SecurityCo
ntextHolderAwareRequestFilter@7a527389, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5b04476e, org.springframework
.security.web.session.SessionManagementFilter@3a62c01e, org.springframework.security.web.access.ExceptionTranslationFilter@a8c1f44]

2020-05-06 05:46:09,404 INFO Exposing 2 endpoint(s) beneath base path '/actuator'

2020-05-06 05:46:09,473 INFO Initializing ExecutorService 'taskScheduler'

2020-05-06 05:46:09,846 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'

2020-05-06 05:46:09,868 INFO Nacos logs files: /usr/local/nacos/logs/

2020-05-06 05:46:09,868 INFO Nacos conf files: /usr/local/nacos/conf/

2020-05-06 05:46:09,868 INFO Nacos data files: /usr/local/nacos/data/

2020-05-06 05:46:09,869 INFO Nacos started successfully in stand alone mode.

2020-05-06 05:46:10,080 INFO Initializing Servlet 'dispatcherServlet'

2020-05-06 05:46:10,101 INFO Completed initialization in 21 ms
停止
[root@localhost nacos]# sh ./bin/shutdown.sh
访问
http://localhost:8848/nacos/index.html

默认账户密码 nacos/nacos

在这里插入图片描述

配置文件

application.properties

#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=8848

#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false

### Specify local server's IP:
# nacos.inetutils.ip-address=



#*************** Config Module Related Configurations ***************#
### If user 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=1000&socketTimeout=3000&autoReconnect=true
 db.user=root
 db.password=123456


#*************** Naming Module Related Configurations ***************#
### Data dispatch task execution period in milliseconds:
# nacos.naming.distro.taskDispatchPeriod=200

### Data count of batch sync task:
# nacos.naming.distro.batchSyncKeyCount=1000

### Retry delay in milliseconds if sync task failed:
# nacos.naming.distro.syncRetryDelay=5000

### If enable data warmup. If set to false, the server would accept request without local data preparation:
# nacos.naming.data.warmup=true

### If enable the instance auto expiration, kind like of health check of instance:
# nacos.naming.expireInstance=true


### If enable the empty service auto clean, services with an empty instance are automatically cleared
nacos.naming.empty-service.auto-clean=false
### The empty service cleanup task delays startup time in milliseconds
nacos.naming.empty-service.clean.initial-delay-ms=60000
### The empty service cleanup task cycle execution time in milliseconds
nacos.naming.empty-service.clean.period-time-ms=20000


#*************** CMDB Module Related Configurations ***************#
### The interval to dump external CMDB in seconds:
# nacos.cmdb.dumpTaskInterval=3600

### The interval of polling data change event in seconds:
# nacos.cmdb.eventTaskInterval=10

### The interval of loading labels in seconds:
# nacos.cmdb.labelTaskInterval=300

### If turn on data loading task:
# nacos.cmdb.loadDataAtStart=false


#*************** Metrics Related Configurations ***************#
### Metrics for prometheus
#management.endpoints.web.exposure.include=*

### 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
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true


#*************** 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=


#*************** Access Control Related Configurations ***************#
### If enable spring security, this option is deprecated in 1.2.0:
#spring.security.enabled=false

### 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=false


#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false

nacos基础及入门请移步官网或其他博客

参考博客

https://www.jianshu.com/p/c1bcded15d1d

https://www.jianshu.com/p/db02ab4d39c4

官网

https://nacos.io/zh-cn/docs/use-nacos-with-springcloud.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值