Nacos detailed cluster configuration

1, download Nacos

Nacos Download: https://github.com/alibaba/nacos/releases/tag/1.2.0

2, the configuration Nacos

(1), installation configuration
to create a folder in / opt

mkdir mynacos

Xftp can be downloaded to the compressed packet transfer folder

Use this command to extract the folder can be obtained nacos

tar -zxvf nacos-server-1.2.0.tar.gz

Here Insert Picture Description
After extracting good, go to the conf directory j cluster configuration

cd /opt/nacos/conf
cp cluster.conf.example cluster.conf
vim cluster.conf

cp cluster.conf.example cluster.conf is cluster.conf.example a copy of the conf directory in order to avoid, after improper operation cluster.conf.example

Add Content

192.168.204.128:3333
192.168.204.128:4444
192.168.204.128:5555

Use the command to view port

hostname -i


(2) create a database
Here Insert Picture Description
to find nacos-mysql.sql file in the conf directory.
Here Insert Picture Description

  1. You can copy the contents of the file selected in nacos_config to Navicat database, and then click query Click New Query

Here Insert Picture Description

  1. Just right database, run the SQL file and select nacos-mysql.sql file
    Here Insert Picture Description
    obtained after the operation
    Here Insert Picture Description
    and then configure conf / application.properties file
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://填自己的端口号:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=用户名
db.password=密码

(3), turn off the firewall or open port (if a port is open remember to restart the firewall)

systemctl stop firewalld

sudo firewall-cmd --add-port=80/tcp --permanent  (80为这次需要开放的端口)
firewall-cmd --reload

View open port number

 firewall-cmd --list-all

3, configure Nginx

nginx common commands is as follows:

nginx  #启动nginx
nginx -s quit  #快速停止nginx
nginx -V #查看版本,以及配置文件地址
nginx -v #查看版本
nginx -s reload|reopen|stop|quit   #重新加载配置|重启|快速停止|安全关闭nginx
nginx -h #帮助

Change setting

vim /usr/local/nginx/conf/nginx.conf

Configure Reverse Proxy

 upstream cluster{
        server 192.168.204.128:3333;
        server 192.168.204.128:4444;
        server 192.168.204.128:5555;
   }   

    server {
        listen      1111;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / { 
           # root   html;
           # index  index.html index.htm;
           proxy_pass http://cluster;
        } 

After a good modification to the next bin under nacos

cd /opt/mynacos/nacos/bin/
vim startup.sh

Here Insert Picture Description
Here Insert Picture Description
After a good start to modify nacos

./startup.sh -p 3333
./startup.sh -p 4444
./startup.sh -p 5555

If you perform the error:

chmod u+x *.sh

Then start nacos

nacos boot is completed, start nginx

cd /usr/local/nginx/sbin/

./nginx

Access browser

http://192.168.204.128:1111/nacos/

See nacos for success!
Here Insert Picture Description

Released four original articles · won praise 0 · Views 77

Guess you like

Origin blog.csdn.net/llllllkkkkkooooo/article/details/105009410