1. 单机模式
1.1 准备安装介质
nacos-server-2.1.1.tar.gz
1.2 环境准备
- 1台服务器
- 安装JDK 1.8+
1.3 解压
tar-zxvf nacos-server-2.1.1.tar.gz
1.4 启动
进入解压的nacos目录,进入bin目录,运行:
./startup.sh -m standalone
1.5 验证
nacos服务默认端口是8848,如访问:http://10.1.192.120:8848/nacos/#/login,出现登录页面:
默认账号: nacos / nacos
1.6 关闭服务
# 进入nacos bin目录
./shutdown.sh
2. 集群模式
集群搭建以3个节点为例进行步骤说明。
2.1 介质准备
nacos-server-2.1.1.tar.gz
2.2 环境准备
- 准备3个节点机器
- 安装jdk 1.8+
2.3 解压
依次在服务节点进行安装介质解压:
tar-zxvf nacos-server-2.1.1.tar.gz
2.4 配置集群配置文件
在nacos的解压目录nacos的/config目录下,有配置文件cluster.conf,请每行配置成ip:port。(需要每个节点都配置。)
#it is ip
#example
10.1.192.120:8845
10.1.192.121:8845
10.1.192.122:8848
2.5 确定数据源
使用外置数据源
-
初始化MySQL数据库,sql可以在nacos config目录下面获取
/* * Copyright 1999-2018 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. */ /**************/ /* 数据库全名 = nacos_config */ /* 表名称 = config_info */ /**************/ CREATE TABLEconfig_info( idbigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', data_idvarchar(255) NOT NULL COMMENT 'data_id', group_idvarchar(255) DEFAULT NULL, contentlongtext NOT NULL COMMENT 'content', md5varchar(32) DEFAULT NULL COMMENT 'md5', gmt_createdatetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', gmt_modifieddatetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', src_usertext COMMENT 'source user', src_ipvarchar(50) DEFAULT NULL COMMENT 'source ip', app_namevarchar(128) DEFAULT NULL, tenant_idvarchar(128) DEFAULT '' COMMENT '租户字段', c_descvarchar(256) DEFAULT NULL, c_usevarchar(64) DEFAULT NULL, effectvarchar(64) DEFAULT NULL, typevarchar(64) DEFAULT NULL, c_schematext, encrypted_data_keytext NOT NULL COMMENT '秘钥', PRIMARY KEY (id), UNIQUE KEYuk_configinfo_datagrouptenant(data_id,group_id,tenant_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info'; /**************/ /* 数据库全名 = nacos_config */ /* 表名称 = config_info_aggr */ /**************/ CREATE TABLEconfig_info_aggr( idbigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', data_idvarchar(255) NOT NULL COMMENT 'data_id', group_idvarchar