Nacos Server cluster construction

Previous article: Nacos Service Registration and Configuration Center

Nacos Server data persistence

  1. Download nacos
    nacos-server-1.2.0.tar
    Insert image description here

  2. Execute mysql data script
    Insert image description here
    Insert image description here

  3. Modify nacos configuration
    Insert image description here
    Insert image description here

  4. Restart nacos and create a new namespace

Insert image description here
Insert image description here

Nacos Server cluster construction

  1. Modify configuration fileapplication.properties
### Specify local server's IP:
nacos.inetutils.ip-address=127.0.0.1

#*************** 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_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=root
  1. Modify the cluster configuration file and make a copy
    Insert image description here
#it is ip
#example
127.0.0.1:8848
127.0.0.1:8849
127.0.0.1:8850
  1. Copy 3 copies of nacos 8848 8849 8850 and modify the ports respectively.
    Insert image description here

  2. Start D:\dev\nacos-1\bin separately in cluster mode
# 单列模式
# .\startup.cmd -m standalone
# 集群模式
.\startup.cmd -m cluster

Insert image description here

  1. Visit http://localhost:8848/nacos/ ports 8849 and 8850 respectively.
    Insert image description here

Register the microservice to the Nacos cluster

  • Service provider registers with cluster
  1. Modify the configuration of service provider m-service-resume-8083-nacos
server:
  port: 8083

spring:
  application:
    name: m-service-resume

  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8 &serverTimezone=UTC
    username: root
    password: root
  jpa:
    database: MySQL
    show-sql: true
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl  #避免将驼峰命名转换为下划线命名
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848,127.0.0.1:8849,127.0.0.1:8850
# 非免密登录需要用户,密码等信息       
#        username: nacos
#        password: nacos
#        enabled: true
        #集群名称
        cluster-name: BJ
        #所属命名空间 命名空间ID
        namespace: 59486577-18d5-459c-94ad-cbdf6f3d9d5a


  1. Check the nacos cluster, m-service-resume has been registered in the dev cluster with the namespace
    Insert image description here
  • Service consumers register to the cluster
  1. Modify m-service-autodeliver-8093-nacos configuration
spring:
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848,127.0.0.1:8849,127.0.0.1:8850
          #集群名称
          cluster-name: BJ
          #所属命名空间
          namespace: 59486577-18d5-459c-94ad-cbdf6f3d9d5a
  1. Observation cluster
    Insert image description here
  2. Access the consumer interface http://localhost:8093/autodeliver/checkState/1545132
    Insert image description here

Guess you like

Origin blog.csdn.net/u014535922/article/details/130625853