【Spring Cloud Alibaba】Installation and introduction of Nacos and installation of Nacos cluster

Welcome to the world of Nacos!


Nacos /nɑ:kəʊs/ is the acronym for Dynamic Naming and Configuration Service, a dynamic service discovery, configuration management and service management platform that is easier to build cloud-native applications.

Nacos is dedicated to helping you discover, configure and manage microservices. Nacos
provides a set of easy-to-use feature sets to help you quickly realize dynamic service discovery, service configuration, service metadata, and traffic management.

Nacos helps you build, deliver and manage microservice platforms more agilely and easily. Nacos is a service infrastructure for building a "service"-centric modern application architecture
(such as microservice paradigm, cloud native paradigm).
Quote:
https://nacos.io/zh-cn/docs/what-is-nacos.html

⌚️nacos installation

⌚️The first step. Download the installation package

Download the nacos-server-$version.zip package from the latest stable version .

insert image description here
insert image description here

If you can't open it, you can download it from here

Personal warehouse (writing as of the latest version)

insert image description here

⌚️The second step. Modify nacos configuration

⌚️2.1 Modificationapplication.properties

insert image description here

After version 2.2.0.1, the community release version will remove the following values ​​in the document as the default values, which need to be filled in by yourself, otherwise the node cannot be started.

insert image description here

### The default token(Base64 String):
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789

### 2.1.0 版本后
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789

⌚️2.2 modificationstartup.cmd

insert image description here

set MODE="cluster"

change into

set MODE="standalone"

insert image description here

Standalone startup, otherwise cluster startup

Startup command (standalone represents stand-alone mode operation, non-cluster mode):

⌚️Step 3. Start nacos

After decompression, enter the bin path and run startup.cmd

insert image description here
If this page appears, the operation is successful

insert image description here

⌚️Step 4. View the console page

http://localhost:8848/nacos

insert image description here

The default username and password arenacos

insert image description here

Now that nacos has been successfully installed and started on your computer, let me introduce the nacos console page

⏰nacos management page introduction

⏰Namespace (namespace)

insert image description here

Similar to spring profiles, it isolates development, testing, and production environments

⏰Cluster management

insert image description here

The place to manage and view nacos cluster nodes

⏰Privilege management

You can modify the password of the account and create a new user (not very useful)

insert image description here

⏰Service Management

As an important module of the registration center, nacos can manage all services

insert image description here

⏰Configuration management

nacos is the place where config manages all configuration files in a unified manner

insert image description here
Each configuration file is separated by a namespace

insert image description here

Can manage historical configuration file versions

insert image description here

The above configurations are persisted in the data directory of the nacos folder. If you need to build a nacos cluster or persist data in mysql, you can refer to the following configuration

⏳Persist nacos to mysql

mysql-schema⏳The first step is to execute the sql file under the conf folder

insert image description here

⏳The second step, modify application.propertiesthe file

insert image description here

as follows

insert image description here
Then start nacos

insert image description here
You can see that the data has been persisted in mysql

insert image description here
If you want to build a nacos cluster, you can refer to the following configuration

⌛️nacos cluster construction

⌛️The first step is to prepare the prerequisites for the cluster

Prepare three servers, or one server with three different ports, but their ports should be spaced apart and cannot be continuous, otherwise an error will be reported

Error creating bean with name ‘grpcSdkServer‘

Because the gRPC communication method was added after nacos2.0, two ports need to be added. The new ports are automatically generated with a certain offset on the basis of the configuration winner port (server.port). It will be offset by 1000, 1001 displacement. For example, 8848 needs to use two ports 9848 and 9849, so you can configure their ports as8848,8838,8828

Then follow the above method to let them connect to the same database to realize cluster data sharing, such as configuration files

⌛️The second step, copy the cluster.conf.example file under conf as cluster.conf

Write the following data

insert image description here
The steps of the three servers are the same, and the content of the cluster.conf file is also the same

⌛️The third step, if you used a stand-alone startup before, you need to change the mode of the start.sh file back, if not, ignore it

⌛️The fourth step, use nginx to proxy three servers


http {
    
    
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    
    upstream nacos-cluster {
    
    
        server 192.168.0.116:8848;
        server 192.168.0.115:8848;
        server 192.168.0.117:8848;
    }


    server {
    
    
        listen       81;
        server_name  localhost;

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


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
    
    
            root   html;
        }

       
    }

}

Then access localhost:81/nacosthe address to access the nacos cluster

insert image description here

Nacos official website address: https://nacos.io/zh-cn/docs/quick-start.html

Guess you like

Origin blog.csdn.net/csdnerM/article/details/129530053