• linux下载安装高斯(opengauss)数据库


    下载安装

    官网下载链接

    安装

    1.准备安装的XML配置文件
    
    <ROOT>
        
        <CLUSTER>
            
            <PARAM name="clusterName" value="test"/>
            
            <PARAM name="nodeNames" value="node1_hostname"/>
            
            <PARAM name="gaussdbAppPath" value="/home/opengauss/app"/>
            
            <PARAM name="gaussdbLogPath" value="/home/opengauss/log/omm"/>
            
            <PARAM name="tmpMppdbPath" value="/home/opengauss/tmp"/>
            
            <PARAM name="gaussdbToolPath" value="/home/opengauss/install/om"/>
            
            <PARAM name="corePath" value="/home/opengauss/corefile"/>
            
            <PARAM name="backIp1s" value="192.xxx.xxx.xxx"/>
        CLUSTER>
        
        <DEVICELIST>
            
            <DEVICE sn="node1_hostname">
                
                <PARAM name="name" value="node1_hostname"/>
                
                <PARAM name="azName" value="AZ1"/>
                <PARAM name="azPriority" value="1"/>
                
                <PARAM name="backIp1" value="192.xxx.xxx.xxx"/>
                <PARAM name="sshIp1" value="192.xxx.xxx.xxx"/>
    			
                
                <PARAM name="dataNum" value="1"/>
                <PARAM name="dataPortBase" value="5432"/>
                
                <PARAM name="dataNode1" value="/home/opengauss/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
    • 43
    2.准备安装环境
    • 安装bzip2

    • 安装python3.6X

    • 创建db用户组、db用户

    • 关闭防火墙

    • 把软件要安装的目录以及安装包解压目录所有权限都给db用户

    • 前置脚本运行,安装gauss的命令

      cd /opt/software/openGauss
      tar -zxvf openGauss-x.x.x-openEuler-64bit-all.tar.gz
      tar -zxvf openGauss-x.x.x-openEuler-64bit-om.tar.gz
      cd /opt/software/openGauss/script
      # cluster_config.xml就是刚刚那个配置文件
      ./gs_preinstall -U omm -G dbgrp -X /opt/software/openGauss/cluster_config.xml
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
    3.运行命令解析安装数据库
    gs_install -X /opt/software/openGauss/cluster_config.xml
    
    • 1

    使用

    数据库启动与关闭

    gs_om -t start
    gs_om -t stop && gs_om -t start
    
    • 1
    • 2

    连接数据库

    # 默认创建者omm,
    gsql -d postgres -p 15401
    gsql -d test -p 15401 -U test
    
    • 1
    • 2
    • 3

    设置用户加密算法

    查看加密算法
    SHOW password_encryption_type;
    
    • 1
    • 当参数password_encryption_type设置为0时,表示采用md5方式对密码加密。md5为不安全的加密算法,不建议使用。
    • 当参数password_encryption_type设置为1时,表示采用sha256和md5方式对密码加密。其中包含md5为不安全的加密算法,不建议使用,。
    • 当参数password_encryption_type设置为2时,表示采用sha256方式对密码加密,为默认配置。
    配置加密算法

    为了使用开源pgsql的驱动器连接,我还是建议使用password_encryption_type=1,使用默认配置将连接不上。

    gs_guc reload -N all -I all -c "password_encryption_type=1";
    
    • 1

    创建用户

    注意:创建用户之前先设置加密算法

    # 创建用户并授权
    CREATE USER test IDENTIFIED BY 'test@123';
    GRANT ALL ON TABLESPACE TEST_TABLE_SPACE TO test; 
    GRANT ALL ON DATABASE test TO test;
    GRANT ALL ON SCHEMA test TO test;
    \c dbname -- 切换数据库
    \c  -- 查看当前数据库
    select current_database(); -- 查看当前数据库
    CREATE SCHEMA test; -- 创建 schema
    GRANT ALL ON SCHEMA test TO test; -- 授权schema
    DROP USER test; --删除用户
    ALTER USER  test PASSWORD 'test@123' -- 修改密码
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    开启数据库的远程连接

    1. 开启监听ip

      # 查看已开启的监听ip
      gs_guc check -Z coordinator -I all -c "listen_addresses"
      #修改监听ip命令 
      gs_guc set -I all -Z coordinator -c "listen_addresses='localhost,192.xxx.xxx.xxx' "
      #或修改 postgresql.conf
      vi /home/software/openGauss/install/data/dn/postgresql.conf
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
    2. 开启远程连接ip

      #开启远程连接ip命令 
      gs_guc set -N all -I all -h "host all omm 192.xxx.xxx.xxx/32 md5"
      # 开启所有ip/网关
      gs_guc set -N all -I all -h "host all all 0.0.0.0/0 md5"
      # 或者直接编辑pg_hba.conf文件。
      vi /home/software/openGauss/install/data/dn/pg_hba.conf
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
    3. 远程连接必须创建一个非软件安装的默认管理员用户,否则连接不上

    数据库函数

  • 相关阅读:
    在 centos7 上安装Docker
    《Effective Java 中文版》读书笔记
    4.1.3 名称的特殊处理
    windows WSL配置cuda,pytorch和jupyter notebook
    【数据结构】【项目】BitMap?40亿电话号码如何快速去重?
    攻防演练-安全监测岗都做哪些工作
    ouster-32激光雷达使用---雷达参数配置
    FPGA实现双向电平转换
    架构-三层架构:三层架构
    MyBatisPlus(十七)通用枚举
  • 原文地址:https://blog.csdn.net/blood_Z/article/details/127800580