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
- We then modify the configuration file
cluster.conf.example
Change cluster.conf
, and then change the content of the original file to your own ip and port
Then modify application.properties
the configuration of the database and modify it to your own configuration.
- Finally, copy the nacos folder into three parts and modify
application.properties
the files respectivelyserver.port
.
The application.yml file configuration in the code is as follows:
spring:
cloud:
nacos:
server-addr: localhost:80 # Nacos地址
Start the nodes separately
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.