Nacos series docker installation stand-alone Nacos service

I summary

In 2018, alibaba will open source Nacos. Nacos is the name after open source. It is based on the core code integration of Alibaba's internal Configserver (Registration Center), Diamond (persistent configuration center) and Vipserver (Registration Center similar to Configserver, which provides routing information). The goal is to build the world's most powerful service registration and configuration center.

This article simply deploys a nacos service to get an intuitive understanding.

II Deployment steps

Since it is installed using docker, the use of docker is not introduced in this article. You can refer to: docker usage

2.1 download demo file

nacos provides demo configuration files on github. Download them first:

#clone down from github
git clone
#Enter file directory
cd nacos-docker

There are the following documents:

The key is the env and example files.

2.2 installation and startup

Start command:

#Note that the last - d indicates background startup. You may not be able to access the console after startup without - d
docker-compose -f example/standalone-mysql-5.7.yaml up -d

Because nacos itself has no storage function, it needs to be used with the database. Here we use mysql5 7. Mysql derby.5 is supported by default 7. mysql8, the corresponding yaml configuration file is in the example path.

example file description:

  • standalone-mysql-5.7.yaml: stand alone mode, using mysql5 7 database
  • standalone-mysql-8.yaml: stand alone mode, using mysql8 database
  • standalone-derby.yaml: stand alone mode, using embedded Derby database
  • cluster-hostname.yaml: cluster mode, using mysql5 7 database
  • cluster-embedded.yaml: cluster mode, using embedded derby database

It should be noted before startup that MySQL uses port 3306 by default. If MySQL is installed in your server and 3306 is occupied, the startup will fail. At this time, you can modify the nacos configuration and use your locally installed mysql,
You can also directly modify the mapping port of mysql, and then start it,
Modify standalone-mysql-5.7 as follows: MySQL ports in yaml file:

version: "2"
    image: nacos/nacos-server:${NACOS_VERSION}
    container_name: nacos-standalone-mysql
      - ../env/nacos-standlone-mysql.env
      - ./standalone-logs/:/home/nacos/logs
      - ./init.d/
      - "8848:8848"
      - "9848:9848"
      - "9555:9555"
      - mysql
    restart: on-failure
    container_name: mysql
    image: nacos/nacos-mysql:5.7
      - ../env/mysql.env
      - ./mysql:/var/lib/mysql
    # Change the mysql port to 3307 to avoid conflicts
      - "3307:3306"
#  prometheus:
#    container_name: prometheus
#    image: prom/prometheus:latest
#    volumes:
#      - ./prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
#    ports:
#      - "9090:9090"
#    depends_on:
#      - nacos
#    restart: on-failure
#  grafana:
#    container_name: grafana
#    image: grafana/grafana:latest
#    ports:
#      - 3000:3000
#    restart: on-failure

View container

docker ps

2.3 Nacos console

Default username / password: nacos/nacos

After login, the interface is as follows:

Because it is a registration center + configuration center, the main menu is configuration management + service management.

By default, they are all empty. We can use the following commands to simply register and add configuration.

2.4 service registration and discovery

# Register a service randomly. Parameters: service name, ip, port
curl -X POST ''

Then check the service list and find the successful registration:

2.5 configuration release and acquisition

Add configuration:
Add any configuration:
It mainly configures data id, Group and content:

However, to view this data in mysql database:

You can also call the interface:

# Parameters: dataId, group, content
curl -X POST ""

Let's stop here first.

reference resources:

Keywords: Docker Nacos

Added by exxx on Tue, 01 Feb 2022 14:38:02 +0200