当前位置:网站首页>[on Nacos] get started quickly
[on Nacos] get started quickly
2022-06-27 12:04:00 【Liangyou】
If you want to know more Nacos course , welcome star 《On Nacos》 Open source project . be based on Nacos 2.x To get started 、 principle 、 Source code 、 Introduction to actual combat , Help developers get started quickly Nacos.
Installation package
install
Step one : Can pass https://github.com/alibaba/nacos/releases Find the corresponding version , Download packaged Nacos. You can use the following command to download the corresponding Nacos edition . What we're downloading right now is 2.1.0 edition , You can use the following command :
wget https://github.com/alibaba/nacos/releases/download/2.1.0/nacos-server-2.1.0.tar.gz
Step two : After downloading the compressed package, you need to decompress it with a command :
tar -xzf nacos-server-2.1.0.tar.gz
Step three :cd To nacos Under the table of contents , First, let's introduce the directory structure
.
|____LICENSE
|____bin // nacos Start of 、 Stop script
| |____startup.sh
| |____startup.cmd
| |____shutdown.sh
| |____shutdown.cmd
|____target // nacos Server side jar package
| |____nacos-server.jar
|____NOTICE
|____conf // naocs The configuration file 、sql Script 、 Cluster configuration, etc
| |____1.4.0-ipv6_support-update.sql
| |____schema.sql
| |____nacos-mysql.sql
| |____application.properties.example
| |____nacos-logback.xml
| |____cluster.conf.example
| |____application.properties
Step four : Stand alone mode starts Nacos
Linux/Unix/Mac
Start command ( -m standalone Stand alone mode start ):
sh startup.sh -m standalone
If you are using ubuntu System , Or run the script to report an error [[ Symbol not found , Try the following operation :
bash startup.sh -m standalone
Windows
Start command ( -m standalone Stand alone mode start ):
startup.cmd -m standalone
The following log shows that it has been started naocs 了 , Detailed log nacos/logs/start.out.
nacos is starting with standalone
nacos is starting,you can check the /Users/lixiaoshuang/nacos-related/nacos/logs/start.out
Step five : Access... Through a browser :http://127.0.0.1:8848/nacos Sign in nacos Console , The default account name and password are :nacos、nacos.

remarks : By default, it is unnecessary to start in stand-alone mode MySQL Of , If you want to use it MySQL You can modify the data source information in the configuration
Configuration Management
adopt curl Command invocation Nacos Of Open API Let's have a quick experience of Nacos Configuration management capabilities .
Release configuration :
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=Hello Nacos"
adopt curl After the command is issued and configured , You can configure management through the console - View the configuration information in the configuration list .

Get configuration :
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"

Service registration & Find out
adopt curl Command invocation Nacos Of Open API Let's have a quick experience of Nacos Service discovery capabilities for .
Service registration :
curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'
After execution curl After the command , You can manage services on the console - View the registered service information in the service list .

Service discovery :
curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.naming.serviceName'

Use MySQL
If you want to Nacos Use MySQL To do the underlying storage , First we need to find out nacos/conf In the catalog nacos-mysql.sql . perform sql Script creation nacos Related library tables .
Then you just need to modify application.properties file , First cd To nacos/conf Under the table of contents , use vim Command to change application.properties file , Find the following comment :
#*************** 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://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
# db.user.0=nacos
# db.password.0=nacos
Release comment , modify db.url.0 The database link of is the actual database address to be connected , Modify corresponding user、password.
#*************** 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://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=12345678
After modifying the above configuration , Through nacos/bin The startup script under the directory starts nacos that will do :
sh startup.sh -m standalone
Debugging the source code
Step one : adopt git The order will nacos Warehouse clone To local
git clone https://github.com/alibaba/nacos.git
Step two : Use idea open nacos Source code

Step three : Use mvn clean compile -U -Dmaven.test.skip=true Command to compile the project

Step four : find com.alibaba.nacos.Nacos Start class , stay idea Add... At startup VM Parameters -Dnacos.standalone=true, And then it starts , You can debug nacos Source code .

边栏推荐
- In depth analysis of error solutions and problems in dynamic loading of unity shadow and outline components
- Nifi from introduction to practice (nanny level tutorial) - identity authentication
- Comment modifier Node Fichiers dans les modules
- Getting started with go web programming: validators
- [tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
- Precautions for use of IO interface interrupt of Jerry [chapter]
- Jerry's DAC output mode setting [chapter]
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用VGAM包的vglm函数对有序多分类logistic回归模型进行平行性假设作检验
- 56. Core principle of flutter - flutter startup process and rendering pipeline
- namespace ‘rlang’ 0.2.0 is being loaded, but >= 0.3.0 is required
猜你喜欢

QStyle实现自绘界面项目实战(一)

"Internet +" contest topic hot docking | I figure to understand 38 propositions of Baidu

器审科普:创新医疗器械系列科普——胸骨板产品

MapReduce principle analysis (in-depth source code)

巅峰小店APP仿站开发玩法模式讲解源码分享

Salesforce 容器化 ISV 场景下的软件供应链安全落地实践

Interviewer: with the for loop, why do you need foreach?
![Dynamic programming [4] (counting class DP) example: integer partition](/img/06/4b3863bbb85582348c6f4ea7c5511e.png)
Dynamic programming [4] (counting class DP) example: integer partition

Unity shader learning (I) understanding the basic structure of unity shader

How to adjust an integer that is entered in Excel but always displays decimals?
随机推荐
Maximum path and problem (cherry picking problem)
记一次 .NET 某物管后台服务 卡死分析
Usage of rxjs mergemap
手把手带你入门 API 开发
Detailed explanation of interprocess communication
56. Core principle of flutter - flutter startup process and rendering pipeline
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.labels参数在可视化图像中为强调线添加标签信息
R语言glm函数构建二分类logistic回归模型(family参数为binomial)、使用AIC函数比较两个模型的AIC值的差异(简单模型和复杂模型)
Don't miss it. New media operates 15 treasure official account to share
The GLM function of R language is used to build a binary logistic regression model (the family parameter is binomial), and the AIC function is used to compare the AIC values of the two models (simple
The wonderful use of 0 length array in C language
千万不要错过,新媒体运营15个宝藏公众号分享
建木持续集成平台v2.5.0发布
星际争霸的虫王IA退役2年搞AI,自叹不如了
最大路径和问题(摘樱桃问题)
动态规划【四】(计数类dp)例题:整数划分
i. Construction of mx6ull C language environment
Nifi from introduction to practice (nanny level tutorial) - identity authentication
Leetcode 177 The nth highest salary (June 26, 2022)
【On nacos】快速上手 Nacos