Windows server 2012 server nacos installation configuration and cluster construction

1. Install and configure nacos

1 Introduction

nacos官网文档介绍:https://nacos.io/zh-cn/docs/what-is-nacos.html

2. Download and install

Here I use the 1.3.2
address: https://github.com/alibaba/nacos/releases/tag/1.4.0
Insert image description here
1. Create a nacos database and execute the nacos/conf/nacos-mysql.sql file to initialize the table structure and data .
Insert image description here
2. Modify nacos/conf/application.properties configuration data related information

#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
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=root
db.password=fzys87

3. Open the windos command line and enter the command in the bin directory to start the server.

startup.cmd -m standalone
or go to nacos\bin\startup.cmd and double-click "startup.cmd" to start the nocas service
Insert image description here
4. Test

Log in to the nacos management console http://localhost:8848/nacos/, the default user password: nacos/nacos
Insert image description here
Insert image description here

2. Build a nacos cluster

1. Unzip the downloaded Nacos, enter the conf directory under nacos and rename cluster.conf.example to cluster.conf, then open the file and add the following content.

服务器ip:8847
服务器ip:8848
服务器ip:8849
服务器ip:8850

Insert image description here

* Note : The number should be replaced with the IP address of your own server’s public network.
The ports of the nacos cluster built this time are 8847, 8848, 8849, and 8850. The
IP address in front of it is your own local IP address. It is best not to write localhost or 127.0.0.1 here, otherwise the cluster may fail to be built!

2. If it is modified in the previous stand-alone nacos, there is no need to modify the database path of the application.properties file.
If it is not necessary to modify the contents of the application.properties file.

#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
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=root
db.password=fzys87

3. The default startup mode of nacos is the stand-alone version. We need to manually change it to the cluster version. Open the startup.cmd file in the bin directory with Notepad, and sequentially exchange the codes in the following locations. Before
replacing
Insert image description here

After replacement
Insert image description here

 if %MODE% == "cluster" (
    set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
    set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof"
    set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
) else (
    set "JAVA_OPT=%JAVA_OPT% -Xms512m -Xmx512m -Xmn256m"
    set "JAVA_OPT=%JAVA_OPT% -Dnacos.standalone=true"
)

  1. Copy the previous nacos folder. I copied three here (the names are arbitrary). The server.port in the application.properties file under conf in the nacos directory was changed to 8847, 8849, and 8850 respectively.

5. If the modification is not done on the previous nacos, you need to create a new data nacos database and initialize the data in the MySQL database. Execute the nacos-mysql.sql database script in the conf directory.
Insert image description here
Insert image description here
Note: You can use a separate database for each service and just modify the database in the application.properties file. If you use the same one, the data is universal and you can use multiple Namespaces are separated.

6. Start these four nacos on four nodes respectively (go to bin and click startup.cmd to start)
Insert image description here

7. Test
http://…:8848/nacos/index.html
http://…:8847/nacos/index.html
http://…:8849/nacos/index.html
http://…:8850/ nacos/index.htmlThe
default username and password are nacos

Guess you like

Origin blog.csdn.net/A_awen/article/details/122691156