Nacos 2.3.3支持Postgre SQL数据源配置
- 1、Nacos下载
- 2、 插件下载:
- 3、SQL脚本获取、nacos数据库创建、插件编译
- 4、Nacos 集群搭建方式:
1、Nacos下载
下载地址: https://download.nacos.io/nacos-server/nacos-server-2.3.2.zip
或者自行在官网下载其他版本: https://nacos.io/download/
2、 插件下载:
下载地址: https://github.com/wuchubuzai2018/nacos-datasource-extend-plugins
3、SQL脚本获取、nacos数据库创建、插件编译
1、下载后记得解压zip包,我这里是直接以zip包的格式下载的;
2、Postgre SQL脚本获取:
3、在postgre sql数据库执行脚本创建nacos数据库,编码格式:utf-8
4、编译打包插件jar
5、解压nacos 并创建plugins目录:
6、将上面编译好的jar放入到plugins目录:
7、修改nacos的配置文件:
# application.properties
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=postgresql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:postgresql://127.0.0.1:5432/nacos?targetServerType=primary&tcpKeepAlive=true&reWriteBatchedInserts=true&ApplicationName=nacos_java
db.user.0=nacos
db.password.0=nacos
### Connection pool configuration: hikariCP
db.pool.config.driverClassName=org.postgresql.Driver
8、启动
启动集群:
bin/startup.sh
启动单机:
bin/startup.sh -m standalone
停止:
bin/shutdown.sh
4、Nacos 集群搭建方式:
1、 例如:在三台服务器上,服务器的IP分别是:192.168.10.1,192.168.10.2,192.168.10.3
2、分别修改三台服务上的nacos/conf/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.10.1:8848
192.168.10.2:8848
192.168.10.3:8848
3、修改nacos\conf\application.properties文件:
4、三台服务器均需打开8848端口:
开放8848端口命令:firewall-cmd --zone=public --add-port=8848/tcp --permanent
5、启动三台服务的nacos实例:
nacos/bin/startup.sh