Nacos cluster configuration examples (windows under test)

1, a first fork nacos code to your github repository, then clone the code locally. 
  git address: https: //github.com/alibaba/nacos.git

2, then your project into ideal editor (find sub distribution)

 

3, adding cluster nodes: Locate the file distribution-> conf-> cluster.conf.example, copy remove the suffix .example, edit cluster.conf, the node repair 
  127.0.0.1:8841 
  127.0.0.1:8842 
  127.0.0.1 : 8843
4, modify the data source 
  Adding a data source in distribution-> conf-> application.properties in (link address into the mysql own services, including account password)
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.url.1=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=nacos
db.password=nacos

  

5, introduced into the data in its own database 
  the distribution-> Table Structure conf-> nacos-mysql.sql is introduced into its own database to link to
6, packaged 
  and then execute the following command in the root directory of the project (assuming we have configured java and maven environment): mvn -Prelease-nacos clean install -U Note: The project is located in the root directory of the machine in D: \ Workspaces \ nacos, and then use the Terminal in the ideal packaging commands executed above (provided that you have installed the Terminal command), two compressed files nacos-server-1.0.1.tar.gz package will be finished> target the next generation in distribution- (use under linux) (use under windows) and nacos-server-1.0.1.zip
  
7, the cluster configuration 
  a, create a node: unzip nacos-server-1.0.1.zip, three copies, respectively command nacos-server-1.0.1-01, nacos- server-1.0.1-02, nacos- 1.0.1-03-Server; 
  B, modify the configuration: three nodes modified configuration file, the file open nacos-server-1.0.1-01 \ nacos \ conf \ application.properties, a first port node is modifying server.port = 8841, 
  and modify nacos-server-1.0.1-01 \ nacos \ bin \ startup.sh file, add the following two codes at the JVM configuration cluster configuration: JAVA_OPT = "{$} -Dserver JAVA_OPT = 127.0.0.1 .ip " 
  JAVA_OPT =" {$ JAVA_OPT} -Dserver.port = 8841 " 
  Note: If the experiment is useful to a different segment of the IP on linux you need to specify the IP, otherwise it will error. windows This machine can test only need to specify the port. Reference Source: https: //www.wandouip.com/t5i278697/ 
  other two nodes configured the same as the first node.
  
8, start the service 
  locally start: double-click on Start \ nacos \ bin \ startup.cmd file to start nacos-server-1.0.1- (under bin directory cmd command or enter cmd startup.cmd start), and then directly into the browser enter http://127.0.0.1:8841/nacos/index.html access, account passwords are nacos Note: after starting the doc remember not to close the command window, three nodes simultaneously start according to this method. Start the linux: need nacos-server-1.0.1.tar.gz copied to the server, and then extract command to extract tar -xvf nacos-server-1.0.1.tar.gz, enter start command: sh startup.sh
  
9, modify the account password 
  found in the project Nacos console project \ console \ src \ main \ java \ com \ alibaba \ nacos \ console \ password utils \ PasswordEncoderUtil.java class, you will want to set the input 123456, run the generated character with salt string $ 2a $ 10 $ XNArlfqerD3jY4LepVByPO6X1qJQDDWJsmbFnusKxVWjCFgJpCHbm, then the nacos database, to modify the password of the user table nacos user, the user name can be changed directly in the database.
10, Nginx proxy configuration 
  after three local nodes are activated, start configuring cluster agent, open nginx-1.14.2 \ conf \ nginx.conf configuration file, add the following two codes:
#集群的3个节点
upstream nacos {
 server 127.0.0.1:8841 weight=2;
 server 127.0.0.1:8842 weight=2;
 server 127.0.0.1:8843 weight=2;
}

server {
    listen       80;
    server_name  localhost;
    location /nacos/ {
        #代理
        proxy_pass http://nacos/nacos/;
    }
}
11、登录客户端
  http://localhost/nacos/index.html,输入预设好的账号和密码即可。

登录成功后的界面,集群节点查看

服务器配置后的节点效果

疑问一:我在本地配置了三个节点为什么在客户端只显示了一个节点,每次强制刷新页面时访问的节点会发生变化;每次而且节点状态和集群任期也会发生变化
  127.0.0.1/8整个都是环回地址,用来测试本机的TCP/IP协议栈,发往这段A类地址数据包不会出网卡,网络设备不会对其做路由
疑问二:当注册实例或者创建一个服务等操作时,节点状态和集群任期也会产生相应的变化。
  这个属于Ratf协议的内容,关于Raft协议的介绍可以参考https://www.jianshu.com/p/aa77c8f4cb5c

 

  

 

Guess you like

Origin www.cnblogs.com/yangtsecode/p/11209633.html