高斯数据库GaussDB详解
一 介绍
高斯数据库不是指某个特定的产品,而是一系列产品的统称。
从官网上看,包含三大类产品OLTP,OLAP,HTAP的多个子产品:
可见,高斯数据库已经被打造成多类型数据库的内核平台。
GaussDB100外称GaussT,意指交易型,开源本版openGauss,全自研。
GaussDB200外称GaussA,意指分析型,闭源,基于postgresql。
二 架构及部署
三 安装
采用opengauss 2.0.1:
环境配置:CentOS Linux release 7.9.2009 (Core)
1,关闭防火墙,se
systemctl disable firewalld.service
systemctl stop firewalld.service
vim /etc/selinux/config
SELINUX=disabled
reboot
2,设置字符集
vim /etc/profile
export LANG=en_US.UTF-8
3,关闭swap,提升性能
swapoff -a
四 初始化
解压:
yum -y install bzip2
tar -jxf openGauss-2.0.1-CentOS-64bit.tar.bz2 -C gauss
创建用户:
groupadd gauss
useradd gauss:gauss
修改安装目录为gauss
chown -R gauss:gauss gauss
su gauss
安装netstat:
yum -y install net-tools
修改内核参数:
echo "kernel.sem=250 32000 100 1280" >> /etc/sysctl.conf
sysctl -p
启动:
sh install.sh -w 1234.abc
ps ux | grep gaussdb
导入lib:
cp /opt/gauss/lib/* /usr/lib64
状态查询:
bin/gs_ctl query -D /opt/gauss/data/single_node
五 admin
启停:
gs_ctl start -D /opt/gauss/data/single_node
进入数据库:
gsql -d postgres -p 5432
\l 列出所有数据库
\c mdb 切换到mdb数据库
\d 列出当前数据库下的表
select user; 显示当前用户
六 ddl
sql语法:
S Q L语法 | openGauss
create database mydb;
七 dml,dql
八 client
允许远程连接:
1.pg_hba.conf
host all all 0.0.0.0/0 sha256
2.postgresql.conf
listen_addresses = '*'
DataStudio:
CREATE USER jack PASSWORD '1234.abc';
Java Client:
jdbc connector,不能使用postgresql的驱动:
public class App { public static void main(String[] args) { String username = "jack"; String passwd = "1234.abc"; getConnect(username, passwd); } //以下代码将获取数据库连接操作封装为一个接口,可通过给定用户名和密码来连接数据库。 public static Connection getConnect(String username, String passwd) { //驱动类。 String driver = "org.postgresql.Driver"; //数据库连接描述符。 String sourceURL = "jdbc:postgresql://192.168.56.103:5432/mydb"; 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; } }
复制