Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation method of Nacos

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about the installation method of Nacos, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Nacos I, Spring Cloud, Spring Cloud Alibaba, Nacos version correspondence

Official version notes

Version description

Format edited this page 2019-7-1 13 revisions

Version dependency Spring Cloud VersionSpring Cloud Alibaba VersionSpring Boot VersionSpring Cloud Greenwich0.9.0.RELEASE2.1.X.RELEASESpring Cloud Finchley0.2.X.RELEASE2.0.X.RELEASESpring Cloud Edgware0.1.X.RELEASE1.5.X.RELEASENote Please note that Spring Cloud Edgware supports the minimum Edgware.SR5 version

Component version relationship Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version0.9.0.RELEASE or 0.2.2.RELEASE or 0.1.2.RELEASE1.5.21.0.04.4.02.7.10.4.20.2.1.RELEASE or 0.1.1.RELEASE1.4.00.6.24.3.1 ❌❌ 0.2.0.RELEASE or 0.1.0.RELEASE1.3.0-GA0.3.0 ❌❌❌ dependency Management

Spring Cloud Alibaba BOM contains all the dependent versions it uses.

RELEASE version of Spring Cloud Greenwich

If you need to use the Spring Cloud Greenwich version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.9.0.RELEASE pom importSpring Cloud Finchley

If you need to use the Spring Cloud Finchley version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.2.2.RELEASE pom importSpring Cloud Edgware

If you need to use the Spring Cloud Edgware version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.1.2.RELEASE pom importBUILD-SNAPSHOT version

If you want to use the latest version of SNAPSHOT, you first need to add the Spring BUILDSNAPSHOT repository to your maven configuration, which can be configured in settings.xml in the Maven configuration file or in the pom.xml of the Java project.

Spring-snapshot Spring Snapshot Repository https://repo.spring.io/snapshot true Note, please note that the BUILD-SNAPSHOT version may be updated at any time

Spring Cloud Greenwich

If you need to use the Spring Cloud Greenwich version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.9.1.BUILD-SNAPSHOT pom importSpring Cloud Finchley

If you need to use the Spring Cloud Finchley version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.2.3.BUILD-SNAPSHOT pom importSpring Cloud Edgware

If you need to use the Spring Cloud Edgware version, add the following to dependencyManagement

Org.springframework.cloud spring-cloud-alibaba-dependencies 0.1.3.BUILD-SNAPSHOT pom import II. Deploy Nacos1 on a single machine. Use docker deployment 1.1 to download the image

Github address

Dockerhub

Note: the branch version number in github needs to be the same as the docker image address. For example, nacos-server:0.6.0 does not support prometheus and grafana, but the latest version does.

# if you use the latest version of git clone-- depth 1 https://github.com/nacos-group/nacos-docker.git

If you are not using the latest version of the docker image

Then you need to find the appropriate version in github, then download the zip file and upload it to the centos server using ftp

1.2 deployment Image

Standalone Derby (standalone deployment, using Derby)

Derby is an embedded database written by Java. Do not introduce mysql.

Docker-compose-f example/standalone-derby.yaml up-d

Configuration file

Version: "3.7" services: nacos: image: nacos/nacos-server:1.1.0 # generally do not use latest container_name: nacos-standalone # container instance naming environment:-PREFER_HOST_MODE=hostname-MODE=standalone # deployment mode volumes: -. / standalone-logs/:/home/nacos/logs -. / init.d/custom.properties:/home/nacos/init.d/custom.properties # configuration uses prometheus, fluxdb, ES ports:-"8848 prometheus image 8848" prometheus: container_name: prometheus image: prom/prometheus:v2.11.1 volumes: -. / prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml # configuration Monitoring Point ports:-"9090 prometheus image 9090" depends_on:-nacos # Service Mapping restart: on-failure grafana: container_name: grafana image: grafana/grafana: 6.2.5 ports:-3000 ports 3000 restart: on-failure

Version is the version correspondence between docker-compose file format and docker

Version description

Compose file formatDocker Engine release3.718.06.0+3.618.02.0+3.517.12.0+3.417.09.0+3.317.06.0+3.217.04.0+3.11.13.1+3.01.13.0+2.417.12.0+2.317.06.0+2.21.13.0+2.11.12.0+2.01.10.0+1.01.9.1.+

Standalone Mysql (standalone deployment, using Mysql)

Docker-compose-f example/standalone-mysql.yaml up-d

Configuration file

