This commit is contained in:
pader 2022-01-29 14:52:21 +08:00
parent 4f9cdce70b
commit d1ba05a38b
3 changed files with 36 additions and 76 deletions

View File

@ -12,14 +12,15 @@ This project contains a Docker image meant to facilitate the deployment of [Naco
* env: Environment variable file for compose yaml * env: Environment variable file for compose yaml
* example: Docker compose example for Nacos server * example: Docker compose example for Nacos server
## Precautions ## Precautions
* The **database master-slave image** has been removed, after the latest `nacos/nacos-server:latest` image. For specific reasons, refer to [Removing the Master-Slave Image Configuration](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE) * The **database master-slave image** has been removed, after the latest `nacos/nacos-server:latest` image. For specific
* Since Nacos 1.3.1 version, the database storage has been upgraded to 8.0, and it is backward compatible reasons, refer
* If you use a custom database, you need to initialize the [database script](https://github.com/alibaba/nacos/blob/develop/distribution/conf/nacos-mysql.sql) yourself for the first time. to [Removing the Master-Slave Image Configuration](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE)
* Since Nacos 1.3.1 version, the database storage has been upgraded to 8.0, and it is backward compatible
* If you use a custom database, you need to initialize
the [database script](https://github.com/alibaba/nacos/blob/develop/distribution/conf/nacos-mysql.sql) yourself for
the first time.
## Quick Start ## Quick Start
@ -27,11 +28,11 @@ This project contains a Docker image meant to facilitate the deployment of [Naco
docker run --name nacos-quick -e MODE=standalone -p 8848:8848 -p 9848:9848 -d nacos/nacos-server:2.0.2 docker run --name nacos-quick -e MODE=standalone -p 8848:8848 -p 9848:9848 -d nacos/nacos-server:2.0.2
``` ```
## Advanced Usage ## Advanced Usage
* Tips: You can change the version of the Nacos image in the compose file from the following configuration. * Tips: You can change the version of the Nacos image in the compose file from the following configuration.
`example/.env` `example/.env`
```dotenv ```dotenv
NACOS_VERSION=2.0.2 NACOS_VERSION=2.0.2
``` ```
@ -93,15 +94,12 @@ Run the following command
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test" curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"
``` ```
* Open the Nacos console in your browser * Open the Nacos console in your browser
linkhttp://127.0.0.1:8848/nacos/ linkhttp://127.0.0.1:8848/nacos/
## Common property configuration
## Common property configuration
| name | description | option | | name | description | option |
| ----------------------------- | -------------------------------------- | -------------------------------------- | | ----------------------------- | -------------------------------------- | -------------------------------------- |
@ -117,7 +115,8 @@ Run the following command
| MYSQL_SERVICE_USER | username of database | | | MYSQL_SERVICE_USER | username of database | |
| MYSQL_SERVICE_PASSWORD | password of database | | | MYSQL_SERVICE_PASSWORD | password of database | |
| MYSQL_DATABASE_NUM | It indicates the number of database | default :**1** | | MYSQL_DATABASE_NUM | It indicates the number of database | default :**1** |
| MYSQL_SERVICE_DB_PARAM | Database url parameter | default : **characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false** | | MYSQL_SERVICE_DB_PARAM | Database url parameter | default : **
characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false** |
| JVM_XMS | -Xms | default :1g | | JVM_XMS | -Xms | default :1g |
| JVM_XMX | -Xmx | default :1g | | JVM_XMX | -Xmx | default :1g |
| JVM_XMN | -Xmn | default :512m | | JVM_XMN | -Xmn | default :512m |
@ -138,13 +137,12 @@ Run the following command
| NACOS_AUTH_IDENTITY_VALUE | nacos.core.auth.server.identity.value | default : security | | NACOS_AUTH_IDENTITY_VALUE | nacos.core.auth.server.identity.value | default : security |
| NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` | | NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` |
~~# Advanced configuration~~
~~If the above property configuration list does not meet your requirements, you can mount the `custom.properties` file
into the `/home/nacos/init.d/` directory of the container, where the spring properties can be configured, and the
priority is higher than `application.properties` file~~
## Advanced configuration
If the above property configuration list does not meet your requirements, you can mount the `custom.properties` file into the `/home/nacos/init.d/` directory of the container, where the spring properties can be configured, and the priority is higher than `application.properties` file
Reference example: [cluster-hostname.yaml](/example/cluster-hostname.yaml)
## Nacos + Grafana + Prometheus ## Nacos + Grafana + Prometheus
Usage reference[Nacos monitor-guide](https://nacos.io/zh-cn/docs/monitor-guide.html) Usage reference[Nacos monitor-guide](https://nacos.io/zh-cn/docs/monitor-guide.html)

View File

@ -2,31 +2,24 @@
本项目是 [Nacos](https://github.com/alibaba/nacos) Server的docker镜像的build源码,以及Nacos server 在docker的单机和集群的运行例子. 本项目是 [Nacos](https://github.com/alibaba/nacos) Server的docker镜像的build源码,以及Nacos server 在docker的单机和集群的运行例子.
## 项目目录 ## 项目目录
* buildnacos 镜像制作的源码 * buildnacos 镜像制作的源码
* env: docker compose 环境变量文件 * env: docker compose 环境变量文件
* example: docker-compose编排例子 * example: docker-compose编排例子
## 运行环境 ## 运行环境
* [Docker](https://www.docker.com/) * [Docker](https://www.docker.com/)
### 注意事项 ### 注意事项
* 从最新的nacos:nacos-server/latest 镜像以后,移除了数据库主从镜像,具体原因请参考[移除主从镜像配置](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE) * 从最新的nacos:nacos-server/latest
镜像以后,移除了数据库主从镜像,具体原因请参考[移除主从镜像配置](https://github.com/nacos-group/nacos-docker/wiki/%E7%A7%BB%E9%99%A4%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B8%BB%E4%BB%8E%E9%95%9C%E5%83%8F%E9%85%8D%E7%BD%AE)
* 从Nacos 1.3.1版本开始,数据库存储已经升级到8.0, 并且它向下兼容 * 从Nacos 1.3.1版本开始,数据库存储已经升级到8.0, 并且它向下兼容
* 例子演示中使用的数据库是为了方便定制了官方Mysql镜像, 自动初始化的数据库脚本. * 例子演示中使用的数据库是为了方便定制了官方Mysql镜像, 自动初始化的数据库脚本.
* 如果你使用自定义数据库, 第一次启动Nacos前需要手动初始化 [数据库脚本](https://github.com/alibaba/nacos/blob/develop/distribution/conf/nacos-mysql.sql) . * 如果你使用自定义数据库,
第一次启动Nacos前需要手动初始化 [数据库脚本](https://github.com/alibaba/nacos/blob/develop/distribution/conf/nacos-mysql.sql) .
## 快速开始 ## 快速开始
@ -87,7 +80,6 @@
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test" curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"
``` ```
* 打开浏览器 * 打开浏览器
@ -133,31 +125,29 @@
* 访问控制台 * 访问控制台
浏览器访问http://127.0.0.1:8848/nacos/ 浏览器访问http://127.0.0.1:8848/nacos/
## 属性配置列表 ## 属性配置列表
| 属性名称 | 描述 | 选项 | | 属性名称 | 描述 | 选项 |
| --------------------------------- | ------------------------------------------------------------ | ----------------------------------- | | --------------------------------- | ------------------------------------------------------------ | ----------------------------------- |
| MODE | 系统启动方式: 集群/单机 | cluster/standalone默认 **cluster** | | MODE | 系统启动方式: 集群/单机 | cluster/standalone默认 **
cluster** |
| NACOS_SERVERS | 集群地址 | p1:port1空格ip2:port2 空格ip3:port3 | | NACOS_SERVERS | 集群地址 | p1:port1空格ip2:port2 空格ip3:port3 |
| PREFER_HOST_MODE | 支持IP还是域名模式 | hostname/ip 默认 **ip** | | PREFER_HOST_MODE | 支持IP还是域名模式 | hostname/ip 默认 **
| NACOS_SERVER_PORT | Nacos 运行端口 | 默认 **8848** | ip** |
| NACOS_SERVER_PORT | Nacos 运行端口 | 默认 **
8848** |
| NACOS_SERVER_IP | 多网卡模式下可以指定IP | | | NACOS_SERVER_IP | 多网卡模式下可以指定IP | |
| SPRING_DATASOURCE_PLATFORM | 单机模式下支持MYSQL数据库 | mysql / 空 默认:空 | | SPRING_DATASOURCE_PLATFORM | 单机模式下支持MYSQL数据库 | mysql / 空 默认:空 |
| MYSQL_SERVICE_HOST | 数据库 连接地址 | | | MYSQL_SERVICE_HOST | 数据库 连接地址 | |
| MYSQL_SERVICE_PORT | 数据库端口 | 默认 : **3306** | | MYSQL_SERVICE_PORT | 数据库端口 | 默认 : **3306** |
| MYSQL_SERVICE_DB_NAME | 数据库库名 | | | MYSQL_SERVICE_DB_NAME | 数据库库名 | |
| MYSQL_SERVICE_USER | 数据库用户名 | | | MYSQL_SERVICE_USER | 数据库用户名 | |
| MYSQL_SERVICE_PASSWORD | 数据库用户密码 | | | MYSQL_SERVICE_PASSWORD | 数据库用户密码 | |
| MYSQL_SERVICE_DB_PARAM | 数据库连接参数 | default : **characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false** | | MYSQL_SERVICE_DB_PARAM | 数据库连接参数 | default : **
| MYSQL_DATABASE_NUM | It indicates the number of database | 默认 :**1** | characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false** |
| MYSQL_DATABASE_NUM | It indicates the number of database | 默认 :**
1** |
| JVM_XMS | -Xms | 默认 :1g | | JVM_XMS | -Xms | 默认 :1g |
| JVM_XMX | -Xmx | 默认 :1g | | JVM_XMX | -Xmx | 默认 :1g |
| JVM_XMN | -Xmn | 默认 :512m | | JVM_XMN | -Xmn | 默认 :512m |
@ -178,19 +168,10 @@
| NACOS_AUTH_IDENTITY_VALUE | nacos.core.auth.server.identity.value | default : security | | NACOS_AUTH_IDENTITY_VALUE | nacos.core.auth.server.identity.value | default : security |
| NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` | | NACOS_SECURITY_IGNORE_URLS | nacos.security.ignore.urls | default : `/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**` |
~~## 高级配置~~
~~如果上面的属性列表无法满足你的需求时,可以挂载`custom.properties`到`/home/nacos/init.d/` 目录,然后在里面像使用Spring Boot的`application.properties`
文件一样配置属性, 并且这个文件配置的属性**优先级高于application.properties**~~
## 高级配置
如果上面的属性列表无法满足你的需求时,可以挂载`custom.properties`到`/home/nacos/init.d/` 目录,然后在里面像使用Spring Boot的`application.properties`文件一样配置属性, 并且这个文件配置的属性**优先级高于application.properties**
参考例子: [cluster-hostname.yaml](/example/cluster-hostname)
## Nacos + Grafana + Prometheus ## Nacos + Grafana + Prometheus

View File

@ -1,19 +0,0 @@
#spring.security.enabled=false
#management.security=false
#security.basic.enabled=false
#nacos.security.ignore.urls=/**
#management.metrics.export.elastic.host=http://localhost:9200
# metrics for prometheus
management.endpoints.web.exposure.include=*
# metrics for elastic search
#management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200
# metrics for influx
#management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true