├── .idea └── inspectionProfiles │ └── Project_Default.xml ├── README.md ├── build ├── Dockerfile └── nacos │ ├── LICENSE │ ├── NOTICE │ ├── bin │ └── docker-startup.sh │ ├── conf │ ├── application.properties │ ├── nacos-logback.xml │ └── schema.sql │ └── target │ └── nacos-server.jar ├── changlog ├── cluster-hostname.yaml ├── cluster-ip.yaml ├── env ├── mysql-common.env ├── mysql-master.env ├── mysql-slave.env ├── nacos-hostname.env └── nacos-ip.env └── standalone.yaml /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### 简介 2 | 3 | 本项目是 [Nacos](https://github.com/alibaba/nacos) Server的docker镜像的build源码,以及Nacos server 在docker的单机和集群的运行例子. 4 | 5 | 6 | 7 | ### 项目目录 8 | 9 | * build:nacos 镜像制作的源码,目前里面存放的是最新0.5.0的jar 10 | * env: 镜像运行环境变量文件 11 | * logs: nacos 运行日志挂载的卷 12 | * mysql: docker mysql-master 运行挂载卷 13 | 14 | ### 运行环境 15 | 16 | * [Docker](https://www.docker.com/) 17 | 18 | 19 | 20 | ### 注意事项 21 | > nacos 0.5.0 开始才支持集群配置域名解析,所以需要集群使用需要注意以下事项 22 | 1. Nacos server 低于0.5.0版本,执行docker-compose 指定**cluster-ip.yaml**运行. 23 | 2. Nacos server 0.5.0或者更高版本集群,执行docker-compose 指定**cluster-hostname.yaml**或者**cluster-ip.yaml**运行都可以 24 | 25 | 26 | 27 | ### 使用方法 28 | 29 | 打开命令窗口执行: 30 | 31 | * Clone 项目 并且进入项目根目录 32 | 33 | ```powershell 34 | git clone https://github.com/paderlol/nacos-docker.git 35 | cd nacos-docker 36 | ``` 37 | 38 | 39 | * 单机 40 | 41 | ```powershell 42 | docker-compose -f standalone.yaml up 43 | ``` 44 | 45 | * 集群 46 | 47 | ```powershell 48 | docker-compose -f cluster-hostname.yaml up 49 | ``` 50 | 51 | 52 | * 注册服务 53 | 54 | ```powershell 55 | curl -X PUT 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080' 56 | ``` 57 | 58 | * 注册配置 59 | 60 | ```powershell 61 | curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=helloWorld" 62 | ``` 63 | 64 | * 访问控制台 65 | 66 | 浏览器访问:http://127.0.0.1:8848/nacos/ 67 | -------------------------------------------------------------------------------- /build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7.5.1804 2 | MAINTAINER pader "huangmnlove@163.com" 3 | 4 | # set environment 5 | ENV MODE="cluster" \ 6 | PREFER_HOST_MODE="ip"\ 7 | BASE_DIR="/home/nacos" \ 8 | CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \ 9 | CLUSTER_CONF="/home/nacos/conf/cluster.conf" \ 10 | JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" \ 11 | JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" 12 | 13 | RUN set -x \ 14 | && yum update -y \ 15 | && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc tzdata vim libcurl\ 16 | && yum autoremove -y wget \ 17 | && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ 18 | && yum clean all 19 | 20 | WORKDIR /home/nacos 21 | 22 | COPY nacos $BASE_DIR 23 | 24 | 25 | # set startup log dir 26 | RUN mkdir -p logs \ 27 | && cd logs \ 28 | && touch start.out \ 29 | && ln -sf /dev/stdout $BASE_DIR/logs/start.out \ 30 | && ln -sf /dev/stderr $BASE_DIR/logs/start.out 31 | RUN chmod +x bin/docker-startup.sh 32 | 33 | EXPOSE 8848 34 | ENTRYPOINT ["bin/docker-startup.sh"] -------------------------------------------------------------------------------- /build/nacos/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (properties) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | ------ 204 | This product has a bundle logback, which is available under the EPL v1.0 License. 205 | The source code of logback can be found at https://github.com/qos-ch/logback. 206 | 207 | Logback LICENSE 208 | --------------- 209 | 210 | Logback: the reliable, generic, fast and flexible logging framework. 211 | Copyright (C) 1999-2015, QOS.ch. All rights reserved. 212 | 213 | This program and the accompanying materials are dual-licensed under 214 | either the terms of the Eclipse Public License v1.0 as published by 215 | the Eclipse Foundation 216 | 217 | or (per the licensee's choosing) 218 | 219 | under the terms of the GNU Lesser General Public License version 2.1 220 | as published by the Free Software Foundation. 221 | 222 | ------ 223 | This product has a bundle slf4j, which is available under the MIT License. 224 | The source code of slf4j can be found at https://github.com/qos-ch/slf4j. 225 | 226 | Copyright (c) 2004-2017 QOS.ch 227 | All rights reserved. 228 | 229 | Permission is hereby granted, free of charge, to any person obtaining 230 | a copy of this software and associated documentation files (the 231 | "Software"), to deal in the Software without restriction, including 232 | without limitation the rights to use, copy, modify, merge, publish, 233 | distribute, sublicense, and/or sell copies of the Software, and to 234 | permit persons to whom the Software is furnished to do so, subject to 235 | the following conditions: 236 | 237 | The above copyright notice and this permission notice shall be 238 | included in all copies or substantial portions of the Software. 239 | 240 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 241 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 242 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 243 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 244 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 245 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 246 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 247 | 248 | ------ 249 | This product has a bundle fastjson, which is available under the ASL2 License. 250 | The source code of fastjson can be found at https://github.com/alibaba/fastjson. 251 | 252 | Copyright 1999-2016 Alibaba Group Holding Ltd. 253 | 254 | Licensed under the Apache License, Version 2.0 (the "License"); 255 | you may not use this file except in compliance with the License. 256 | You may obtain a copy of the License at 257 | 258 | http://www.apache.org/licenses/LICENSE-2.0 259 | 260 | Unless required by applicable law or agreed to in writing, software 261 | distributed under the License is distributed on an "AS IS" BASIS, 262 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 263 | See the License for the specific language governing permissions and 264 | limitations under the License. 265 | 266 | ------ 267 | This product has a bundle javassist, which is available under the ASL2 License. 268 | The source code of javassist can be found at https://github.com/jboss-javassist/javassist. 269 | 270 | Copyright (C) 1999- by Shigeru Chiba, All rights reserved. 271 | 272 | Javassist (JAVA programming ASSISTant) makes Java bytecode manipulation simple. 273 | It is a class library for editing bytecodes in Java; it enables Java programs to define a new class 274 | at runtime and to modify a class file when the JVM loads it. Unlike other similar bytecode editors, 275 | Javassist provides two levels of API: source level and bytecode level. If the users use the source- level API, 276 | they can edit a class file without knowledge of the specifications of the Java bytecode. 277 | The whole API is designed with only the vocabulary of the Java language. 278 | You can even specify inserted bytecode in the form of source text; Javassist compiles it on the fly. 279 | On the other hand, the bytecode-level API allows the users to directly edit a class file as other editors. 280 | 281 | This software is distributed under the Mozilla Public License Version 1.1, 282 | the GNU Lesser General Public License Version 2.1 or later, or the Apache License Version 2.0. 283 | 284 | ------ 285 | This product has a bundle jna, which is available under the ASL2 License. 286 | The source code of jna can be found at https://github.com/java-native-access/jna. 287 | 288 | This copy of JNA is licensed under the 289 | Apache (Software) License, version 2.0 ("the License"). 290 | See the License for details about distribution rights, and the 291 | specific rights regarding derivate works. 292 | 293 | You may obtain a copy of the License at: 294 | 295 | http://www.apache.org/licenses/ 296 | 297 | A copy is also included in the downloadable source code package 298 | containing JNA, in file "AL2.0", under the same directory 299 | as this file. 300 | ------ 301 | This product has a bundle guava, which is available under the ASL2 License. 302 | The source code of guava can be found at https://github.com/google/guava. 303 | 304 | Copyright (C) 2007 The Guava authors 305 | 306 | Licensed under the Apache License, Version 2.0 (the "License"); 307 | you may not use this file except in compliance with the License. 308 | You may obtain a copy of the License at 309 | 310 | http://www.apache.org/licenses/LICENSE-2.0 311 | 312 | Unless required by applicable law or agreed to in writing, software 313 | distributed under the License is distributed on an "AS IS" BASIS, 314 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 315 | See the License for the specific language governing permissions and 316 | limitations under the License. 317 | ------ 318 | This product has a bundle OpenMessaging, which is available under the ASL2 License. 319 | The source code of OpenMessaging can be found at https://github.com/openmessaging/openmessaging. 320 | 321 | Copyright (C) 2017 The OpenMessaging authors. 322 | 323 | Licensed under the Apache License, Version 2.0 (the "License"); 324 | you may not use this file except in compliance with the License. 325 | You may obtain a copy of the License at 326 | 327 | http://www.apache.org/licenses/LICENSE-2.0 328 | 329 | Unless required by applicable law or agreed to in writing, software 330 | distributed under the License is distributed on an "AS IS" BASIS, 331 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 332 | See the License for the specific language governing permissions and 333 | limitations under the License. 334 | 335 | -------------------------------------------------------------------------------- /build/nacos/NOTICE: -------------------------------------------------------------------------------- 1 | Nacos 2 | Copyright 2018-2019 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Alibaba MiddleWare Group. 6 | 7 | ------ 8 | This product has a bundle netty: 9 | The Spring oot Project 10 | ================= 11 | 12 | Please visit the Netty web site for more information: 13 | 14 | * http://netty.io/ 15 | 16 | Copyright 2014 The Netty Project 17 | 18 | The Netty Project licenses this file to you under the Apache License, 19 | version 2.0 (the "License"); you may not use this file except in compliance 20 | with the License. You may obtain a copy of the License at: 21 | 22 | http://www.apache.org/licenses/LICENSE-2.0 23 | 24 | Unless required by applicable law or agreed to in writing, software 25 | distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 26 | WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 27 | License for the specific language governing permissions and limitations 28 | under the License. 29 | 30 | Also, please refer to each LICENSE..txt file, which is located in 31 | the 'license' directory of the distribution file, for the license terms of the 32 | components that this product depends on. 33 | 34 | ------ 35 | This product has a bundle commons-lang, which includes software from the Spring Framework, 36 | under the Apache License 2.0 (see: StringUtils.containsWhitespace()) -------------------------------------------------------------------------------- /build/nacos/bin/docker-startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 1999-2018 Alibaba Group Holding Ltd. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | export DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/" 16 | export CUSTOM_SEARCH_LOCATIONS=${DEFAULT_SEARCH_LOCATIONS},file:${BASE_DIR}/conf/ 17 | 18 | function print_servers(){ 19 | for server in ${NACOS_SERVERS}; do 20 | echo "$server" >> "$CLUSTER_CONF" 21 | done 22 | } 23 | #=========================================================================================== 24 | # JVM Configuration 25 | #=========================================================================================== 26 | if [[ "${MODE}" == "standalone" ]]; then 27 | 28 | JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -Xmn256m" 29 | JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true" 30 | else 31 | 32 | JAVA_OPT="${JAVA_OPT} -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" 33 | JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof" 34 | JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages" 35 | print_servers 36 | fi 37 | 38 | JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p') 39 | if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then 40 | JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400" 41 | else 42 | JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M" 43 | fi 44 | 45 | if [[ "${PREFER_HOST_MODE}" == "hostname" ]]; then 46 | JAVA_OPT="${JAVA_OPT} -Dnacos.preferHostnameOverIp=true" 47 | fi 48 | 49 | JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}" 50 | JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/nacos-server.jar" 51 | JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}" 52 | JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}" 53 | JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml" 54 | 55 | echo "nacos is starting,you can check the ${BASE_DIR}/logs/start.out" 56 | echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 & 57 | nohup $JAVA ${JAVA_OPT} > ${BASE_DIR}/logs/start.out 2>&1 < /dev/null 58 | -------------------------------------------------------------------------------- /build/nacos/conf/application.properties: -------------------------------------------------------------------------------- 1 | # spring 2 | server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos} 3 | server.port=${NACOS_SERVER_PORT:8848} 4 | 5 | db.num=2 6 | db.url.0=jdbc:mysql://${MYSQL_MASTER_SERVICE_HOST}:${MYSQL_MASTER_SERVICE_PORT:3306}/${MYSQL_MASTER_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true 7 | db.url.1=jdbc:mysql://${MYSQL_SLAVE_SERVICE_HOST}:${MYSQL_SLAVE_SERVICE_PORT:3306}/${MYSQL_MASTER_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true 8 | db.user=${MYSQL_MASTER_SERVICE_USER} 9 | db.password=${MYSQL_MASTER_SERVICE_PASSWORD} 10 | 11 | -------------------------------------------------------------------------------- /build/nacos/conf/nacos-logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | ${nacos.home}/logs/naming-server.log 7 | true 8 | 9 | ${nacos.home}/logs/naming-server.log.%d{yyyy-MM-dd}.%i 10 | 2GB 11 | 15 12 | 7GB 13 | true 14 | 15 | 16 | %date %level %msg%n%n 17 | UTF-8 18 | 19 | 20 | 22 | ${nacos.home}/logs/naming-raft.log 23 | true 24 | 25 | ${nacos.home}/logs/naming-raft.log.%d{yyyy-MM-dd}.%i 26 | 20MB 27 | 15 28 | 128MB 29 | true 30 | 31 | 32 | %date %level %msg%n%n 33 | UTF-8 34 | 35 | 36 | 38 | ${nacos.home}/logs/naming-event.log 39 | true 40 | 41 | ${nacos.home}/logs/naming-event.log.%d{yyyy-MM-dd}.%i 42 | 20MB 43 | 15 44 | 128MB 45 | true 46 | 47 | 48 | %date %level %msg%n%n 49 | UTF-8 50 | 51 | 52 | 54 | ${nacos.home}/logs/naming-push.log 55 | true 56 | 57 | ${nacos.home}/logs/naming-push.log.%d{yyyy-MM-dd}.%i 58 | 20MB 59 | 15 60 | 128MB 61 | true 62 | 63 | 64 | %date %level %msg%n%n 65 | UTF-8 66 | 67 | 68 | 70 | ${nacos.home}/logs/naming-rt.log 71 | true 72 | 73 | ${nacos.home}/logs/naming-rt.log.%d{yyyy-MM-dd}.%i 74 | 1GB 75 | 15 76 | 3GB 77 | true 78 | 79 | 80 | %msg%n 81 | UTF-8 82 | 83 | 84 | 85 | 87 | ${nacos.home}/logs/naming-performance.log 88 | true 89 | 90 | ${nacos.home}/logs/naming-performance.log.%d{yyyy-MM-dd}.%i 91 | 50MB 92 | 15 93 | 512MB 94 | true 95 | 96 | 97 | %date %level %msg%n%n 98 | UTF-8 99 | 100 | 101 | 102 | 104 | ${nacos.home}/logs/naming-router.log 105 | true 106 | 107 | ${nacos.home}/logs/naming-router.log.%d{yyyy-MM-dd}.%i 108 | 2GB 109 | 15 110 | 7GB 111 | true 112 | 113 | 114 | %date|%msg%n 115 | UTF-8 116 | 117 | 118 | 119 | 121 | ${nacos.home}/logs/naming-cache.log 122 | true 123 | 124 | ${nacos.home}/logs/naming-cache.log.%d{yyyy-MM-dd}.%i 125 | 1GB 126 | 15 127 | 3GB 128 | true 129 | 130 | 131 | %date|%msg%n 132 | UTF-8 133 | 134 | 135 | 136 | 138 | ${nacos.home}/logs/naming-device.log 139 | true 140 | 141 | ${nacos.home}/logs/naming-device.log.%d{yyyy-MM-dd}.%i 142 | 2GB 143 | 15 144 | 7GB 145 | true 146 | 147 | 148 | %date|%msg%n 149 | UTF-8 150 | 151 | 152 | 153 | 155 | ${nacos.home}/logs/naming-tag.log 156 | true 157 | 158 | ${nacos.home}/logs/naming-tag.log.%d{yyyy-MM-dd}.%i 159 | 1GB 160 | 15 161 | 3GB 162 | true 163 | 164 | 165 | %date %level %msg%n%n 166 | UTF-8 167 | 168 | 169 | 170 | 172 | ${nacos.home}/logs/naming-tenant.log 173 | true 174 | 175 | ${nacos.home}/logs/naming-tenant.log.%d{yyyy-MM-dd}.%i 176 | 1GB 177 | 15 178 | 3GB 179 | true 180 | 181 | 182 | %date %level %msg%n%n 183 | UTF-8 184 | 185 | 186 | 187 | 189 | ${nacos.home}/logs/naming-debug.log 190 | true 191 | 192 | ${nacos.home}/logs/naming-debug.log.%d{yyyy-MM-dd}.%i 193 | 20MB 194 | 15 195 | 128MB 196 | true 197 | 198 | 199 | %date %level %msg%n%n 200 | UTF-8 201 | 202 | 203 | 204 | 205 | 206 | 208 | ${nacos.home}/logs/config-dump.log 209 | true 210 | 211 | ${nacos.home}/logs/config-dump.log.%d{yyyy-MM-dd}.%i 212 | 2GB 213 | 15 214 | 7GB 215 | true 216 | 217 | 218 | %date %level %msg%n%n 219 | GBK 220 | 221 | 222 | 224 | ${nacos.home}/logs/config-pull.log 225 | true 226 | 227 | ${nacos.home}/logs/config-pull.log.%d{yyyy-MM-dd}.%i 228 | 20MB 229 | 15 230 | 128MB 231 | true 232 | 233 | 234 | %date %level %msg%n%n 235 | GBK 236 | 237 | 238 | 240 | ${nacos.home}/logs/config-fatal.log 241 | true 242 | 243 | ${nacos.home}/logs/config-fatal.log.%d{yyyy-MM-dd}.%i 244 | 20MB 245 | 15 246 | 128MB 247 | true 248 | 249 | 250 | %date %level %msg%n%n 251 | GBK 252 | 253 | 254 | 256 | ${nacos.home}/logs/config-memory.log 257 | true 258 | 259 | ${nacos.home}/logs/config-memory.log.%d{yyyy-MM-dd}.%i 260 | 20MB 261 | 15 262 | 128MB 263 | true 264 | 265 | 266 | %date %level %msg%n%n 267 | GBK 268 | 269 | 270 | 272 | ${nacos.home}/logs/config-pull-check.log 273 | true 274 | 275 | ${nacos.home}/logs/config-pull-check.log.%d{yyyy-MM-dd}.%i 276 | 1GB 277 | 15 278 | 3GB 279 | true 280 | 281 | 282 | %msg%n 283 | GBK 284 | 285 | 286 | 287 | 289 | ${nacos.home}/logs/config-acl.log 290 | true 291 | 292 | ${nacos.home}/logs/config-acl.log.%d{yyyy-MM-dd}.%i 293 | 50MB 294 | 15 295 | 512MB 296 | true 297 | 298 | 299 | %date %level %msg%n%n 300 | GBK 301 | 302 | 303 | 304 | 306 | ${nacos.home}/logs/config-client-request.log 307 | true 308 | 309 | ${nacos.home}/logs/config-client-request.log.%d{yyyy-MM-dd}.%i 310 | 2GB 311 | 15 312 | 7GB 313 | true 314 | 315 | 316 | %date|%msg%n 317 | GBK 318 | 319 | 320 | 321 | 323 | ${nacos.home}/logs/config-sdk-request.log 324 | true 325 | 326 | ${nacos.home}/logs/config-sdk-request.log.%d{yyyy-MM-dd}.%i 327 | 1GB 328 | 15 329 | 3GB 330 | true 331 | 332 | 333 | %date|%msg%n 334 | GBK 335 | 336 | 337 | 338 | 340 | ${nacos.home}/logs/config-trace.log 341 | true 342 | 343 | ${nacos.home}/logs/config-trace.log.%d{yyyy-MM-dd}.%i 344 | 2GB 345 | 15 346 | 7GB 347 | true 348 | 349 | 350 | %date|%msg%n 351 | GBK 352 | 353 | 354 | 355 | 357 | ${nacos.home}/logs/config-notify.log 358 | true 359 | 360 | ${nacos.home}/logs/config-notify.log.%d{yyyy-MM-dd}.%i 361 | 1GB 362 | 15 363 | 3GB 364 | true 365 | 366 | 367 | %date %level %msg%n%n 368 | GBK 369 | 370 | 371 | 372 | 374 | ${nacos.home}/logs/config-app.log 375 | true 376 | 377 | ${nacos.home}/logs/config-app.log.%d{yyyy-MM-dd}.%i 378 | 20MB 379 | 15 380 | 128MB 381 | true 382 | 383 | 384 | %date %level %msg%n%n 385 | GBK 386 | 387 | 388 | 389 | 391 | ${nacos.home}/logs/config-server.log 392 | true 393 | 394 | ${nacos.home}/logs/config-server.log.%d{yyyy-MM-dd}.%i 395 | 50MB 396 | 15 397 | 512MB 398 | true 399 | 400 | 401 | %date %level %msg%n%n 402 | GBK 403 | 404 | 405 | 406 | 408 | ${nacos.home}/logs/nacos.log 409 | true 410 | 411 | ${nacos.home}/logs/nacos.log.%d{yyyy-MM-dd}.%i 412 | 50MB 413 | 15 414 | 512MB 415 | true 416 | 417 | 418 | %date %level %msg%n%n 419 | UTF-8 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | -------------------------------------------------------------------------------- /build/nacos/conf/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE SCHEMA nacos AUTHORIZATION nacos; 2 | 3 | CREATE TABLE config_info ( 4 | id bigint NOT NULL generated by default as identity, 5 | data_id varchar(255) NOT NULL, 6 | group_id varchar(128) NOT NULL, 7 | tenant_id varchar(128) default '', 8 | app_name varchar(128), 9 | content LONG VARCHAR NOT NULL, 10 | md5 varchar(32) DEFAULT NULL, 11 | gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 12 | gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 13 | src_user varchar(128) DEFAULT NULL, 14 | src_ip varchar(20) DEFAULT NULL, 15 | c_desc varchar(256) DEFAULT NULL, 16 | c_use varchar(64) DEFAULT NULL, 17 | effect varchar(64) DEFAULT NULL, 18 | type varchar(64) DEFAULT NULL, 19 | c_schema LONG VARCHAR DEFAULT NULL, 20 | constraint configinfo_id_key PRIMARY KEY (id), 21 | constraint uk_configinfo_datagrouptenant UNIQUE (data_id,group_id,tenant_id)); 22 | 23 | CREATE INDEX configinfo_dataid_key_idx ON config_info(data_id); 24 | CREATE INDEX configinfo_groupid_key_idx ON config_info(group_id); 25 | CREATE INDEX configinfo_dataid_group_key_idx ON config_info(data_id, group_id); 26 | 27 | CREATE TABLE his_config_info ( 28 | id bigint NOT NULL, 29 | nid bigint NOT NULL generated by default as identity, 30 | data_id varchar(255) NOT NULL, 31 | group_id varchar(128) NOT NULL, 32 | tenant_id varchar(128) default '', 33 | app_name varchar(128), 34 | content LONG VARCHAR NOT NULL, 35 | md5 varchar(32) DEFAULT NULL, 36 | gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00.000', 37 | gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00.000', 38 | src_user varchar(128), 39 | src_ip varchar(20) DEFAULT NULL, 40 | op_type char(10) DEFAULT NULL, 41 | constraint hisconfiginfo_nid_key PRIMARY KEY (nid)); 42 | 43 | CREATE INDEX hisconfiginfo_dataid_key_idx ON his_config_info(data_id); 44 | CREATE INDEX hisconfiginfo_gmt_create_idx ON his_config_info(gmt_create); 45 | CREATE INDEX hisconfiginfo_gmt_modified_idx ON his_config_info(gmt_modified); 46 | 47 | 48 | CREATE TABLE config_info_beta ( 49 | id bigint NOT NULL generated by default as identity, 50 | data_id varchar(255) NOT NULL, 51 | group_id varchar(128) NOT NULL, 52 | tenant_id varchar(128) default '', 53 | app_name varchar(128), 54 | content LONG VARCHAR NOT NULL, 55 | beta_ips varchar(1024), 56 | md5 varchar(32) DEFAULT NULL, 57 | gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 58 | gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 59 | src_user varchar(128), 60 | src_ip varchar(20) DEFAULT NULL, 61 | constraint configinfobeta_id_key PRIMARY KEY (id), 62 | constraint uk_configinfobeta_datagrouptenant UNIQUE (data_id,group_id,tenant_id)); 63 | 64 | CREATE TABLE config_info_tag ( 65 | id bigint NOT NULL generated by default as identity, 66 | data_id varchar(255) NOT NULL, 67 | group_id varchar(128) NOT NULL, 68 | tenant_id varchar(128) default '', 69 | tag_id varchar(128) NOT NULL, 70 | app_name varchar(128), 71 | content LONG VARCHAR NOT NULL, 72 | md5 varchar(32) DEFAULT NULL, 73 | gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 74 | gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 75 | src_user varchar(128), 76 | src_ip varchar(20) DEFAULT NULL, 77 | constraint configinfotag_id_key PRIMARY KEY (id), 78 | constraint uk_configinfotag_datagrouptenanttag UNIQUE (data_id,group_id,tenant_id,tag_id)); 79 | 80 | CREATE TABLE config_info_aggr ( 81 | id bigint NOT NULL generated by default as identity, 82 | data_id varchar(255) NOT NULL, 83 | group_id varchar(128) NOT NULL, 84 | tenant_id varchar(128) default '', 85 | datum_id varchar(255) NOT NULL, 86 | app_name varchar(128), 87 | content LONG VARCHAR NOT NULL, 88 | gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00', 89 | constraint configinfoaggr_id_key PRIMARY KEY (id), 90 | constraint uk_configinfoaggr_datagrouptenantdatum UNIQUE (data_id,group_id,tenant_id,datum_id)); 91 | 92 | CREATE TABLE app_list ( 93 | id bigint NOT NULL generated by default as identity, 94 | app_name varchar(128) NOT NULL, 95 | is_dynamic_collect_disabled smallint DEFAULT 0, 96 | last_sub_info_collected_time timestamp DEFAULT '1970-01-01 08:00:00.0', 97 | sub_info_lock_owner varchar(128), 98 | sub_info_lock_time timestamp DEFAULT '1970-01-01 08:00:00.0', 99 | constraint applist_id_key PRIMARY KEY (id), 100 | constraint uk_appname UNIQUE (app_name)); 101 | 102 | CREATE TABLE app_configdata_relation_subs ( 103 | id bigint NOT NULL generated by default as identity, 104 | app_name varchar(128) NOT NULL, 105 | data_id varchar(255) NOT NULL, 106 | group_id varchar(128) NOT NULL, 107 | gmt_modified timestamp DEFAULT '2010-05-05 00:00:00', 108 | constraint configdatarelationsubs_id_key PRIMARY KEY (id), 109 | constraint uk_app_sub_config_datagroup UNIQUE (app_name, data_id, group_id)); 110 | 111 | 112 | CREATE TABLE app_configdata_relation_pubs ( 113 | id bigint NOT NULL generated by default as identity, 114 | app_name varchar(128) NOT NULL, 115 | data_id varchar(255) NOT NULL, 116 | group_id varchar(128) NOT NULL, 117 | gmt_modified timestamp DEFAULT '2010-05-05 00:00:00', 118 | constraint configdatarelationpubs_id_key PRIMARY KEY (id), 119 | constraint uk_app_pub_config_datagroup UNIQUE (app_name, data_id, group_id)); 120 | 121 | CREATE TABLE config_tags_relation ( 122 | id bigint NOT NULL, 123 | tag_name varchar(128) NOT NULL, 124 | tag_type varchar(64) DEFAULT NULL, 125 | data_id varchar(255) NOT NULL, 126 | group_id varchar(128) NOT NULL, 127 | tenant_id varchar(128) DEFAULT '', 128 | nid bigint NOT NULL generated by default as identity, 129 | constraint config_tags_id_key PRIMARY KEY (nid), 130 | constraint uk_configtagrelation_configidtag UNIQUE (id, tag_name, tag_type)); 131 | 132 | CREATE INDEX config_tags_tenant_id_idx ON config_tags_relation(tenant_id); 133 | 134 | CREATE TABLE group_capacity ( 135 | id bigint NOT NULL generated by default as identity, 136 | group_id varchar(128) DEFAULT '', 137 | quota int DEFAULT 0, 138 | usage int DEFAULT 0, 139 | max_size int DEFAULT 0, 140 | max_aggr_count int DEFAULT 0, 141 | max_aggr_size int DEFAULT 0, 142 | max_history_count int DEFAULT 0, 143 | gmt_create timestamp DEFAULT '2010-05-05 00:00:00', 144 | gmt_modified timestamp DEFAULT '2010-05-05 00:00:00', 145 | constraint group_capacity_id_key PRIMARY KEY (id), 146 | constraint uk_group_id UNIQUE (group_id)); 147 | 148 | CREATE TABLE tenant_capacity ( 149 | id bigint NOT NULL generated by default as identity, 150 | tenant_id varchar(128) DEFAULT '', 151 | quota int DEFAULT 0, 152 | usage int DEFAULT 0, 153 | max_size int DEFAULT 0, 154 | max_aggr_count int DEFAULT 0, 155 | max_aggr_size int DEFAULT 0, 156 | max_history_count int DEFAULT 0, 157 | gmt_create timestamp DEFAULT '2010-05-05 00:00:00', 158 | gmt_modified timestamp DEFAULT '2010-05-05 00:00:00', 159 | constraint tenant_capacity_id_key PRIMARY KEY (id), 160 | constraint uk_tenant_id UNIQUE (tenant_id)); 161 | 162 | CREATE TABLE tenant_info ( 163 | id bigint NOT NULL generated by default as identity, 164 | kp varchar(128) NOT NULL, 165 | tenant_id varchar(128) DEFAULT '', 166 | tenant_name varchar(128) DEFAULT '', 167 | tenant_desc varchar(256) DEFAULT NULL, 168 | create_source varchar(32) DEFAULT NULL, 169 | gmt_create bigint NOT NULL, 170 | gmt_modified bigint NOT NULL, 171 | constraint tenant_info_id_key PRIMARY KEY (id), 172 | constraint uk_tenant_info_kptenantid UNIQUE (kp,tenant_id)); 173 | CREATE INDEX tenant_info_tenant_id_idx ON tenant_info(tenant_id); 174 | -------------------------------------------------------------------------------- /build/nacos/target/nacos-server.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paderlol/nacos-docker/1dffb9b1137a7ac1d3fc1fd57f0ea38c72932bee/build/nacos/target/nacos-server.jar -------------------------------------------------------------------------------- /changlog: -------------------------------------------------------------------------------- 1 | version:0.4.0 2 | 1.修复单机启动内存数据库缺脚本异常问题 3 | 2.替换nacos基础镜像为centos 4 | 3.增加ping、curl、vim命令 5 | 4.重新优化env文件命名 -------------------------------------------------------------------------------- /cluster-hostname.yaml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | nacos1: 4 | hostname: nacos1 5 | container_name: nacos1 6 | image: paderlol/nacos:latest 7 | volumes: 8 | - ./logs:/home/nacos/logs 9 | ports: 10 | - "8848:8848" 11 | - "9555:9555" 12 | env_file: 13 | - ./env/nacos-hostname.env 14 | restart: always 15 | depends_on: 16 | - mysql-master 17 | - mysql-slave 18 | 19 | nacos2: 20 | hostname: nacos2 21 | image: paderlol/nacos:latest 22 | container_name: nacos2 23 | ports: 24 | - "8849:8848" 25 | env_file: 26 | - ./env/nacos-hostname.env 27 | restart: always 28 | depends_on: 29 | - mysql-master 30 | - mysql-slave 31 | nacos3: 32 | hostname: nacos3 33 | image: paderlol/nacos:latest 34 | container_name: nacos3 35 | ports: 36 | - "8850:8848" 37 | env_file: 38 | - ./env/nacos-hostname.env 39 | restart: always 40 | depends_on: 41 | - mysql-master 42 | - mysql-slave 43 | mysql-master: 44 | container_name: mysql-master 45 | image: paderlol/nacos-mysql-master:latest 46 | env_file: 47 | - ./env/mysql-common.env 48 | - ./env/mysql-master.env 49 | volumes: 50 | - ./mysql:/var/lib/mysql 51 | ports: 52 | - "3306:3306" 53 | mysql-slave: 54 | container_name: mysql-slave 55 | image: paderlol/nacos-mysql-slave:latest 56 | env_file: 57 | - ./env/mysql-common.env 58 | - ./env/mysql-slave.env 59 | ports: 60 | - "3305:3306" 61 | depends_on: 62 | - mysql-master 63 | -------------------------------------------------------------------------------- /cluster-ip.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | services: 3 | nacos1: 4 | image: paderlol/nacos:latest 5 | container_name: nacos1 6 | networks: 7 | nacos_net: 8 | ipv4_address: 172.16.238.10 9 | volumes: 10 | - ./logs:/home/nacos/logs 11 | ports: 12 | - "8848:8848" 13 | - "9555:9555" 14 | env_file: 15 | - ./env/nacos-ip.env 16 | restart: always 17 | depends_on: 18 | - mysql-master 19 | - mysql-slave 20 | 21 | nacos2: 22 | image: paderlol/nacos:latest 23 | container_name: nacos2 24 | networks: 25 | nacos_net: 26 | ipv4_address: 172.16.238.11 27 | ports: 28 | - "8849:8848" 29 | env_file: 30 | - ./env/nacos-ip.env 31 | restart: always 32 | depends_on: 33 | - mysql-master 34 | - mysql-slave 35 | nacos3: 36 | image: paderlol/nacos:latest 37 | container_name: nacos3 38 | networks: 39 | nacos_net: 40 | ipv4_address: 172.16.238.12 41 | ports: 42 | - "8850:8848" 43 | env_file: 44 | - ./env/nacos-ip.env 45 | restart: always 46 | depends_on: 47 | - mysql-master 48 | - mysql-slave 49 | mysql-master: 50 | container_name: mysql-master 51 | image: paderlol/nacos-mysql-master:latest 52 | networks: 53 | nacos_net: 54 | ipv4_address: 172.16.238.13 55 | env_file: 56 | - ./env/mysql-common.env 57 | - ./env/mysql-master.env 58 | volumes: 59 | - ./mysql:/var/lib/mysql 60 | ports: 61 | - "3306:3306" 62 | mysql-slave: 63 | container_name: mysql-slave 64 | image: paderlol/nacos-mysql-slave:latest 65 | networks: 66 | nacos_net: 67 | ipv4_address: 172.16.238.14 68 | env_file: 69 | - ./env/mysql-common.env 70 | - ./env/mysql-slave.env 71 | ports: 72 | - "3305:3306" 73 | depends_on: 74 | - mysql-master 75 | networks: 76 | nacos_net: 77 | driver: bridge 78 | ipam: 79 | driver: default 80 | config: 81 | - subnet: 172.16.238.0/24 82 | -------------------------------------------------------------------------------- /env/mysql-common.env: -------------------------------------------------------------------------------- 1 | # mysql template env 2 | MYSQL_ROOT_PASSWORD=root 3 | MYSQL_REPLICATION_USER=nacos_ru 4 | MYSQL_REPLICATION_PASSWORD=nacos_ru -------------------------------------------------------------------------------- /env/mysql-master.env: -------------------------------------------------------------------------------- 1 | MYSQL_DATABASE=nacos_devtest 2 | MYSQL_USER=nacos 3 | MYSQL_PASSWORD=nacos -------------------------------------------------------------------------------- /env/mysql-slave.env: -------------------------------------------------------------------------------- 1 | MYSQL_MASTER_SERVICE_HOST=mysql-master -------------------------------------------------------------------------------- /env/nacos-hostname.env: -------------------------------------------------------------------------------- 1 | #nacos dev env 2 | PREFER_HOST_MODE=hostname 3 | NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848 4 | MYSQL_MASTER_SERVICE_HOST=mysql-master 5 | MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest 6 | MYSQL_MASTER_SERVICE_PORT=3306 7 | MYSQL_SLAVE_SERVICE_HOST=mysql-slave 8 | MYSQL_SLAVE_SERVICE_PORT=3306 9 | MYSQL_MASTER_SERVICE_USER=nacos 10 | MYSQL_MASTER_SERVICE_PASSWORD=nacos -------------------------------------------------------------------------------- /env/nacos-ip.env: -------------------------------------------------------------------------------- 1 | #nacos dev env 2 | PREFER_HOST_MODE=hostname 3 | NACOS_SERVERS=172.16.238.10:8848 172.16.238.11:8848 172.16.238.12:8848 4 | MYSQL_MASTER_SERVICE_HOST=mysql-master 5 | MYSQL_MASTER_SERVICE_DB_NAME=nacos_devtest 6 | MYSQL_MASTER_SERVICE_PORT=3306 7 | MYSQL_SLAVE_SERVICE_HOST=mysql-slave 8 | MYSQL_SLAVE_SERVICE_PORT=3306 9 | MYSQL_MASTER_SERVICE_USER=nacos 10 | MYSQL_MASTER_SERVICE_PASSWORD=nacos -------------------------------------------------------------------------------- /standalone.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | services: 3 | nacos: 4 | image: paderlol/nacos:latest 5 | container_name: nacos-standalone 6 | environment: 7 | - PREFER_HOST_MODE=hostname 8 | - MODE=standalone 9 | volumes: 10 | - ./logs:/home/nacos/logs 11 | ports: 12 | - "8848:8848" --------------------------------------------------------------------------------