Version: "3.7" services: nacos: image: nacos/nacos-server:1.1.0 container_name: nacos-standalone-mysql environment:-PREFER_HOST_MODE=hostname-MODE=standalone-SPRING_DATASOURCE_PLATFORM=mysql-MYSQL_MASTER_SERVICE_HOST=mysql-master-MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest-MYSQL_MASTER_SERVICE_PORT=3306-MYSQL_SLAVE_SERVICE_HOST=mysql-slave- MYSQL_SLAVE_SERVICE_PORT=3305-MYSQL_MASTER_SERVICE_USER=nacos-MYSQL_MASTER_SERVICE_PASSWORD=nacos volumes: -. / standalone-logs/:/home/nacos/logs -. / init.d/custom.properties:/home/nacos/init.d/custom.properties ports:-"8848 standalone-logs/:/home/nacos/logs 8848"-"95555 standalone-logs/:/home/nacos/logs 9555" depends_on:-mysql-slave restart: on-failure mysql -master: container_name: mysql-master image: nacos/nacos-mysql-master:latest env_file: -.. / env/mysql-common.env -.. / env/mysql-master.env volumes: -. / mysql-master:/var/lib/mysql ports:-"3306 mysql-master image 3306" mysql-slave: container_name: mysql-slave image: nacos/nacos-mysql-slave:latest env _ file: -.. / env/mysql-common.env -.. / env/mysql-slave.env volumes: -. / mysql-slave:/var/lib/mysql ports:-"3305 mysql-slave:/var/lib/mysql ports 3306" depends_on:-mysql-master prometheus: container_name: prometheus image: prom/prometheus:v2.11.1 volumes: -. / prometheus/prometheus-standalone.yaml:/etc / prometheus/prometheus.yml ports:-"9090 nacos restart 9090" depends_on:-nacos restart: on-failure grafana: container_name: grafana image: grafana/grafana:6.2.5 ports:-3000UR 3000 restart: on-failure

3. Cluster deployment of Nacos

Cluster (Cluster deployment)

5G memory reservation is required

Docker-compose-f example/cluster-hostname.yaml up-d

Configuration file

Version: "3.7" services: nacos1: hostname: nacos1 container_name: nacos1 image: nacos/nacos-server:1.1.0 volumes:-/ usr/local/use_data/nacos/nacos-cluster/nacos-1/data/logs:/home/nacos/logs -. / init.d/custom.properties:/home/nacos/init.d/custom.properties ports:-"8849-8848"- "95555 env/nacos-hostname.env restart 9555" env_file: -.. / env/nacos-hostname.env restart: on-failure depends_on:-mysql-master-mysql-slave nacos2: hostname: nacos2 image: nacos/nacos-server:latest container_name: nacos2 volumes:-/ usr/local/use_data/nacos/nacos-cluster/nacos-2/data/logs:/home/nacos/logs -. / init. D/custom.properties:/home/nacos/init.d/custom.properties ports:-"8850 on-failure depends_on 8848" env_file: -.. / env/nacos-hostname.env restart: on-failure depends_on:-mysql-master-mysql-slave nacos3: hostname: nacos3 image: nacos/nacos-server:latest container_name: nacos3 volumes:-/ usr/local/use_data/nacos/nacos -cluster/nacos-3/data/logs:/home/nacos/logs -. / init.d/custom.properties:/home/nacos/init.d/custom.properties ports:-"8851 env/nacos-hostname.env restart 8848" env_file: -.. / env/nacos-hostname.env restart: on-failure depends_on:-mysql-master-mysql-slave mysql-master: container_name: mysql-master image: nacos / nacos-mysql-master:latest env_file: -.. / env/mysql-common.env -.. / env/mysql-master.env volumes:-/ usr/local/use_data/nacos/nacos-cluster/mysql-master:/var/lib/mysql ports:-"3306 usr/local/use_data/nacos/nacos-cluster/mysql-master:/var/lib/mysql ports 3306" mysql-slave: container_name: mysql-slave image: nacos/nacos-mysql-slave:latest env_file: -.. / env/mysql-common.env -.. / env/mysql-slave.env volumes:-/ usr/local/use_data/nacos/nacos-cluster/mysql-slave:/var/lib/mysql ports:-"3305 depends_on:-mysql-master prometheus: container_name: prometheus image: prom/prometheus:v2.11.1 volumes: -. / Prometheus/prometheus-cluster.yaml:/etc/prometheus/prometheus.yml ports:-"9091 nacos2 9090" depends_on:-nacos1-nacos2-nacos3 restart: on-failure grafana: container_name: grafana image: grafana/grafana:6.2.5 ports:-3000 nacos2 3000 restart: on-failure

IV. Testing

Service registration

Curl-X PUT 'http://{ip}:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'

Service discovery

Curl-X GET 'http://{ip}:8848/nacos/v1/ns/instances?serviceName=nacos.naming.serviceName'

Publish configuration

Curl-X POST "http://{ip}:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=helloWorld"

Get configuration

Curl-X GET "http://{ip}:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"

Open it using a browser

Link: http://${ip}:8848/nacos/

Account number: nacos/nacos

Use prometheus to view monitoring data

Link: http://${ip}:9090

Monitor the ui panel using grafana

Link: http://${ip}:3000

Stop and start nacos

Because you are using docker-compose choreography, use the docker-compose command

# query running container docker-compose-f example/cluster-hostname.yaml ps# stop container docker-compose-f example/cluster-hostname.yaml stop# start container docker-compose-f example/cluster-hostname.yaml start# restart container docker-compose-f example/cluster-hostname.yaml restart# delete container docker-compose-f example/cluster-hostname.yaml rm above is the installation method of Nacos The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report