• 华为GAUSSDB集成


    华为GAUSSDB集成

    1. 安装Centos7

    Centos7

    1. 关闭防火墙服务
    systemctl stop firewalld.service
    systemctl disabled firewalld.service
    systemctl status firewalld
    
    • 1
    • 2
    • 3
    1. 禁用Swap交换内存
    swapoff -a
    swapoff -av
    
    • 1
    • 2
    1. 修改配置文件
    # 修改selinux配置文件
    vim /etc/selinux/config
    # 修改SELINUX配置值为disabled
    SELINUX=disabled
    # 修改profile文件
    vim /etc/profile
    # 末尾添加
    ulimit -c unlimited
    # 重启系统
    reboot
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    1. 配置hostname和ip映射
    # 配置主机名,自由配置,不能使用默认配置
    vim /etc/hostname
    # 配置地址映射
    vim /etc/hosts
    
    • 1
    • 2
    • 3
    • 4
    1. 安装依赖
    mkdir /etc/yum.repos.d/bak
    mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
    wget -O /etc/yum.repos.d/CentOS-Base.repo https://repo.huaweicloud.com/repository/conf/CentOS-7-reg.repo
    """
    注:提示-bash: wget: command not found  (这是在Mini版本下)
    解决办法:http://mirrors.163.com/.help/centos.html,下载对应的版本
    	将文件上传至/etc/yum.repos.d/
    	yum clean all
    	yum makecache
    	yum -y install wget
    再重新执行即可
    """
    yum clean all
    yum install -y lksctp*
    yum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel
    yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core
    rpm -qa java-1.8.0-openjdk psmisc bzip2 libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core lksctp-tools* python3 python3-develchecksctp
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    1. 配置时区、添加用户和用户组
    # 配置时区
    echo "export LANG=en_US.UTF-8" >> ~/.bash_profile
    source ~/.bash_profile
    env|grep LANG
    rm -fr /etc/localtime
    ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    ll /etc/localtime
    # 添加用户和用户组
    groupadd dbgrp
    useradd -g dbgrp omm
    passwd omm
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    1. 安装opengaussdb
    # 创建存储目录
    mkdir /opt/module/opengauss/
    # 解压openGauss-3.0.0-CentOS-64bit-all.tar.gz 
    tar -zxvf /opt/software/openGauss-3.0.0-CentOS-64bit-all.tar.gz -C /opt/module/opengauss/
    # 解压openGauss-3.0.0-CentOS-64bit-om.tar.gz
    cd /opt/module/opengauss/
    tar -zxvf openGauss-3.0.0-CentOS-64bit-om.tar.gz
    # 配置环境变量
    vi /etc/profile
    export LD_LIBRARY_PATH=/opt/module/opengauss/script/gspylib/clib:$LD_LIBRARY_PATH
    source /etc/profile
    # 创建gaussdb单节点配置文件
    vim /opt/module/opengauss/clusterconfig.xml
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    # 配置信息
    
    <ROOT>
        <CLUSTER>
            
            <PARAM name="clusterName" value="dbCluster" />
            
            <PARAM name="nodeNames" value="gaussdb" />
            
            <PARAM name="gaussdbAppPath" value="/opt/huawei/install/app" />
            
            <PARAM name="gaussdbLogPath" value="/var/log/omm" />
            
            <PARAM name="tmpMppdbPath" value="/opt/huawei/tmp" />
            
            <PARAM name="gaussdbToolPath" value="/opt/huawei/install/om" />
            
            <PARAM name="corePath" value="/opt/huawei/corefile" />
            
            <PARAM name="backIp1s" value="192.168.5.69"/> 
        CLUSTER>
        每台服务器上的节点部署信息 -->
        <DEVICELIST>
            
            <DEVICE sn="node1_hostname">
                
                <PARAM name="name" value="gaussdb"/>
                
                <PARAM name="azName" value="AZ1"/>
                <PARAM name="azPriority" value="1"/>
                
                <PARAM name="backIp1" value="192.168.5.69"/>
                <PARAM name="sshIp1" value="192.168.5.69"/>
            
            <PARAM name="dataNum" value="1"/>
               
            <PARAM name="dataPortBase" value="15400"/>
            <PARAM name="dataNode1" value="/opt/huawei/install/data/dn"/>
                <PARAM name="dataNode1_syncNum" value="0"/>
            DEVICE>
        DEVICELIST>
    ROOT>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    # 使用root权限,执行gs_preinstall脚本
    cd /opt/module/opengauss/script
    ./gs_preinstall -U omm -G dbgrp -X /opt/module/openGauss/clusterconfig.xml
    # 修改opengauss读写权限和用户和用户组
    chmod -R 755 /opt/module/opengauss/
    chown -R omm /opt/module/opengauss/
    chgrp -R dbgrp /opt/module/opengauss/
    # 执行安装脚本
    su - omm
    cd /opt/module/opengauss/script
    # 注意安装过程中需要配置数据库密码
    ./gs_install -X /opt/module/opengauss/clusterconfig.xml
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    1. 启动opengaussdb、配置加密方式、添加用户、配置远程连接
    # 启动
    ./gs_om -t start
    # 修改密码加密类型为MD5(默认时sha256)
    gs_guc reload -N all -I all -c 'password_encryption_type=0'
    # 连接
    gsql -d postgres -p 15400
    # 查看加密类型,若输出值为0则配置成功
    show password_encryption_type;
    # 由于加密规则改变,需要修改用户密码
    alter user omm password 'gauss@123';
    # 添加test用户
    create user test with password 'test@1234';
    # 授权
    GRANT omm TO test;
    # 退出
    \q
    # 配置远程连接,具体路径查看clusterconfig.xml配置文件
    vim /opt/huawei/install/data/dn/pg_hba.conf
    # 末尾加入
    host    all    all    0.0.0.0/0    md5
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    1. 使用navicat连接
    数据库类型: postgresql
    ip: 宿主机ip 
    port: 配置文件中配置的port
    username: test
    password: test@1234
    
    • 1
    • 2
    • 3
    • 4
    • 5
    1. opengauss相关指令
    # 启动
    gs_om -t start
    # 重启
    gs_om -t restart
    # 停止
    gs_om -t stop
    # 检查数据库性能
    gs_om -t status --detail
    gs_om -t status --all
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    JDBC连接

    依赖配置

    <dependency>
       <groupId>org.opengaussgroupId>
       <artifactId>opengauss-jdbcartifactId>
       <version>3.0.0version>
    dependency>
    <dependency>
       <groupId>org.postgresqlgroupId>
       <artifactId>postgresqlartifactId>
       <version>42.2.6version>
    dependency>
    <dependency>
       <groupId>cn.hutoolgroupId>
       <artifactId>hutool-allartifactId>
       <version>5.8.0.M3version>
    dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    postgresql方式连接

    public class PostgresqlTest {
        public static void main(String[] args) {
            ResultSet tablesResult = null;
            try {
                String driver = "org.postgresql.Driver";
                String sourceURL = "jdbc:postgresql://192.168.5.69:15400/postgres";
                String username = "name";
                String passwd = "pwd";
    
                Class.forName(driver);
                Connection connection = DriverManager.getConnection(sourceURL, username, passwd);
                DatabaseMetaData metaData = connection.getMetaData();
                System.out.println(connection.getSchema());
                tablesResult = metaData.getTables(null,"public", null, new String[]{"TABLE"});
                while (tablesResult.next()) {
                    String tableName = tablesResult.getString("TABLE_NAME");
                    System.out.println(tableName);
                }
            } catch (ClassNotFoundException | SQLException e) {
                e.printStackTrace();
            }finally {
                IoUtil.close(tablesResult);
            }
    
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    官方数据库驱动

    public class GaussDbTest {
        public static void main(String[] args) {
            ResultSet tablesResult = null;
            try {
                String driver = "org.opengauss.Driver";
                String sourceURL = "jdbc:opengauss://192.168.5.69:15400/postgres?schema=public";
                String username = "name";
                String passwd = "pwd";
    
                Class.forName(driver);
                Connection connection = DriverManager.getConnection(sourceURL, username, passwd);
                DatabaseMetaData metaData = connection.getMetaData();
                System.out.println(connection.getSchema());
                tablesResult = metaData.getTables(null,"public", null, new String[]{"TABLE"});
                while (tablesResult.next()) {
                    String tableName = tablesResult.getString("TABLE_NAME");
                    System.out.println(tableName);
                }
            } catch (ClassNotFoundException | SQLException e) {
                e.printStackTrace();
            }finally {
                IoUtil.close(tablesResult);
            }
    
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    Datax集成

    模板文件

    {
        "job": {
            "content": [
                {
                    "reader": {
                        "name": "postgresqlreader", 
                        "parameter": {
    						"column": [
                                "\"id\"","\"name\"","\"desc\""
                            ],
                            "connection": [
                                {
                                    "jdbcUrl": ["jdbc:postgresql://192.168.5.69:15400/postgres"], 
                                    "table": ["\"user\""]
                                }
                            ], 
                            "password": "test", 
                            "username": "test@1234"
                        }
                    }, 
                    "writer": {
                        "name": "streamwriter", 
                        "parameter": {
                            "encoding": "", 
                            "print": true
                        }
                    }
                }
            ], 
            "setting": {
                "speed": {
                    "channel": "1"
                }
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    注意:列名和表名需要使用双引号包围

    执行结果

    在这里插入图片描述

    资源、参考博客路径

    opengauss下载地址: https://opengauss.org/zh/download.html

    clusterconfig.xml配置文件:https://www.bookstack.cn/read/openGauss-2.1-zh/installation-%E5%88%9B%E5%BB%BAXML%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6.md#单节点配置文件

    opengauss安装1:https://blog.csdn.net/yxzone/article/details/115057333?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-115057333-blog-112973261.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-115057333-blog-112973261.pc_relevant_aa&utm_relevant_index=1

    opengauss安装2:https://blog.csdn.net/qq_41619524/article/details/109722264

    opengauss密码模式修改:https://cdn.modb.pro/db/393744

    %7Edefault%7ECTRLIST%7Edefault-1-115057333-blog-112973261.pc_relevant_aa&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-115057333-blog-112973261.pc_relevant_aa&utm_relevant_index=1

    opengauss安装2:https://blog.csdn.net/qq_41619524/article/details/109722264

    opengauss密码模式修改:https://cdn.modb.pro/db/393744

  • 相关阅读:
    贪吃蛇-第12届蓝桥杯Scratch选拔赛真题精选
    双重预防机制数字化系统赋能施工企业安全隐患闭环管理,安全风险分级管控
    PIL和cv2读取图片时的差异及round函数讲解
    06 MIT线性代数-列空间和零空间 Column space & Nullspace
    HNU 电子电路 模型机综合设计
    WIFI 万[néng]钥匙 v5.0.10/v4.9.80 SVIP版!
    waitqueue实现阻塞数据访问 - Linux等待队列
    EXTI外部中断
    2023中国智能产业高峰论坛丨文档图像大模型的思考与探索
    使用sonar对webgoat进行静态扫描
  • 原文地址:https://blog.csdn.net/Amber_Flying/article/details/126138275