小工具知识网

当前位置: 首页 > 行业知识 > Go语言连接openGauss环境搭建过程(含OG安装)

行业知识

Go语言连接openGauss环境搭建过程(含OG安装)

2026-11-08 19:01:43 来源:互联网转载

Go 语言连接 openGauss 环境搭建过程(含 OG 安装)

1.前言

���文共分为 openGauss 单机版安装部分和连接环境搭建部分,提供了通过 go 语言来连接 openGauss 的一种方案。openGauss 现在也有了基于 go 的驱动,但是我觉得 ODBC 的方式更为通用一些,也不应被丢弃,因此本文使用 go 通过 ODBC 来连接 openGauss。

  • 硬件及软件环境:

    硬件环境:虚拟机的内存 8GB,4 核心 CPU,900G 磁盘(非必须)

    软件环境:CentOS7.6

    数据库版本:opengauss2.0 企业版:openGauss-2.0.0-CentOS-64bit-all.tar.gz

    2.openGauss 单机版安装:

    • 2.1. 关闭防火墙

      #停止firewallsystemctl stop firewalld.service#禁止firewall开机启动systemctl disable firewalld.service#检查防火墙是否关闭。 systemctl status firewalld
      • 说明:

        若防火墙状态显示为 active (running),则表示防火墙未关闭。

        若防火墙状态显示为 inactive (dead),则无需再关闭防火墙。

    • 2.2. 设置时区和时间

      将各数据库节点的时区设置为相同时区,可以将/usr/share/zoneinfo/目录下的时区文件拷贝为/etc/localtime 文件。

      cp /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
    • 2.3. 关闭 SELinux

      [root@node1 ~]#getenforcesed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/configsetenforce 0getenforce#检查 cat /etc/selinux/config|grep SELINUX输出:# SELINUX= can take one of these three values:SELINUX=disabled# SELINUXTYPE= can take one of three values:SELINUXTYPE=targeted[root@node1 ~]#
    • 2.4. 修改/etc/hosts

      #添加一行cat >>/etc/hosts  /etc/profile/etc/ssh/sshd_config/etc/security/limits.confecho "* hard nofile 1000000" >>/etc/security/limits.confecho "* soft nproc unlimited" >>/etc/security/limits.confecho "* hard nproc unlimited" >>/etc/security/limits.conf
    • 2.9. 安装 python3.6.x

      yum install openssl* -yyum install python3* -y

      检查

      [omm@node1 dn]$ python3 -VPython 3.6.8

      其他软件包,如需要可以安装(也可以直接使用安装):

      yum install -y libaio-devel flex bison ncurses-devel glibc-devel patch redhat-lsb-core readline-develyum install openssl* -yyum install -y java-1.8.0-openjdk* psmisc bzip2 python3 python3-devel lksctp*reboot   #重新启动服务器
    • 2.10. 创建安装包的存放目录

      mkdir -p /opt/software/openGausschmod 755 -R /opt/software
    • 2.11. 下载 openGauss 数据库软件

      下载地址为:https://opengauss.org/zh/download/">https://opengauss.org/zh/download/

      下载完成后上传到 centos 中

    • 2.12. 解压缩 openGauss DBMS 介质

      cd /opt/software/openGausstar -zxvf openGauss-2.0.0-CentOS-64bit-all.tar.gztar -zxvf openGauss-2.0.0-CentOS-64bit-om.tar.gz
    • 2.13. 创建 XML 文件

      下面是 xml 文件官方模板,一般只需要改一下自己 centos 机器的 IP

      cat > clusterconfig.xml                                                                                                                        

上一篇:宝塔面板怎么搬运网站?

下一篇:通天峡美景高清图片下载攻略,轻松掌握绝美风光!