SpringCloud-study notes (5) nacos cluster environment construction

reference video

Cluster construction steps

Build a MySQL cluster and initialize the database table
Download and decompress nacos
Modify the cluster configuration (node ​​information) and database configuration
Start multiple nacos nodes
nginx reverse proxy

  • install database

The official suggestion is to use MySQL to form a high-availability cluster for the mode. For the convenience of demonstration, only a single-point database is used for testing.
We first use the MySQL database to create an empty library, and then execute the nacos-conf.sql file provided in the conf of the nacos compressed package
insert image description here

  • We then modify the configuration file

cluster.conf.exampleChange cluster.conf, and then change the content of the original file to your own ip and port

insert image description here
Then modify application.propertiesthe configuration of the database and modify it to your own configuration.

  • Finally, copy the nacos folder into three parts and modify application.propertiesthe files respectively server.port.

The application.yml file configuration in the code is as follows:

spring:
  cloud:
    nacos:
      server-addr: localhost:80 # Nacos地址

Start the nodes separately
insert image description here
Then we start to configure nginx below.
Modify the conf/nginx.conf file, the configuration is as follows:

upstream nacos-cluster {
    server 127.0.0.1:8845;
	server 127.0.0.1:8846;
	server 127.0.0.1:8847;
}

server {
    listen       80;
    server_name  localhost;

    location /nacos {// /nacos是nacos的默认路径,这里使用nginx代理这个路径
        proxy_pass http://nacos-cluster;
    }
}

Finally, visit in the browser: http://localhost/nacos.

Guess you like

Origin blog.csdn.net/qq_45401910/article/details/128942248