Windows installs the Nacos service, which you can view[ Learning notes of SpringCloudAlibaba [2] building Nacos service in Windows]
premise
1. Operating system CentOs7
1.1. Install Docker on centos7[ Install Docker]
Mode 1
Only Nacos server is deployed, and monitoring components such as prometheus/grafana are not used
edition
View the Docker version of Nacos: https://hub.docker.com/r/nacos/nacos-server/tags
docker search nacos #Search for images of nacos
Download
docker pull nacos/nacos-server:v2.0.4 #The stable version is recommended. If the version is not specified, it is the latest version (corresponding to the v2.0.4 version of nacos)
docker images #View all image packages in docker
Run
After downloading the image package, you have to start the image package. Here are some more words to introduce the meaning of parameters, so as not to follow the steps
-v: Directory of a container: map a directory on centos (i.e. mount)
-p: External access port: internally mapped port (i.e. port)
-e: Environment variable settings
-d: Background operation
– Name: the name of the container
– restart: restart policy
docker run -d -e MODE=standalone -v /nacos/logs:/home/nacos/logs -p 8848:8848 --name nacos --restart=always nacos/nacos-server:v2.0.4
Or this command will work
docker run --env MODE=standalone --restart=always --name nacos -d -p 8848:8848 nacos/nacos-server:v2.0.4
Run successfully!
Log
How to view logs?
Note: 10m is a time parameter, which is set according to the time you want to see
docker ps #View containers that have been started docker logs --since 10m nacos Container for id #View the output log of the specified container
One of the addresses drawn by the horizontal line is the ip address in the docker container. This is very important (the external connection uses the server ip + external mapping port, and the internal connection (a single service is also deployed on docker) uses the ip address of a container in the docker container and its internal port number
Effect
User name / password: nacos/nacos -- default
Modify the configuration of Nacos
How to modify the configuration of Nacos in Docker? Very simple, direct operation ~
docker ps #Check the started container and find the container id of nacso docker exec -it nacos Container for id /bin/bash #Enter the container of nacso exit #Exit container
The following is how to change the Nacos configuration. Only the application Properties.
Mode 2
Deployed through docker compose, including prometheus/grafana and other monitoring components
Reference documents: https://nacos.io/zh-cn/docs/quick-start-docker.html
Premise
Install git and docker-compose
Clone project git clone https://github.com/nacos-group/nacos-docker.git cd nacos-docker standalone mode Derby docker-compose -f example/standalone-derby.yaml up standalone mode MySQL -- If you want to use MySQL5.7 docker-compose -f example/standalone-mysql-5.7.yaml up -- If you want to use MySQL8 docker-compose -f example/standalone-mysql-8.yaml up Cluster mode docker-compose -f example/cluster-hostname.yaml up
No effect display for network reasons!
Mode 3
As a supplement to method 1, it is deployed by using the configuration file mount method
Mount directory
mkdir -p /home/nacos/logs/ #New logs directory mkdir -p /home/nacos/init.d/ vim /home/nacos/init.d/custom.properties #Modify profile
Add the following parameters:
server.contextPath=/nacos server.servlet.contextPath=/nacos server.port=8848 spring.datasource.platform=mysql # Database configuration db.num=1 db.url.0=jdbc:mysql://xx.xx.xx.x:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true db.user=user db.password=pass nacos.cmdb.dumpTaskInterval=3600 nacos.cmdb.eventTaskInterval=10 nacos.cmdb.labelTaskInterval=300 nacos.cmdb.loadDataAtStart=false management.metrics.export.elastic.enabled=false management.metrics.export.influx.enabled=false server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/** nacos.naming.distro.taskDispatchThreadCount=1 nacos.naming.distro.taskDispatchPeriod=200 nacos.naming.distro.batchSyncKeyCount=1000 nacos.naming.distro.initDataRatio=0.9 nacos.naming.distro.syncRetryDelay=5000 nacos.naming.data.warmup=true nacos.naming.expireInstance=true
Start container
docker run \ --name nacos -d \ -p 8848:8848 \ --privileged=true \ --restart=always \ -e JVM_XMS=256m \ -e JVM_XMX=256m \ -e MODE=standalone \ -e PREFER_HOST_MODE=hostname \ -v /mydata/nacos/logs:/home/nacos/logs \ -v /mydata/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \ nacos/nacos-server
Effect