当前位置:网站首页>Deployment and use of Nacos
Deployment and use of Nacos
2022-06-30 21:32:00 【[email protected]】
Nacos Deployment and use
download
Deploy
stand-alone
192.168.1.10 This server is used in this chapter , To install MySQL.
Upload the downloaded file to /usr/local/nacos Under the document
mkdir /usr/local/nacos # establish nacos Folder , Upload the file downloaded above here
cd /usr/local/nacos # Enter file
tar -zxvf nacos-server-2.1.0.tar.gz # Unzip the file
cd nacos/conf/ # Enter the conf In file
After entering the document will be nacos-mysql.sql Save the file or make a copy , Enter into MySQL in
create database nacos_mysql; # Create database
use nacos_mysql; # Enter this database
source /usr/local/weekeight/nacos/nacos/conf/nacos-mysql.sql; # perform sql file , The path is based on the absolute path of your file
create user 'nacos'@'%' identified by 'nacos'; # Create user
grant all on nacos_mysql.* to 'nacos'@'%'; # Assign permissions
flush privileges; # Refresh
Linux Console
cd /usr/local/nacos/nacos/conf/ # Enter the configuration folder
cp cluster.conf.example cluster.conf # Copy the cluster file
vim application.properties # The configuration file
vim cluster.conf # Configure clusters
Modify the configuration file application.properties, Attributes use vim Search function to find and then unlock comments or modify parameters
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://192.168.1.10:3306/nacos_mysql?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=nacos
nacos.core.auth.enabled=false # Close permissions , It can be opened for use
Modify the configuration file cluster.conf, take nacos Of IP+ Write in the port , The port is set above
192.168.1.10:8848
start-up
cd /usr/local/nacos/nacos/bin/
./startup.sh -m stanalone # Start the program
visit 192.168.1.10:8848/nacos Enter interface , account number nacos\ password nacos
Use

Configuration Management
It is equivalent to that the configuration center can hot refresh the configuration of the project
Service management
It's equivalent to a registry
Access control
User creation and permission control
Namespace
You can create namespaces , It can be understood as a project with a namespace , A set of microservices in a project , There are many programs .
Cluster management
nacos Cluster management of
The namespace has its own , Now create a new namespace example, Namespace id Also use example, Not set up id It will generate automatically (uuid),id Will be used in the program
Java Add maven
The configuration file used in the project should use bootstrap.yml perhaps bootstrap.properties,bootstrap The priority ratio application high
According to your own installation nacos The introduction of different versions corresponds to maven, Reference here 
<!-- nacos Service registration / Find out -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
<!--nacos The configuration center is used for configuration management -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
Registry Center

Specify the namespace just created , Appoint nacos Of IP:port, In this way, you can see the service in the service list after starting , Of course, you can add group To group , Group by environment or whatever 
Configuration center

What needs attention here is my spring.profiles.active=dev Not in the configuration file , But in the startup parameters , The main reason is that you don't need to change the environment when packaging yml file , Running jar Just switch packages , Make it convenient

At the same time nacos Create a Data ID by ${prefix}-${spring.profile.active}.${file-extension},group It can be configured by default , At this time, the configuration content will be loaded when the program is started

Use @Value and @RefreshScope Cooperate to realize hot refresh , Use it together .
This column is a micro service record column , If you have any questions, please point out , Learning together !
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/181/202206302128489916.html
边栏推荐
- 1-13 express监听GET和POST请求&处理请求
- 将el-table原样导出为excel表格
- clickhouse原生監控項,系統錶描述
- 的撒啊苏丹看老司机
- 个人开发的渗透测试工具Satania
- ca i啊几次哦啊句iu家哦
- Personal developed penetration testing tool Satania
- Use the log server to output the topn of various Apache logs
- To the Sultanate of Anderson
- Why have the intelligent investment advisory products collectively taken off the shelves of banks become "chicken ribs"?
猜你喜欢

Oracle 数据库表结构 Excel 导出

Jupyterbook clear console output

多态在代码中的体现

Spatiotemporal data mining: an overview

个人开发的渗透测试工具Satania

文本生成模型退化怎麼辦?SimCTG 告訴你答案

ICLR'22 Spotlight | 怎样度量神经网络权重中的信息量?

Text recognition svtr paper interpretation

Multi table operation - foreign key constraint

Personal developed penetration testing tool Satania
随机推荐
3Ds Max 精模obj模型导入ArcGIS Pro (二)要点补充
Auto-created primary key used when not defining a primary key
Learning summary
全面认识痛风:症状、风险因素、发病机理及管理
ssh 默认端口不是22时的一些问题
针对美国国家安全局“酸狐狸”漏洞攻击武器平台的分析与应对方案建议
用yml文件进行conda迁移环境时的报错小结
興奮神經遞質——穀氨酸與大腦健康
What does grade evaluation mean? What is included in the workflow?
Move blog to CSDN
1-20 预检请求
Can flinksql two Kafka streams join?
Clickhouse Native Monitoring item, System table Description
1-15 nodemon
Five years after graduation, I wondered if I would still be so anxious if I hadn't taken the test
vim 常用快捷键
测试媒资缓存问题
Understand what MySQL index push down (ICP) is in one article
1-13 express监听GET和POST请求&处理请求
A group of K inverted linked lists
