Java工具篇之nacos的安装(windows环境)

tech2023-07-02  102

Java工具篇之nacos的安装(windows环境)

一、准备工作

1、环境

直接查阅官方文档即可,这里简单做简单的记录。

JDK:1.8+

MAVEN:3.2.x+

2、下载源码

从GitHub上面下载源码

git clone https://github.com/alibaba/nacos.git cd nacos/ mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U ls -al distribution/target/ cd distribution/target/nacos-server-$version/nacos/bin

二、配置文件

1、导入nacos-mysql.sql脚本

这个地方开始官方文档没有写,需要自己填坑。

2、修改application.properties文件

### Connect URL of DB: spring.datasource.platform=mysql db.num=1 db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC db.user=root db.password=root

注意:此处的文件是target文件夹下面的,我的路径是

3、修改cluster.conf.example文件

需要复制并修改为cluster.conf,文件内容需要修改,我的修改如下:

#it is ip #example 192.168.0.129:8848 #192.168.16.102 #192.168.16.103

4、成功启动

三、可能出现的问题

1、下载源码之后编译报错

bash: mvn: command not found

这个是没有配置maven的全局变量,设置完成即可编译成功

2、启动时候连接数据库报错

Caused by: java.lang.RuntimeException: [db-load-error]load jdbc.properties error at com.alibaba.nacos.config.server.service.datasource.ExternalDataSourceServiceImpl.init(ExternalDataSourceServiceImpl.java:118) at com.alibaba.nacos.config.server.service.datasource.DynamicDataSource.getDataSource(DynamicDataSource.java:53) ... 166 common frames omitted

请检查application.properties文件,数据库名,用户名以及密码

3、启动的时候没有设置ip

Caused by: java.net.UnknownHostException: jmenv.tbsite.net at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:196) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:162) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:394) at java.net.Socket.connect(Socket.java:606) at sun.net.NetworkClient.doConnect(NetworkClient.java:175) at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) at sun.net.www.http.HttpClient.New(HttpClient.java:339) at sun.net.www.http.HttpClient.New(HttpClient.java:357) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1226) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1162) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1056) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:990) at com.alibaba.nacos.common.http.client.request.JdkHttpClientRequest.execute(JdkHttpClientRequest.java:109) at com.alibaba.nacos.common.http.client.NacosRestTemplate.execute(NacosRestTemplate.java:462) at com.alibaba.nacos.common.http.client.NacosRestTemplate.get(NacosRestTemplate.java:72) at com.alibaba.nacos.core.cluster.lookup.AddressServerMemberLookup.syncFromAddressUrl(AddressServerMemberLookup.java:145) at com.alibaba.nacos.core.cluster.lookup.AddressServerMemberLookup.run(AddressServerMemberLookup.java:113) ... 123 common frames omitted

请检查cluster.conf文件,并查看配置的ip地址以及端口是否正确。

最新回复(0)