暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

高斯数据库GaussDB详解

原创 wzf0072 2022-11-30
11867

高斯数据库GaussDB详解

一 介绍

高斯数据库不是指某个特定的产品,而是一系列产品的统称。

从官网上看,包含三大类产品OLTP,OLAP,HTAP的多个子产品:


可见,高斯数据库已经被打造成多类型数据库的内核平台。

GaussDB100外称GaussT,意指交易型,开源本版openGauss,全自研。

GaussDB200外称GaussA,意指分析型,闭源,基于postgresql。

二 架构及部署


三 安装

采用opengauss 2.0.1:

openGaussopengauss.org/zh/



环境配置: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语法 | openGaussopengauss.org/zh/docs/2.0.1/docs/Developerguide/SQL%E8%AF%AD%E6%B3%95.html

create database mydb;

https://opengauss.org/zh/docs/2.0.1/docs/Developerguide/DDL%E8%AF%AD%E6%B3%95%E4%B8%80%E8%A7%88%E8%A1%A8.htmlopengauss.org/zh/docs/2.0.1/docs/Developerguide/DDL%E8%AF%AD%E6%B3%95%E4%B8%80%E8%A7%88%E8%A1%A8.html


七 dml,dql

https://opengauss.org/zh/docs/2.0.1/docs/Developerguide/DML%E8%AF%AD%E6%B3%95%E4%B8%80%E8%A7%88%E8%A1%A8.htmlopengauss.org/zh/docs/2.0.1/docs/Developerguide/DML%E8%AF%AD%E6%B3%95%E4%B8%80%E8%A7%88%E8%A1%A8.html

八 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;
    }

}
复制
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论