Nacos installation ultra-detailed steps (windows+linux+docker)

Introduction

Nacos is a dynamic service discovery, configuration management and service management platform that makes it easier to build cloud-native applications.

Nacos main functions

  • Dynamic Service Discovery: Support DNS-based and RPC-based service discovery. Service providers can actively register services, and service consumers can dynamically discover services.
  • Dynamic Configuration Service: Supports dynamic configuration of cloud-native microservices, can be used as a data center to manage and push configuration files, and can also support clients to pull configuration information.
  • Dynamic DNS service: dynamic resolution of domain names, which can easily realize the dynamic adjustment of the corresponding relationship between domain names and services.
  • Service and its metadata management: support the management of services, realize the online and offline of services, and provide the management function of service metadata, which is convenient for service dependency analysis, performance monitoring and other operations.

The main features of Nacos

  • Service registration and discovery: supports DNS-based and RPC-based service discovery.
  • Dynamic Configuration Service: Dynamically update and push configurations.
  • Dynamic DNS service: Adding and removing DNS records on the fly.
  • Service and its metadata management: manage services and metadata to facilitate operations such as service dependency analysis and performance monitoring.
  • Offline instance management: jox#Offline instance records for reference when other instances elect the master instance.
  • Support open API: support open platform API, convenient for secondary development and expansion.
  • Support multiple configuration formats: support configurations in formats such as YAML/Properties/XML/JSON.
  • Data monitoring: Supports the monitoring of various data stored in Nacos to facilitate data analysis and diagnosis.
  • Multi-language support: supports multiple languages ​​such as Java/C#/.Net Core/Go/.
  • High Availability: Nacos supports Cluster mode to easily implement high availability deployment.

windows install nacos

1. Download address

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

image-20230528121117264

2. Unzip after downloading

image-20230528121332852

3. You also need to configure the database, take mysql as an example

​3.1 Create a new configuration database nacos-config

​3.2 Execute mysql-schema.sql under nacos/conf

image-20230528121444482

3.3 Generate the table as follows:

image-20230528165025211

4.bin directory

image-20230528170118374

5. start

​5.1 Modify set MODE="cluster" in startup.cmd to set MODE="standalone" and then double-click to start

image-20230528170703881

​5.2 Execute startup.cmd -m standalone

linux install NACOS

1. Download address

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

2. Unzip and move

tar -zxvf nacos-server-2.2.3.tar.gz 
mv nacos /usr/local

3. Edit text

vim startup.sh

4. Modify the configuration

Will

export JAVA_HOME=$HOME/jdk/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH={JAVA_HOME}/bin:$PATH

change into

export JAVA_HOME=/usr/local/java/jdk17.0.4.1
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH={JAVA_HOME}/bin:$PATH

5. Edit application.properties

cd /usr/local/nacos/conf
vim application.properties
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://10.114.12.177:3306/nacos-config?serverTimezone=GMT%2B8&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=123456

6. start

cd /usr/local/nacos/bin
sh startup.sh -m standalone

docker install NACOS

1. Install

docker pull nacos/nacos-server

2. Set up mount

mkdir -p /mydata/nacos/logs/                      #新建logs目录
mkdir -p /mydata/nacos/init.d/      

3. Modify the configuration

vim /mydata/nacos/init.d/custom.properties        #修改配置文件
server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848

spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos-config? characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true #这里需要修改端口
db.user=root #用户名
db.password=123456 #密码

nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true

4. Start (need to start 8848, 9848)

docker  run 
--name nacos -d 
-p 8848:8848 
-p 9848:9848 \
--privileged=true 
--restart=always 
-e JVM_XMS=256m 
-e JVM_XMX=256m 
-e MODE=standalone 
-e PREFER_HOST_MODE=hostname 
-v /mydata/nacos/logs:/home/nacos/logs 
-v /mydata/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
nacos/nacos-server

background address

地址: http://127.0.0.1:8848/nacos
账号: nacos
密码: nacos

write at the end

If you are interested in related articles, you can pay attention to the official account "Architecture Palace", and will continue to update AIGC, java basic interview questions, netty, spring boot, spring cloud and other series of articles, and a series of dry goods will be delivered at any time!

Guess you like

Origin blog.csdn.net/jinxinxin1314/article/details/130917625