Deploy linux in nacos cluster environment

Table of contents

1. Download nacos

 Two, modify the configuration

1.application.properties

2.cluster.conf

3.startup.sh

Three, nginx configuration

4. Start


1. Download nacos

Select the tar.gz download of the matching springcloud version

Releases · alibaba/nacos · GitHub

Unzip it after downloading. Respectively copy as nacos8849, nacos8850, nacos8851 three folders

 Two, modify the configuration

Modify the configuration of the files in the three folders

1.application.properties

1. Modify

server.port=8849

The other two were changed to

server.port=8850

server.port=8851

2. Let go of annotations

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&useUnicode=true&useSSL=false&serverTimezone=UTC
 db.user.0=root
 db.password.0=123456

2.cluster.conf

cluster.conf.example copy a cluster.conf

changed to

10.0.4.16:8849
10.0.4.16:8850
10.0.4.16:8851

Among them, 10.0.4.16 is the local address of the server intranet

3.startup.sh

Enter the bin directory and modify startup.sh.

Modify xms, xmx, xmn in else according to the server memory size.

If the configured memory is too large, the memory will not be enough.

if [[ "${MODE}" == "standalone" ]]; then
    JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -Xmn256m"
    JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true"
else
    if [[ "${EMBEDDED_STORAGE}" == "embedded" ]]; then
        JAVA_OPT="${JAVA_OPT} -DembeddedStorage=true"
    fi
    JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
    JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof"
    JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"

Three, nginx configuration

Modify nginx configuration

 increase server at the same level

    upstream nacoscluster {
        server 127.0.0.1:8849;
        server 127.0.0.1:8850;
        server 127.0.0.1:8851;
    }

increase in server

 location /nacos/ {
         proxy_pass http://nacoscluster/nacos/;
 }

4. Start

After modifying the configuration, execute the startup.sh under each folder to start nacos.

Start nginx. (The nginx port configuration file is 80)

After startup, access  http://ip:port/nacos/ through the external network

Among them, ip is the address of the external network, and port is the port number mapped to the external network by nginx.

After logging in, you can see the list of nodes managed by the cluster

Guess you like

Origin blog.csdn.net/Spring_possible/article/details/130721187