CentOS安装配置使用openGauss数据库
Contents [hide]
0 背景说明
华为基于PostgreSQL搞了个opengauss数据库,基于PG版的数据库。本文简单记录在CentOS上如何安装配置,基本使用该数据库,以及基本的错误解决。
opengauss官方网站:https://opengauss.org/zh/
1 安装软件包:
1
1
[root@localhost ~]# yum install flex* bison* ncurses-devel* glibc-devel* patch* redhat-lsb-core* readline-devel* libnsl* bzip* python3*
记得安装bzip,否则后面会有类似下述错误:
13
1
[root@localhost script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config_template.xml
2
[GAUSS-50217] : Failed to decompress version.cfg.The cmd is cd /opt/software/openGauss/script/../ && tar -xpf `head -1 version.cfg`*.tar.bz2 ./version.cfg. The output is tar (child): lbzip2:无法 exec: 没有那个文件或目录
3
tar (child): Error is not recoverable: exiting now
4
tar: Child returned status 2
5
tar: Error is not recoverable: exiting now.
6
[root@localhost script]# yum install bzip*
7
已加载插件:fastestmirror
8
Loading mirror speeds from cached hostfile
9
* base: mirrors.163.com
10
* extras: mirrors.163.com
11
* updates: mirrors.nju.edu.cn
12
软件包 bzip2-libs-1.0.6-13.el7.x86_64 已安装并且是最新版本
13
正在解决依赖关系
以及安装Python3:
7
1
[root@localhost script]# ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config_template.xml
2
/usr/bin/env: python3: 没有那个文件或目录
3
[root@localhost script]# py
4
pydoc python python2 python2.7
5
[root@localhost script]# yum install python3*
6
已加载插件:fastestmirror
7
Loading mirror speeds from cached hostfile
2 关闭SELINUX和Firewall
3
1
[root@localhost ~]# setenforce 0
2
[root@localhost ~]# systemctl stop firewalld
3
[root@localhost ~]# systemctl status firewalld
3 创建路径、下载、解压软件:
10
1
[root@localhost ~]# mkdir -p /opt/software/openGauss
2
[root@localhost ~]# chmod 755 -R /opt/software
3
[root@localhost ~]# cd /opt/software/openGauss/
4
[root@localhost openGauss]# wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.0.0/x86/openGauss-2.0.0-CentOS-64bit-all.tar.gz
5
[root@localhost openGauss]# tar -zxvf openGauss-2.0.0-CentOS-64bit-all.tar.gz
6
....
7
....
8
再解压om压缩文件:
9
[root@localhost openGauss]# tar -zxvf openGauss-2.0.0-CentOS-64bit-om.tar.gz
10
...
5 编辑配置文件:
1
1
[root@localhost openGauss]# cp script/gspylib/etc/conf/cluster_config_template.xml .
编辑完之后的配置文件内容:
47
1
[root@localhost openGauss]# pwd
2
/opt/software/openGauss
3
[root@localhost openGauss]# ll
4
总用量 298556
5
-rw-------. 1 omm dbgrp 1101 4月 19 16:09 cluster_config_template.xml
6
drwx------. 15 root root 4096 4月 19 16:10 lib
7
-r--------. 1 root root 101382908 3月 31 21:31 openGauss-2.0.0-CentOS-64bit-all.tar.gz
8
-r--------. 1 root root 65 3月 31 21:16 openGauss-2.0.0-CentOS-64bit-om.sha256
9
-r--------. 1 root root 12646330 3月 31 21:16 openGauss-2.0.0-CentOS-64bit-om.tar.gz
10
-r--------. 1 root root 65 3月 31 21:16 openGauss-2.0.0-CentOS-64bit.sha256
11
-r--------. 1 root root 89573052 3月 31 21:16 openGauss-2.0.0-CentOS-64bit.tar.bz2
12
-r--------. 1 root root 101942608 4月 19 16:10 openGauss-Package-bak_78689da9.tar.gz
13
drwx------. 6 root root 4096 3月 31 21:16 script
14
drwxr-xr-x. 2 root root 4096 3月 31 21:16 simpleInstall
15
-r--------. 1 root root 65 3月 31 21:15 upgrade_sql.sha256
16
-r--------. 1 root root 133704 3月 31 21:15 upgrade_sql.tar.gz
17
-r--------. 1 root root 32 3月 31 21:14 version.cfg
18
[root@localhost openGauss]# cat cluster_config_template.xml
19
<?xml version="1.0" encoding="utf-8"?>
20
<ROOT>
21
<CLUSTER>
22
<PARAM name="clusterName" value="Cluster_template" />
23
<PARAM name="nodeNames" value="localhost.localdomain"/>
24
<PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
25
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
26
<PARAM name="tmpMppdbPath" value="/opt/huawei/tmp"/>
27
<PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
28
<PARAM name="corePath" value="/opt/huawei/corefile"/>
29
<PARAM name="backIp1s" value="172.16.11.148"/>
30
</CLUSTER>
31
32
<DEVICELIST>
33
<DEVICE sn="localhost">
34
<PARAM name="name" value="localhost.localdomain"/>
35
<PARAM name="azName" value="AZ1"/>
36
<PARAM name="azPriority" value="1"/>
37
<PARAM name="backIp1" value="172.16.11.148"/>
38
<PARAM name="sshIp1" value="172.16.11.148"/>
39
<!-- dn -->
40
<PARAM name="dataNum" value="1"/>
41
<PARAM name="dataPortBase" value="15400"/>
42
<PARAM name="dataNode1" value="/opt/huawei/install/data/dn"/>
43
<PARAM name="dataNode1_syncNum" value="0"/>
44
</DEVICE>
45
</DEVICELIST>
46
</ROOT>
47
[root@localhost openGauss]#
6 执行安装前检查:
48
1
[root@localhost openGauss]# pwd
2
/opt/software/openGauss
3
[root@localhost openGauss]# ./script/gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config_template.xml
4
Parsing the configuration file.
5
Successfully parsed the configuration file.
6
Installing the tools on the local node.
7
Successfully installed the tools on the local node.
8
Setting pssh path
9
Successfully set core path.
10
Are you sure you want to create the user[omm] and create trust for it (yes/no)? yes
11
Please enter password for cluster user.
12
Password:
13
Please enter password for cluster user again.
14
Password:
15
Successfully created [omm] user on all nodes.
16
Preparing SSH service.
17
Successfully prepared SSH service.
18
Checking OS software.
19
Successfully check os software.
20
Checking OS version.
21
Successfully checked OS version.
22
Creating cluster's path.
23
Successfully created cluster's path.
24
Setting SCTP service.
25
Successfully set SCTP service.
26
Set and check OS parameter.
27
Setting OS parameters.
28
Successfully set OS parameters.
29
Warning: Installation environment contains some warning messages.
30
Please get more details by "/opt/software/openGauss/script/gs_checkos -i A -h localhost.localdomain --detail".
31
Set and check OS parameter completed.
32
Preparing CRON service.
33
Successfully prepared CRON service.
34
Setting user environmental variables.
35
Successfully set user environmental variables.
36
Setting the dynamic link library.
37
Successfully set the dynamic link library.
38
Setting Core file
39
Successfully set core path.
40
Setting pssh path
41
Successfully set pssh path.
42
Set ARM Optimization.
43
No need to set ARM Optimization.
44
Fixing server package owner.
45
Setting finish flag.
46
Successfully set finish flag.
47
Preinstallation succeeded.
48
[root@localhost openGauss]#
7 执行安装
56
1
[root@localhost openGauss]# su - omm
2
上一次登录:一 4月 19 17:08:22 CST 2021pts/1 上
3
[omm@localhost ~]$ which gs_install
4
/opt/huawei/install/om/script/gs_install
5
[omm@localhost ~]$ gs_install -X /opt/software/openGauss/cluster_config_template.xml
6
Parsing the configuration file.
7
Check preinstall on every node.
8
Successfully checked preinstall on every node.
9
Creating the backup directory.
10
Successfully created the backup directory.
11
begin deploy..
12
Installing the cluster.
13
begin prepare Install Cluster..
14
Checking the installation environment on all nodes.
15
begin install Cluster..
16
Installing applications on all nodes.
17
Successfully installed APP.
18
begin init Instance..
19
encrypt cipher and rand files for database.
20
Please enter password for database:
21
Please repeat for database:
22
[GAUSS-50322] : Failed to encrypt the password for databaseError:
23
Invalid password,it must contain at least eight characters
24
Try "gs_guc --help" for more information.
25
Please enter password for database:
26
Please repeat for database:
27
[GAUSS-50322] : Failed to encrypt the password for databaseError:
28
Invalid password,it must contain at least three kinds of characters
29
Try "gs_guc --help" for more information.
30
Please enter password for database:
31
Please repeat for database:
32
begin to create CA cert files
33
The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om
34
Cluster installation is completed.
35
Configuring.
36
Deleting instances from all nodes.
37
Successfully deleted instances from all nodes.
38
Checking node configuration on all nodes.
39
Initializing instances on all nodes.
40
[GAUSS-51400] : Failed to execute the command: source /home/omm/.bashrc;python3 '/opt/huawei/install/om/script/local/InitInstance.py' -U omm -l /var/log/omm/omm/om/gs_local.log.Error:
41
Initializing instance.
42
[GAUSS-51615] : Failed to initialize instance. Command:/opt/huawei/install/app/bin/gs_initdb --locale=C -D /opt/huawei/install/data/dn --nodename=dn_6001 -C /opt/huawei/install/app/bin. Error:
43
The files belonging to this database system will be owned by user "omm".
44
This user must also own the server process.
45
46
The database cluster will be initialized with locale "C".
47
The default database encoding has accordingly been set to "SQL_ASCII".
48
The default text search configuration will be set to "english".
49
50
fixing permissions on existing directory /opt/huawei/install/data/dn ... ok
51
creating subdirectories ... ok
52
selecting default max_connections ... 10
53
selecting default shared_buffers ... 400kB
54
creating configuration files ... ok
55
creating template1 database in /opt/huawei/install/data/dn/base/1 ... gs_initdb: removing contents of data directory "/opt/huawei/install/data/dn"
56
[omm@localhost ~]$
8 错误GAUSS-51400和GAUSS-51615
https://gitee.com/opengauss/docs/issues/I38WUR?_from=gitee_search
当前机器内存配置比较小:
5
1
[omm@localhost ~]$ free -m
2
total used free shared buff/cache available
3
Mem: 3790 127 3287 90 375 3110
4
Swap: 0 0 0
5
[omm@localhost ~]$
9 安装成功
根据错误解决经验,更换了一台内存为8GB的新机器执行安装成功了。
37
1
[omm@localhost ~]$ free -m
2
total used free shared buff/cache available
3
Mem: 7984 6336 546 720 1100 72
4
Swap: 8063 3525 4538
5
[omm@localhost ~]$ gs_install -X /opt/software/openGauss/cluster_config_template.xml
6
Parsing the configuration file.
7
Check preinstall on every node.
8
Successfully checked preinstall on every node.
9
Creating the backup directory.
10
Successfully created the backup directory.
11
begin deploy..
12
Installing the cluster.
13
begin prepare Install Cluster..
14
Checking the installation environment on all nodes.
15
begin install Cluster..
16
Installing applications on all nodes.
17
Successfully installed APP.
18
begin init Instance..
19
encrypt cipher and rand files for database.
20
Please enter password for database:
21
Please repeat for database:
22
begin to create CA cert files
23
The sslcert will be generated in /opt/huawei/install/app/share/sslcert/om
24
Cluster installation is completed.
25
Configuring.
26
Deleting instances from all nodes.
27
Successfully deleted instances from all nodes.
28
Checking node configuration on all nodes.
29
Initializing instances on all nodes.
30
Updating instance configuration on all nodes.
31
Check consistence of memCheck and coresCheck on database nodes.
32
Configuring pg_hba on all nodes.
33
Configuration is completed.
34
Successfully started cluster.
35
Successfully installed application.
36
end deploy..
37
[omm@localhost ~]$
10 创建数据库
30
1
[omm@localhost ~]$ gsql -d postgres -p 15400
2
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr )
3
Non-SSL connection (SSL connection is recommended when requiring high-security)
4
Type "help" for help.
5
postgres=# \l+
6
List of databases
7
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
8
-----------+-------+-----------+---------+-------+-------------------+-------+------------+--------------------------------------------
9
postgres | omm | SQL_ASCII | C | C | | 11 MB | pg_default | default administrative connection database
10
template0 | omm | SQL_ASCII | C | C | =c/omm +| 10 MB | pg_default | default template for new databases
11
| | | | | omm=CTc/omm | | |
12
template1 | omm | SQL_ASCII | C | C | =c/omm +| 10 MB | pg_default | unmodifiable empty database
13
| | | | | omm=CTc/omm | | |
14
(3 rows)
15
16
postgres=# CREATE DATABASE mydb WITH ENCODING 'GBK' template = template0;
17
CREATE DATABASE
18
postgres=# \l+
19
List of databases
20
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
21
-----------+-------+-----------+---------+-------+-------------------+-------+------------+--------------------------------------------
22
mydb | omm | GBK | C | C | | 10 MB | pg_default |
23
postgres | omm | SQL_ASCII | C | C | | 11 MB | pg_default | default administrative connection database
24
template0 | omm | SQL_ASCII | C | C | =c/omm +| 10 MB | pg_default | default template for new databases
25
| | | | | omm=CTc/omm | | |
26
template1 | omm | SQL_ASCII | C | C | =c/omm +| 10 MB | pg_default | unmodifiable empty database
27
| | | | | omm=CTc/omm | | |
28
(4 rows)
29
30
postgres=#
11 gsql远程连接数据库
前提条件:
服务端启动数据库服务;
配置白名单
客户端安装gsql
注意:客户端配置时的,PATH和LD_LIBRARY_PATH环境变量中,一个是指向/opt/software/bin,一个是指向了/opt/software/lib。不可粗心大意!!!!我就是不注意细节,导致,客户端通过gsql访问远程的数据库,一直报错。自己还傻呵呵的去手动创建链接:
14
1
[root@localhost ~]# gsql -d fdp -h 172.16.11.106 -U fdp -p 15400 -W Aa123456
2
gsql: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
3
[root@localhost ~]# openssl version
4
OpenSSL 1.1.1g 21 Apr 2020
5
[root@localhost ~]# find / -name libssl.so.1.1
6
/root/gauss/script/gspylib/clib/libssl.so.1.1
7
/root/gauss_om/omm/script/gspylib/clib/libssl.so.1.1
8
/opt/software/lib/libssl.so.1.1
9
/opt/software/bin/script/gspylib/clib/libssl.so.1.1
10
[root@localhost ~]#
11
•
12
•
13
[root@localhost ~]# ln -s /opt/software/lib/libssl.so.1.1 /usr/local/lib/libssl.so.1.1
14
[root@localhost ~]# ln -s /opt/software/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
12 Java程序通过JDBC访问数据库
安装opengauss官方的说法是,凡是之前可以运行在PostgreSQL数据库上的系统,都可以直接运行在opengauss的数据库上。
https://opengauss.org/zh/docs/2.0.0/docs/Quickstart/%E9%80%9A%E8%BF%87JDBC%E6%89%A7%E8%A1%8CSQL.html
JDBC包与驱动类
- JDBC包在linux服务器端源代码目录下执行build.sh,获得驱动jar包postgresql.jar,包位置在源代码目录下。从发布包中获取, 包名为openGauss-1.0.1-操作系统版本号-64bit-Jdbc.tar.gz。驱动包与PostgreSQL保持兼容,其中类名、类结构与PostgreSQL驱动完全一致,曾经运行于PostgreSQL的应用程序可以直接移植到当前系统使用。
- 驱动类在创建数据库连接之前,需要加载数据库驱动类“org.postgresql.Driver”。
a idea创建普通的maven工程
b 引入postgresql的驱动
18
1
2
<project xmlns="http://maven.apache.org/POM/4.0.0"
3
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
<modelVersion>4.0.0</modelVersion>
6
7
<groupId>org.example</groupId>
8
<artifactId>gauss</artifactId>
9
<version>1.0-SNAPSHOT</version>
10
<dependencies>
11
<dependency>
12
<groupId>org.postgresql</groupId>
13
<artifactId>postgresql</artifactId>
14
<version>42.2.20.jre7</version>
15
</dependency>
16
</dependencies>
17
18
</project>
c 创建测试类DBTest
168
1
/**
2
* @Author:asher
3
* @Date:2021/6/3 15:36
4
* @Description:PACKAGE_NAME
5
* @Version:1.0
6
*/
7
//DBtest.java
8
//演示基于JDBC开发的主要步骤,会涉及创建数据库、创建表、插入数据等。
9
10
import java.sql.*;
11
12
public class DBTest {
13
14
//创建数据库连接。
15
public static Connection GetConnection(String username, String passwd) {
16
String driver = "org.postgresql.Driver";
17
String sourceURL = "jdbc:postgresql://172.16.11.106:15400/es_sam_dev";
18
// String sourceURL = "jdbc:postgresql://172.16.11.35:5433/es_sam_dev";
19
Connection conn = null;
20
try {
21
//加载数据库驱动。
22
Class.forName(driver).newInstance();
23
} catch (Exception e) {
24
e.printStackTrace();
25
return null;
26
}
27
28
try {
29
//创建数据库连接。
30
conn = DriverManager.getConnection(sourceURL, username, passwd);
31
System.out.println("Connection succeed!");
32
} catch (Exception e) {
33
e.printStackTrace();
34
return null;
35
}
36
37
return conn;
38
};
39
40
//执行普通SQL语句,创建customer_t1表。
41
public static void CreateTable(Connection conn) {
42
Statement stmt = null;
43
try {
44
stmt = conn.createStatement();
45
46
//执行普通SQL语句。
47
int rc = stmt
48
.executeUpdate("CREATE TABLE customer_t1(c_customer_sk INTEGER, c_customer_name VARCHAR(32));");
49
50
stmt.close();
51
} catch (SQLException e) {
52
if (stmt != null) {
53
try {
54
stmt.close();
55
} catch (SQLException e1) {
56
e1.printStackTrace();
57
}
58
}
59
e.printStackTrace();
60
}
61
}
62
63
//执行预处理语句,批量插入数据。
64
public static void BatchInsertData(Connection conn) {
65
PreparedStatement pst = null;
66
67
try {
68
//生成预处理语句。
69
pst = conn.prepareStatement("INSERT INTO customer_t1 VALUES (?,?)");
70
for (int i = 0; i < 3; i++) {
71
//添加参数。
72
pst.setInt(1, i);
73
pst.setString(2, "data " + i);
74
pst.addBatch();
75
}
76
//执行批处理。
77
pst.executeBatch();
78
pst.close();
79
} catch (SQLException e) {
80
if (pst != null) {
81
try {
82
pst.close();
83
} catch (SQLException e1) {
84
e1.printStackTrace();
85
}
86
}
87
e.printStackTrace();
88
}
89
}
90
91
//执行预编译语句,更新数据。
92
public static void ExecPreparedSQL(Connection conn) {
93
PreparedStatement pstmt = null;
94
try {
95
pstmt = conn
96
.prepareStatement("UPDATE customer_t1 SET c_customer_name = ? WHERE c_customer_sk = 1");
97
pstmt.setString(1, "new Data");
98
int rowcount = pstmt.executeUpdate();
99
pstmt.close();
100
} catch (SQLException e) {
101
if (pstmt != null) {
102
try {
103
pstmt.close();
104
} catch (SQLException e1) {
105
e1.printStackTrace();
106
}
107
}
108
e.printStackTrace();
109
}
110
}
111
112
113
//执行存储过程。
114
public static void ExecCallableSQL(Connection conn) {
115
CallableStatement cstmt = null;
116
try {
117
118
cstmt=conn.prepareCall("{? = CALL TESTPROC(?,?,?)}");
119
cstmt.setInt(2, 50);
120
cstmt.setInt(1, 20);
121
cstmt.setInt(3, 90);
122
cstmt.registerOutParameter(4, Types.INTEGER); //注册out类型的参数,类型为整型。
123
cstmt.execute();
124
int out = cstmt.getInt(4); //获取out参数
125
System.out.println("The CallableStatment TESTPROC returns:"+out);
126
cstmt.close();
127
} catch (SQLException e) {
128
if (cstmt != null) {
129
try {
130
cstmt.close();
131
} catch (SQLException e1) {
132
e1.printStackTrace();
133
}
134
}
135
e.printStackTrace();
136
}
137
}
138
139
140
/**
141
* 主程序,逐步调用各静态方法。
142
* @param args
143
*/
144
public static void main(String[] args) {
145
//创建数据库连接。
146
Connection conn = GetConnection("es_sam_dev", "Es_sam_dev2");
147
// Connection conn = GetConnection("es_sam_dev", "es_sam_dev");
148
149
//创建表。
150
CreateTable(conn);
151
152
//批插数据。
153
BatchInsertData(conn);
154
155
//执行预编译语句,更新数据。
156
ExecPreparedSQL(conn);
157
158
//执行存储过程。
159
// ExecCallableSQL(conn);
160
161
//关闭数据库连接。
162
try {
163
conn.close();
164
} catch (SQLException e) {
165
e.printStackTrace();
166
}
167
}
168
}
13 报错解决
a SSL error , Could not generate DH keypair
14
1
org.postgresql.util.PSQLException: SSL error: java.lang.RuntimeException: Could not generate DH keypair
2
at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:43)
3
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:534)
4
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:149)
5
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
6
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
7
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
8
at org.postgresql.Driver.makeConnection(Driver.java:465)
9
at org.postgresql.Driver.connect(Driver.java:264)
10
at java.sql.DriverManager.getConnection(DriverManager.java:664)
11
at java.sql.DriverManager.getConnection(DriverManager.java:247)
12
at DBTest.GetConnection(DBTest.java:30)
13
at DBTest.main(DBTest.java:146)
14
Caused by: javax.net.ssl.SSLException: java.lang.RuntimeException: Could not generate DH keypair
解决办法:opengauss数据库上关闭ssl验证。默认情况下,opengauss开启了ssl。
2
1
78 #ssl = on # (change requires restart)
2
79 ssl = off # (change requires restart)
b 用户口令加密方式错误Invalid or unsupported by client SCRAM mechanisms
16
1
org.postgresql.util.PSQLException: Invalid or unsupported by client SCRAM mechanisms
2
at org.postgresql.jre7.sasl.ScramAuthenticator.processServerMechanismsAndInit(ScramAuthenticator.java:82)
3
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:760)
4
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:161)
5
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:213)
6
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
7
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:223)
8
at org.postgresql.Driver.makeConnection(Driver.java:465)
9
at org.postgresql.Driver.connect(Driver.java:264)
10
at java.sql.DriverManager.getConnection(DriverManager.java:664)
11
at java.sql.DriverManager.getConnection(DriverManager.java:247)
12
at DBTest.GetConnection(DBTest.java:30)
13
at DBTest.main(DBTest.java:146)
14
Exception in thread "main" java.lang.NullPointerException
15
at DBTest.CreateTable(DBTest.java:44)
16
at DBTest.main(DBTest.java:150)
解决方法:
修改配置文件:
1
1
password_encryption_type = 0 #Password storage type, 0 is md5 for PG, 1 is sha256 + md5, 2 is sha256 only
然后,重置数据库用户的密码。
6
1
postgres=# alter user es_sam_dev password 'Es_sam_dev1';
2
ERROR: The password cannot be reused.
3
postgres=# alter user es_sam_dev password 'Es_sam_dev3';
4
NOTICE: The encrypted password contains MD5 ciphertext, which is not secure.
5
ALTER ROLE
6
postgres=#
成功:
Connection succeed!