1、Nacos下载地址:https://github.com/alibaba/nacos.git;PS:我使用的版本是2.1.0的版本;
2、要是修改源码按照下面的地址该就行了,注意数据库依赖版本;
–>链接: link;下面是我修改之后的源码,可以直接用;
Gitee地址: https://gitee.com/sld_gitee/nacos-server-postgre-sql-2.1.0
链接:https://pan.baidu.com/s/1ArHH4Cst_oNOfeRKLFKv_w
提取码:6jrx
3、Maven依赖包下载好,然后install就行了,修改distribution/conf/application.properties里面的数据库配置,一定要在这个文件修改;
# 将下面设置为mysql就可以用mysql数据源了
spring.datasource.platform=postgresql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:postgresql://localhost:5432/nacos?currentSchema=public
db.user.0=postgres
db.password.0=postgres
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
4、install好然后执行上面的打包命令,会在distribution生成target包,目录结构如下:![在这里插入图片描述](https://img-blog.csdnimg.cn/89a71c1f162243a0b321e7a7eab78f3e.png
5、主要的就是这两个压缩包,选一个上传到服务器解压使用就行了;
6、初始SQL脚本,先创建数据库,默认使用的是schema为public,网盘有提供sql文件;
-- 创建nacos用户
CREATE USER nacos WITH PASSWORD 'nacos';
-- 创建nacos数据库
CREATE DATABASE nacos OWNER nacos;
-- 权限
GRANT ALL PRIVILEGES ON DATABASE nacos to nacos;
/*
* 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 TABLE config_info (
id serial NOT NULL,
data_id varchar(255) NOT NULL,
group_id varchar(255) DEFAULT NULL,
content text NOT NULL,
md5 varchar(32) DEFAULT NULL,
gmt_create timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
gmt_modified timestamp NOT NULL DEFAULT '2010-05-05 00:00:00',
src_user text,
src_ip varchar(50) DEFAULT NULL,
app_name varchar(128) DEFAULT NULL,
tenant_id varchar(128) DEFAULT '',
c_desc varchar(256) DEFAULT NULL,
c_use varchar(64) DEFAULT NULL,
effect varchar(64) DEFAULT NULL,
type varchar(64) DEFAULT NULL,
c_schema text,
encrypted_data_key text NOT NULL,
PRIMARY KEY (id),
constraint uk_configinfo_datagrouptenant unique(data_id,group_id,tenant_id)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_aggr */
/******************************************/
CREATE TABLE config_info_aggr (
id serial NOT NULL,
group_id varchar(255) NOT NULL,
datum_id varchar(255) NOT NULL,
gmt_modified timestamp NOT NULL,
constraint uk_configinfoaggr_datagrouptenantdatum unique(data_id,tenant_id,datum_id)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_beta */
/******************************************/
CREATE TABLE config_info_beta (
id serial NOT NULL,
group_id varchar(128) NOT NULL,
beta_ips varchar(1024) DEFAULT NULL,
constraint uk_configinfobeta_datagrouptenant unique(data_id,tenant_id)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_info_tag */
/******************************************/
CREATE TABLE config_info_tag (
id serial NOT NULL,
tag_id varchar(128) NOT NULL,
constraint uk_configinfotag_datagrouptenanttag unique(data_id,tag_id)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = config_tags_relation */
/******************************************/
CREATE TABLE config_tags_relation (
id serial NOT NULL,
tag_name varchar(128) NOT NULL,
tag_type varchar(64) DEFAULT NULL,
nid serial NOT NULL,
PRIMARY KEY (nid),
constraint uk_configtagrelation_configidtag unique(id,tag_name,tag_type)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = group_capacity */
/******************************************/
CREATE TABLE group_capacity (
id serial NOT NULL,
group_id varchar(128) NOT NULL DEFAULT '',
quota int NOT NULL DEFAULT '0' CHECK (quota >= 0),
usage int NOT NULL DEFAULT '0' CHECK (usage >= 0),
max_size int NOT NULL DEFAULT '0' CHECK (max_size >= 0),
max_aggr_count int NOT NULL DEFAULT '0' CHECK (max_aggr_count >= 0),
max_aggr_size int NOT NULL DEFAULT '0' CHECK (max_aggr_size >= 0),
max_history_count int NOT NULL DEFAULT '0' CHECK (max_history_count >= 0),
constraint uk_group_id unique(group_id)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = his_config_info */
/******************************************/
CREATE TABLE his_config_info (
id serial NOT NULL,
op_type char(10) DEFAULT NULL,
PRIMARY KEY (nid)
);
/******************************************/
/* 数据库全名 = nacos_config */
/* 表名称 = tenant_capacity */
/******************************************/
CREATE TABLE tenant_capacity (
id serial NOT NULL,
tenant_id varchar(128) NOT NULL DEFAULT '',
max_size int NOT NULL DEFAULT '0' CHECK (max_size >= 0),
max_aggr_count int NOT NULL DEFAULT '0' CHECK (max_aggr_count >= 0),
max_aggr_size int NOT NULL DEFAULT '0' CHECK (max_aggr_size >= 0),
constraint uk_tenant_id unique(tenant_id)
);
CREATE TABLE tenant_info (
id serial NOT NULL,
kp varchar(128) NOT NULL,
tenant_id varchar(128) default '',
tenant_name varchar(128) default '',
tenant_desc varchar(256) DEFAULT NULL,
create_source varchar(32) DEFAULT NULL,
gmt_create bigint NOT NULL,
gmt_modified bigint NOT NULL,
constraint uk_tenant_info_kptenantid unique(kp,tenant_id)
);
CREATE TABLE users (
username varchar(50) NOT NULL PRIMARY KEY,
password varchar(500) NOT NULL,
enabled boolean NOT NULL
);
CREATE TABLE roles (
username varchar(50) NOT NULL,
role varchar(50) NOT NULL
);
CREATE TABLE permissions (
role varchar(50) NOT NULL,
resource varchar(255) NOT NULL,
action varchar(8) NOT NULL
);
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
7、然后解压压缩包,进入到bin目录,执行启动脚本;
### Windows 启动 ###
startup.cmd -m standalone
### Windows 停止 ###
shutdown.cmd
8、Linux执行脚本启动可能会报下面的错,去掉空格就行,在执行启动命令;
### 报错 ###
startup.sh:行2: $'\r': 未找到命令
startup.sh:行5: $'\r': 未找到命令
# 去掉脚本空格
sed -i 's/\r$//' startup.sh
### Linux 启动 ###
./startup.sh -m standalone
### Linux 停止 ###
./shutdown.sh
如果启动报下面的错,好好看下你的数据库连接,源码的distribution/conf/application.properties是否配置正确
### 如果启动报下面的错,好好看下你的数据库连接,源码的distribution/conf/application.properties是否配置正确 ###
Nacos Server did not start because dumpservice bean construction failure : No DataSource Set
8、根据窗口打印的地址访问就可以了,用户名和密码默认:nacos,完活!!!
原文地址:https://blog.csdn.net/weixin_41481806/article/details/125918282
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。