节点 | ip | port |
---|---|---|
nacos1 | 192.168.xxx.xxx | 8841 |
nacos2 | 192.168.xxx.xxx | 18841 |
nacos3 | 192.168.xxx.xxx | 28841 |
tar -zxvf nacos-server-2.3.0.tar.gz
mv cluster.conf.example cluster.conf
#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#it is ip
#example
192.168.xxx.xxx:8841
192.168.xxx.xxx:18841
192.168.xxx.xxx:28841
### 是否开启鉴权功能
### If turn on auth system:
nacos.core.auth.enabled=true
### 配置自定义身份识别的key(不可为空)和value(不可为空)
### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=exampleNacos
nacos.core.auth.server.identity.value=exampleNacos
### 默认鉴权插件用于生成用户登陆临时accessToken所使用的密钥,使用默认值有安全风险
### 自定义密钥时,推荐将配置项设置为Base64编码的字符串,且原始密钥长度不得低于32字符。 Base64 在线编码解码: https://base64.us/
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
# mysql数据库配置信息
### If use MySQL as datasource:
### Deprecated configuration property, it is recommended to use `spring.sql.init.platform` replaced.
# spring.datasource.platform=mysql
# 初始化使用的数据库为MySQL
spring.sql.init.platform=mysql
# 数据库连接数量
### Count of DB:
db.num=1
### Connect URL of DB:
# 连接mysql的url
db.url.0=jdbc:mysql://192.168.xxx.xxx:3333/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
# 连接mysql的用户
db.user.0=root
# 连接mysql的密码
db.password.0=123456
cp -rf nacos ./nacos1
cp -rf nacos ./nacos2
cp -rf nacos ./nacos3
### Default web server port:
server.port=8841
### Default web server port:
server.port=18841
### Default web server port:
server.port=28841
# 配置JDK环境,要求JDK 1.8+
export JAVA_HOME=/usr/local/project/openjdk-8
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
/usr/local/project/nacos-group/nacos1/bin/startup.sh
/usr/local/project/nacos-group/nacos2/bin/startup.sh
/usr/local/project/nacos-group/nacos3/bin/startup.sh
端口 | 与主端口的偏移量 | 描述 |
---|---|---|
8848 | 0 | 主端口,客户端、控制台及OpenAPI所使用的HTTP端口 |
9848 | 1000 | 客户端gRPC请求服务端端口,用于客户端向服务端发起连接和请求 |
9849 | 1001 | 服务端gRPC请求服务端端口,用于服务间同步等 |
7848 | -1000 | Jraft请求服务端端口,用于处理服务端间的Raft相关请求 |
# upstream指令可以定义一组服务器
upstream nacos-cluster {
server 192.168.xxx.xxx:8841;
server 192.168.xxx.xxx:18841;
server 192.168.xxx.xxx:28841;
}
location /nacos {
# 反向代理配置,将请求转发到指定的服务
proxy_pass http://nacos-cluster;
}
# stream块用于做nacos的TCP转发
stream {
# upstream指令可以定义一组服务器
upstream nacos-cluster {
server 192.168.xxx.xxx:9841;
server 192.168.xxx.xxx:19841;
server 192.168.xxx.xxx:29841;
}
server {
# 80+1000=1080
listen 1080;
proxy_connect_timeout 30s;
proxy_timeout 5m;
# 反向代理配置,将请求转发到指定的服务
proxy_pass nacos-cluster;
}
}
sudo /usr/local/project/nginx/sbin/nginx
server:
port: 18080
spring:
application:
#应用的名称
name: nacos-user-service
cloud:
nacos:
# Nacos Server 启动监听的ip地址和端口
server-addr: 192.168.163.100:80
discovery:
# nacos开启鉴权之后的用户名
username: nacos
# nacos开启鉴权之后的用户登录密码
password: nacos
# 配置服务实例的集群名称
cluster-name: GD