openGauss
开源数据库
openGauss社区官网
开源社区
openGauss数据库的安装运行(openGauss2.0.1)
2021-12-06openGauss数据库的安装运行
环境准备
硬件要求
内存 >= 32GB
CPU >= 8 核 2.0GHZ
硬盘 >= 40GB
软件要求
操作系统:CentOS 7.6 x86_64
Python:Python 3.6.X
虚拟机:VMware:16.1.2
配置 CentOS7.6

设置语言,时区:

设置网络连接:

设置完成后,来到设备选项界面按照如下配置即可。
设置用户名和密码

安装 net-tools 工具


使用 SSH 连接并设置相关

可能遇到的问题:过程试图写入的管道不存在
解决方法:重新检查 Host 地址是否变更,每次输入的 Host 可能会发生变化
yum 源更新

安装 python3.6

安装其他相关文件

开始安装
关闭防火墙和 Selinux
命令如下:
systemctl disable firewalld.service
systemctl stop firewalld.service
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
setenforce 0
设置字符集参数并检查设置时区:
创建用户组与用户
创建用户组 dbgrp、用户 omm,将该用户添加至 root 组,并修改用户 omm 的密码
解压



安装脚本:
命令格式:sh install.sh -w xxxx
由于 openGauss 端口号默认为 5432 默认生成名称为 postgres 的数据库:
使用 ps 和 gs_ctl 查看进程是否正常:
命令行访问数据库
以下以默认数据库里的 school 数据库为例
查看数据库 school 的 class 表结构: school 数据库相关信息:
以 JDBC 的方式访问数据库并查找
以查找 school 数据库中的 class 表为例,查找其中的 cla_id, cla_name, cla_teacher 并输出:
java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
class openGaussTest {
public static void main(String[] args) {
Connection conn = getConnect("mqq", "Mqq123123");
Statement stmt = null;
try {
stmt = conn.createStatement();
ResultSet rs = null;
try {
rs = stmt.executeQuery(
"select cla_id, cla_name, cla_teacher from class;");
while (rs.next()) {
int cla_id = rs.getInt(1);
String cla_name = rs.getString(2);
int cla_teacher = rs.getInt(3);
System.out.println(cla_id +" "+ cla_name + " "+cla_teacher);
}
} catch (SQLException e) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
e.printStackTrace();
}
stmt.close();
} catch (SQLException e) {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
e.printStackTrace();
}
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Connection getConnect(String username, String passwd) {
// 驱动类
String driver = "org.postgresql.Driver";
// 数据库连接描述符
String sourceURL = "jdbc:postgresql://***.***.***.***:5432/school";
Connection conn = null;
try {
// 加载驱动
Class.forName(driver);
} catch (Exception e) {
e.printStackTrace();
return null;
}
try {
// 创建连接
conn = DriverManager.getConnection(sourceURL, username, passwd);
System.out.println("Connection succeed!");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return conn;
}
}
查询结果如下: