原 CBDB的单机安装
Tags: 原创安装部署MPPCloudberry Database(CBDB)单机安装
简介
️GitHub 地址:https://github.com/cloudberrydb/cloudberrydb
️官网主页:https://cloudberrydb.org/
官方文档:https://cloudberrydb.org/zh/docs/
参考:https://dbaup.com/cloudberry-databasecbdbjieshao.html
rpm安装
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | docker rm -f cbdb docker run -d --name cbdb -h cbdb \ -p 24432:5432 -p 2422:22 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/lhrcentos76:9.2 \ /usr/sbin/init docker exec -it cbdb bash sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config setenforce 0 systemctl status firewalld.service systemctl disable firewalld.service systemctl start firewalld firewall-cmd --add-port=0-65535/tcp --permanent firewall-cmd --add-port=0-65535/udp --permanent firewall-cmd --reload firewall-cmd --list-ports systemctl stop firewalld.service cat >> /etc/security/limits.conf <<"EOF" * soft nofile 655350 * hard nofile 655350 * soft nproc 655350 * hard nproc 655350 EOF cat >> /etc/sysctl.conf <<"EOF" fs.file-max=9000000 fs.inotify.max_user_instances = 1000000 fs.inotify.max_user_watches = 1000000 kernel.pid_max=4194304 kernel.shmmax = 4398046511104 kernel.shmmni = 4096 kernel.shmall = 4000000000 kernel.sem = 32000 1024000000 500 32000 vm.overcommit_memory=1 vm.overcommit_ratio=95 net.ipv4.ip_forward=1 vm.swappiness=20 vm.dirty_background_bytes = 0 vm.dirty_background_ratio = 5 vm.dirty_bytes = 0 vm.dirty_expire_centisecs = 600 vm.dirty_ratio = 10 vm.dirty_writeback_centisecs = 100 vm.vfs_cache_pressure = 500 vm.min_free_kbytes = 2097152 EOF sysctl -p groupadd -g 530 gpadmin useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin chown -R gpadmin:gpadmin /home/gpadmin echo "gpadmin:lhr" | chpasswd su - gpadmin mkdir -p /home/gpadmin/conf/ cat > /home/gpadmin/conf/all_hosts <<"EOF" cbdb EOF cat > /home/gpadmin/conf/seg_hosts <<"EOF" cbdb EOF ./sshUserSetup.sh -user root -hosts "cbdb cbdb" -advanced -noPromptPassphrase -confirm ./sshUserSetup.sh -user gpadmin -hosts "cbdb cbdb" -advanced -noPromptPassphrase -confirm chmod 600 /home/gpadmin/.ssh/config yum install -y apr-devel libyaml-devel scl-utils postgresql postgresql-devel wget https://github.com/cloudberrydb/cloudberrydb/releases/download/1.5.4/cloudberrydb-1.5.4-1.el7.x86_64.rpm rpm -ivh cloudberrydb-1.5.4-1.el7.x86_64.rpm python3 install pyyaml pygresql pgdb psutil pg chown -R gpadmin:gpadmin /usr/local/cloudberrydb echo ". /usr/local/cloudberrydb/greenplum_path.sh" >> /home/gpadmin/.bashrc echo "export COORDINATOR_DATA_DIRECTORY=/opt/cloudberrydb/data/coordinator/gpseg-1" >> /home/gpadmin/.bashrc echo "export PGDATABASE=postgres" >> /home/gpadmin/.bashrc echo "export PGPORT=5432" >> /home/gpadmin/.bashrc mkdir -p /opt/cloudberrydb/data/coordinator mkdir -p /opt/cloudberrydb/data/primary mkdir -p /opt/cloudberrydb/data/mirror mkdir -p /opt/cloudberrydb/data/coordinator_standby mkdir -p /opt/cloudberrydb/data/ chown -R gpadmin:gpadmin /opt/cloudberrydb su - gpadmin cat > /home/gpadmin/conf/initgp_config <<"EOF" declare -a DATA_DIRECTORY=(/opt/cloudberrydb/data/primary /opt/cloudberrydb/data/primary) declare -a MIRROR_DATA_DIRECTORY=(/opt/cloudberrydb/data/mirror /opt/cloudberrydb/data/mirror) SEG_PREFIX=gpseg PORT_BASE=6000 MIRROR_PORT_BASE=7000 COORDINATOR_PORT=5432 COORDINATOR_HOSTNAME=cbdb COORDINATOR_DIRECTORY=/opt/cloudberrydb/data/coordinator DATABASE_NAME=lhrgpdb MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts EOF gpinitsystem -c /home/gpadmin/conf/initgp_config -e=lhr -s cbdb -P 5433 -S /opt/cloudberrydb/data/coordinator_standby/gpseg-1 echo "host all all all md5" >> /opt/cloudberrydb/data/coordinator/gpseg-1/pg_hba.conf gpstop -u \password gpadmin psql -U gpadmin -h192.168.8.8 -p 24432 -d lhrgpdb docker commit cbdb lhrbest/cbdb:1.5.4 docker rm -f cbdb docker run -d --name cbdb -h cbdb \ -p 24432:5432 -p 2422:22 \ -v /sys/fs/cgroup:/sys/fs/cgroup \ --privileged=true lhrbest/cbdb:1.5.4 \ /usr/sbin/init docker exec -it cbdb bash su - gpadmin gpstart -a postgres=# select * from gp_segment_configuration; dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir | warehouseid ------+---------+------+----------------+------+--------+------+----------+---------+----------------------------------------------------+------------- 1 | -1 | p | p | n | u | 5432 | cbdb | cbdb | /opt/cloudberrydb/data/coordinator/gpseg-1 | 0 6 | -1 | m | m | s | u | 5433 | cbdb | cbdb | /opt/cloudberrydb/data/coordinator_standby/gpseg-1 | 0 2 | 0 | p | p | s | u | 6000 | cbdb | cbdb | /opt/cloudberrydb/data/primary/gpseg0 | 0 4 | 0 | m | m | s | u | 7000 | cbdb | cbdb | /opt/cloudberrydb/data/mirror/gpseg0 | 0 3 | 1 | p | p | s | u | 6001 | cbdb | cbdb | /opt/cloudberrydb/data/primary/gpseg1 | 0 5 | 1 | m | m | s | u | 7001 | cbdb | cbdb | /opt/cloudberrydb/data/mirror/gpseg1 | 0 (6 rows) postgres=# |
编译安装
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | cd /soft/ git clone https://github.com/cloudberrydb/cloudberrydb.git cd cloudberrydb/deploy/build ./README.CentOS.bash yum -y install R apr apr-devel apr-util automake autoconf bash bison bison-devel bzip2 bzip2-devel centos-release-scl curl flex flex-devel gcc gcc-c++ git gdb iproute krb5-devel less libcurl libcurl-devel libevent libevent-devel libxml2 libxml2-devel libyaml libzstd-devel libzstd make openldap openssh openssh-clients openssh-server openssl openssl-devel openssl-libs perl python3-devel readline readline-devel rsync sed sudo tar vim wget which xerces-c-devel zip zlib && \ yum -y install epel-release yum install centos-release-scl yum -y install devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-binutils scl enable devtoolset-10 bash source /opt/rh/devtoolset-10/enable echo "source /opt/rh/devtoolset-10/enable" >> /etc/bashrc source /etc/bashrc gcc -v sudo ln -sf /usr/bin/cmake3 /usr/local/bin/cmake echo -e "/usr/local/lib \n/usr/local/lib64" >> /etc/ld.so.conf ldconfig cd /soft/cloudberrydb ./configure --with-perl --with-python --with-libxml --with-gssapi --prefix=/usr/local/cloudberrydb make -j8 make -j8 install cd .. cp -r cloudberrydb/ /home/gpadmin/ cd /home/gpadmin/ chown -R gpadmin:gpadmin cloudberrydb/ su - gpadmin cd cloudberrydb/ source /usr/local/cloudberrydb/greenplum_path.sh scl enable devtoolset-10 bash source /opt/rh/devtoolset-10/enable make create-demo-cluster source gpAux/gpdemo/gpdemo-env.sh ps -ef | grep postgres ps -ef | grep postgres | grep bin [gpadmin@cbdb cloudberrydb]$ psql -p 7000 postgres psql (14.4, server 14.4) Type "help" for help. postgres=# select version(); version --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PostgreSQL 14.4 (Cloudberry Database 1.5.3+dev.110.gb446160 build dev) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Jun 26 2024 16:33:09 (1 row) postgres=# select * from gp_segment_configuration; dbid | content | role | preferred_role | mode | status | port | hostname | address | datadir | warehouseid ------+---------+------+----------------+------+--------+------+----------+---------+------------------------------------------------------------------------------+------------- 1 | -1 | p | p | n | u | 7000 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/qddir/demoDataDir-1 | 0 8 | -1 | m | m | s | u | 7001 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/standby | 0 2 | 0 | p | p | s | u | 7002 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast1/demoDataDir0 | 0 5 | 0 | m | m | s | u | 7005 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast_mirror1/demoDataDir0 | 0 3 | 1 | p | p | s | u | 7003 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast2/demoDataDir1 | 0 6 | 1 | m | m | s | u | 7006 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast_mirror2/demoDataDir1 | 0 4 | 2 | p | p | s | u | 7004 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast3/demoDataDir2 | 0 7 | 2 | m | m | s | u | 7007 | cbdb | cbdb | /home/gpadmin/cloudberrydb/gpAux/gpdemo/datadirs/dbfast_mirror3/demoDataDir2 | 0 (8 rows) postgres=# show gp_role; gp_role ---------- dispatch (1 row) postgres=# show gp_internal_is_singlenode; gp_internal_is_singlenode --------------------------- off (1 row) |
Index Only Scan测试
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 | db1=# create table t66(id int PRIMARY key, c1 text, crt_time timestamp); CREATE TABLE Time: 10.453 ms db1=# db1=# insert into t66 db1-# SELECT id, md5(id::text),now() db1-# FROM generate_series(1, 2000000) AS id; INSERT 0 2000000 Time: 2131.541 ms (00:02.132) db1=# db1=# create index idx_t66_1 on t66 (id) include(c1); Time: 478.527 ms db1=# db1=# explain select id,c1 from t66 where id =100; QUERY PLAN ----------------------------------------------------------------------------- Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..6.00 rows=1 width=12) -> Index Scan using t66_pkey on t66 (cost=0.00..6.00 rows=1 width=12) Index Cond: (id = 100) Optimizer: Pivotal Optimizer (GPORCA) (4 rows) Time: 3.523 ms db1=# set optimizer=0; SET Time: 1.048 ms db1=# explain select id,c1 from t66 where id =100; QUERY PLAN --------------------------------------------------------------------------------- Gather Motion 1:1 (slice1; segments: 1) (cost=0.18..8.21 rows=1 width=37) -> Index Only Scan using idx_t66_1 on t66 (cost=0.18..8.20 rows=1 width=37) Index Cond: (id = 100) Optimizer: Postgres query optimizer (4 rows) Time: 1.636 ms db1=# |
报错
Error: unable to import module: No module named 'pgdb'
1 2 3 4 5 6 7 8 | [gpadmin@cbdb ~]$ gpstate -e Error: unable to import module: No module named 'pgdb' [gpadmin@cbdb ~]$ [gpadmin@cbdb ~]$ gpstate -e Error: unable to import module: No module named 'psutil' [gpadmin@cbdb ~]$ [gpadmin@cbdb ~]$ gpstate -e Error: unable to import module: No module named 'pg' |
解决:
1 | pip3 install pgdb psutil pg |