首页
产品
CLup:PostgreSQL高可用集群平台 CMiner: PostgreSQL中的CDC CData高性能数据库云一体机 CBackup数据库备份恢复云平台 CPDA高性能双子星数据库机 CSYun超融合虚拟机产品 ZQPool数据库连接池 ConshGuard数据保护产品
解决方案
数据库专业技术服务全栈式PostgreSQL解决方案Oracle分布式存储化数据库云PolarDB一体化解决方案
文章
客户及伙伴
中启开源
关于我们
公司简介 联系我们
中启开源

服务器清单

主机名 CPU 内存 存储 备注
dfq-cloudberrydb-01 8c 8G 30G SSD 部署Coordinator
dfq-cloudberrydb-02 8c 8G 30G SSD 部署Segment(Primary+Mirror)
dfq-cloudberrydb-03 8c 8G 30G SSD 部署Segment(Primary+Mirrir)

3台服务器信息如下:

  1. [root@dfq-cloudberrydb-01 ~]# cat /etc/os-release
  2. NAME="Rocky Linux"
  3. VERSION="8.6 (Green Obsidian)"
  4. ID="rocky"
  5. ID_LIKE="rhel centos fedora"
  6. VERSION_ID="8.6"
  7. PLATFORM_ID="platform:el8"
  8. PRETTY_NAME="Rocky Linux 8.6 (Green Obsidian)"
  9. ANSI_COLOR="0;32"
  10. CPE_NAME="cpe:/o:rocky:rocky:8:GA"
  11. HOME_URL="https://rockylinux.org/"
  12. BUG_REPORT_URL="https://bugs.rockylinux.org/"
  13. ROCKY_SUPPORT_PRODUCT="Rocky Linux"
  14. ROCKY_SUPPORT_PRODUCT_VERSION="8"
  15. REDHAT_SUPPORT_PRODUCT="Rocky Linux"
  16. REDHAT_SUPPORT_PRODUCT_VERSION="8"

通过源码编译CloudberryDB

下载CloudberryDB源码:

  1. git clone https://github.com/cloudberrydb/cloudberrydb.git
  2. cd cloudberrydb
  3. git checkout 1.5.3

安装依赖项

  1. sudo dnf groupinstall -y "Development Tools"
  2. sudo dnf install -y epel-release
  3. sudo dnf install -y apr-devel bison bzip2-devel cmake3 flex gcc gcc-c++ krb5-devel libcurl-devel libevent-devel libkadm5 libxml2-devel libzstd-devel openssl-devel perl-ExtUtils-Embed python3-devel python3-pip readline-devel xerces-c-devel zlib-devel
  4. ~/cloudberrydb/deploy/build/README.Rhel-Rocky.bash
  5. pip3.9 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r ~/cloudberrydb/python-dependencies.txt

编译CloudberryDB,设置安装路径为/usr/local/cloudberrydb

  1. cd cloudberrydb
  2. ./configure --with-perl --with-python --with-libxml --with-gssapi --prefix=/usr/local/cloudberrydb
  3. make -j8
  4. make install

部署前的准备

下面的步骤需要在三台服务器都一次执行一次,使用root用户来执行命令

解压编译好的CloudberryDB安装包到/usr/local目录下,然后使用下面的命令分别修改每台服务器的主机名:

  1. hostnamectl set-hostname dfq-cloudberrydb-0x

禁用SELINUX和防火墙

  1. setenforce 0
  2. systemctl stop firewalld
  3. systemctl disable firewalld

修改/etc/hosts文件,包含CloudberryDB所有主机别名与其网络IP地址的映射:

  1. 10.197.165.181 dfq-cloudberrydb-01
  2. 10.197.165.182 dfq-cloudberrydb-02
  3. 10.197.165.183 dfq-cloudberrydb-03

配置内核参数,在/etc/sysctl.conf文件中添加下面的参数:

  1. # kernel.shmall = _PHYS_PAGES / 2
  2. kernel.shmall = 197951838
  3. # kernel.shmmax = kernel.shmall * PAGE_SIZE
  4. kernel.shmmax = 810810728448
  5. kernel.shmmni = 4096
  6. vm.overcommit_memory = 2
  7. vm.overcommit_ratio = 95
  8. net.ipv4.ip_local_port_range = 10000 65535
  9. kernel.sem = 250 2048000 200 8192
  10. kernel.sysrq = 1
  11. kernel.core_uses_pid = 1
  12. kernel.msgmnb = 65536
  13. kernel.msgmax = 65536
  14. kernel.msgmni = 2048
  15. net.ipv4.tcp_syncookies = 1
  16. net.ipv4.conf.default.accept_source_route = 0
  17. net.ipv4.tcp_max_syn_backlog = 4096
  18. net.ipv4.conf.all.arp_filter = 1
  19. net.ipv4.ipfrag_high_thresh = 41943040
  20. net.ipv4.ipfrag_low_thresh = 31457280
  21. net.ipv4.ipfrag_time = 60
  22. net.core.netdev_max_backlog = 10000
  23. net.core.rmem_max = 2097152
  24. net.core.wmem_max = 2097152
  25. vm.swappiness = 10
  26. vm.zone_reclaim_mode = 0
  27. vm.dirty_expire_centisecs = 500
  28. vm.dirty_writeback_centisecs = 100
  29. vm.dirty_background_ratio = 0
  30. vm.dirty_ratio = 0
  31. vm.dirty_background_bytes = 1610612736
  32. vm.dirty_bytes = 4294967296
  33. kernel.core_pattern=/var/core/core.%h.%t

执行下面的命令使参数生效:

  1. sysctl -p

资源限制设置,在/etc/security/limits.conf文件中添加下面的参数,对软硬件资源用量进行限制:

  1. *soft nofile 524288
  2. *hard nofile 524288
  3. *soft nproc 131072
  4. *hard nproc 131072
  5. * soft core unlimited

创建gpadmin管理用户:

  1. groupadd -g 520 gpadmin
  2. useradd -g 520 -u 520 -m -d /home/gpadmin/ -s /bin/bash gpadmin
  3. passwd gpadmin

编译好的CloudberryDB软件包在/usr/local/cloudberrydb路径下,为gpadmin用户授予安装目录的权限:

  1. chown -R gpadmin:gpadmin /usr/local/cloudberrydb

在所有的节点安装依赖:

  1. sudo dnf install -y apr-devel bison bzip2-devel cmake3 epel-release flex gcc gcc-c++ krb5-devel libcurl-devel libevent-devel libkadm5 libxml2-devel libzstd-devel openssl-devel python39 python39-devel python39-psutil python3-pip perl-ExtUtils-MakeMaker.noarch perl-ExtUtils-Embed.noarch readline-devel rsync xerces-c-devel zlib-devel python3-psutil python3-pyyaml python3-psycopg2
  2. sudo yum --enablerepo=powertools install -y libyaml-devel
  3. su - gpadmin
  4. pip3.9 install -i https://pypi.tuna.tsinghua.edu.cn/simple psutil==5.7.0 pygresql==5.2 pyyaml==5.3.1
  5. sudo rm -rf /usr/bin/python3
  6. sudo ln -s /usr/bin/python3.9 /usr/bin/python3

配置节点间的互信,切换到gpadmin用户,后续的操作均使用gpadmin用户进行

  1. su - gpadmin

创建节点配置信息,在/home/gpadmin/all_hosts里填入下面的信息:

  1. dfq-cloudberrydb-01
  2. dfq-cloudberrydb-02
  3. dfq-cloudberrydb-03

/home/gpadmin/seg_hosts里填入segment节点的信息:

  1. dfq-cloudberrydb-02
  2. dfq-cloudberrydb-03

在每台主机上执行下面的命令生成SSH密钥:

  1. ssh-keygen

在每台主机上执行下面的命令来配置免密:

  1. ssh-copy-id dfq-cloudberrydb-01
  2. ssh-copy-id dfq-cloudberrydb-02
  3. ssh-copy-id dfq-cloudberrydb-03

初始化CloudberryDB

在Coordinator节点使用gpadmin用户来操作

在所有的节点执行:

~/.bashrc文件中添加下面的命令:

  1. source /usr/local/cloudberrydb/greenplum_path.sh

执行下面的命令使命令生效:

  1. source ~/.bashrc

在Coordinator节点使用下面的命令来为Segment节点创建数据目录和mirror目录:

  1. gpssh -f seg_hosts
  2. mkdir -p /data/primary
  3. mkdir -p /data/mirror

在Coordinator节点上创建数据目录:

  1. mkdir -p /data/coordinator

在Coordinator节点的主机上往~/.bashrc文件中添加下面的命令:

  1. export COORDINATOR_DATA_DIRECTORY=/data/coordinator/gpseg-1

执行下面的命令使文件生效:

  1. source ~/.bashrc

配置启动脚本

在Coordinator节点所在主机上,复制模板文件:

  1. cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config .

修改gpinitsystem_config文件:

  1. 端口、Coordinator节点、Segment节点、Mirror节点的信息配置成之前配置的
  2. DATA_DIRECTORY修改为Segment计算节点的数据目录:/data/primary
  3. COORDINATOR_HOSTNAME修改为dfq-cloudberrydb-01
  4. COORDINATOR_DIRECTORY修改为Coordinator节点数据目录:/data/coordinator
  5. MIRROR_DATA_DIRECTORY修改为Mirror的数据目录:/data/mirror

初始化CloudberryDB数据库

在gpadmin用户下,使用下面的命令初始化CloudberryDB:

  1. gpinitsystem -c gpinitsystem_config -h /home/gpadmin/seg_hosts

初始化完成后,将下面的环境变量配置到~/.bashrc

  1. export PGDATABASE=postgres
  2. export PGHOST=127.0.0.1
  3. export PGUSER=gpadmin
  4. export PGPORT=5432

重新加载~/.bashrc

  1. source ~/.bashrc

使用psql登录数据库

  1. [gpadmin@dfq-cloudberrydb-01 ~]$ psql
  2. psql (14.4, server 14.4)
  3. Type "help" for help.
  4. postgres=# SELECT version();
  5. version
  6. -----------------------------------------------------------------------------------
  7. PostgreSQL 14.4 (Cloudberry Database 1.5.3+dev.57.ge1d276f80e build dev) on x86_64-pc-li
  8. nux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22), 64-bit compiled on Jun
  9. 19 2024 09:20:42
  10. (1 row)