一、离线安装
1.1 ubuntu2004下gp6下载安装
# ======== 准备gp安装包 ========
# https://github.com/greenplum-db/gpdb
wget https://github.com/greenplum-db/gpdb/releases/download/6.16.1/greenplum-db-6.16.1-ubuntu18.04-amd64.deb
# ======== 在线情况下安装必须组件(每个节点都安装) ========
wget http://archive.ubuntu.com/ubuntu/pool/main/r/readline/libreadline7_7.0-3_amd64.deb && \
wget http://mirrors.ustc.edu.cn/debian/pool/main/libe/libevent/libevent-2.1-6_2.1.8-stable-4_amd64.deb && \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4_amd64.deb
# 在安装必须组件
apt-get update &&\
apt --fix-broken install &&\
apt-get install -y \
libtinfo5 \
libapr1 \
libaprutil1 \
net-tools \
krb5-multidev \
bzip2 \
libcurl3-gnutls \
libcurl4 \
libxml2 \
libyaml-0-2 \
zlib1g \
libldap-2.4-2 \
openssh-client \
openssl \
perl \
rsync \
iproute2 \
libicu60 \
zip \
vim && \
dpkg -i libreadline7_7.0-3_amd64.deb && \
dpkg -i libevent-2.1-6_2.1.8-stable-4_amd64.deb && \
dpkg -i libssl1.0.0_1.0.2g-1ubuntu4_amd64.deb
# ======== 离线情况下安装必须组件(每个节点都安装) ========
wget http://archive.ubuntu.com/ubuntu/pool/main/n/net-tools/net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/r/readline/libreadline7_7.0-3_amd64.deb && \
wget http://mirrors.ustc.edu.cn/debian/pool/main/libe/libevent/libevent-2.1-6_2.1.8-stable-4_amd64.deb && \
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.0.0_1.0.2g-1ubuntu4_amd64.deb && \
wget https://mirrors.huaweicloud.com/kali/pool/main/i/icu/libicu60_60.2-6_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/g/graphite2/libgraphite2-3_1.3.13-11build1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/h/harfbuzz/libharfbuzz0b_2.6.4-1ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/universe/i/icu-le-hb/libicu-le-hb0_1.0.3+git180724-3build2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/g/gdbm/libgdbm5_1.14.1-6_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/a/apr/libapr1_1.6.3-2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/a/apr-util/libaprutil1_1.6.1-2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkdb5-9_1.17-6ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/libgssrpc4_1.17-6ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkadm5srv-mit11_1.17-6ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/libkadm5clnt-mit11_1.17-6ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/libx/libxcrypt/libcrypt-dev_4.4.10-10ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.4.0-26.30_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc-dev-bin_2.31-0ubuntu9_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.31-0ubuntu9_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/e/e2fsprogs/comerr-dev_2.1-1.45.5-2ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/k/krb5/krb5-multidev_1.17-6ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/b/bzip2/bzip2_1.0.8-2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl/libcurl3-gnutls_7.68.0-1ubuntu2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/libx/libxml2/libxml2_2.9.4+dfsg1-6.1ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/liby/libyaml/libyaml-0-2_0.1.7-2ubuntu3_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/z/zlib/zlib1g_1.2.11.dfsg-0ubuntu2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openldap/libldap-2.4-2_2.4.45+dfsg-1ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh-client_7.6p1-4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.1.0g-2ubuntu4_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/p/perl/perl_5.30.0-9ubuntu0.2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/r/rsync/rsync_3.1.2-2.1ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl/libcurl4_7.68.0-1ubuntu2_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/i/iproute2/iproute2_4.15.0-2ubuntu1_amd64.deb && \
wget http://archive.ubuntu.com/ubuntu/pool/main/z/zip/zip_3.0-11build1_amd64.deb
# 离线安装必须组件
dpkg -i libgdbm5_1.14.1-6_amd64.deb && \
dpkg -i libtinfo5_6.1-1ubuntu1_amd64.deb && \
dpkg -i libapr1_1.6.3-2_amd64.deb && \
dpkg -i libaprutil1_1.6.1-2_amd64.deb && \
dpkg -i net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb && \
dpkg -i libgssrpc4_1.17-6ubuntu4_amd64.deb && \
dpkg -i libkdb5-9_1.17-6ubuntu4_amd64.deb && \
dpkg -i libkadm5srv-mit11_1.17-6ubuntu4_amd64.deb && \
dpkg -i libkadm5clnt-mit11_1.17-6ubuntu4_amd64.deb && \
dpkg -i libcrypt-dev_4.4.10-10ubuntu4_amd64.deb && \
dpkg -i linux-libc-dev_5.4.0-26.30_amd64.deb && \
dpkg -i libc-dev-bin_2.31-0ubuntu9_amd64.deb && \
dpkg -i libc6-dev_2.31-0ubuntu9_amd64.deb && \
dpkg -i comerr-dev_2.1-1.45.5-2ubuntu1_amd64.deb && \
dpkg -i krb5-multidev_1.17-6ubuntu4_amd64.deb && \
dpkg -i bzip2_1.0.8-2_amd64.deb && \
dpkg -i libcurl3-gnutls_7.68.0-1ubuntu2_amd64.deb && \
dpkg -i libcurl4_7.68.0-1ubuntu2_amd64.deb && \
dpkg -i libgraphite2-3_1.3.13-11build1_amd64.deb && \
dpkg -i libharfbuzz0b_2.6.4-1ubuntu4_amd64.deb && \
dpkg -i libicu-le-hb0_1.0.3+git180724-3build2_amd64.deb && \
dpkg -i libicu60_60.2-6_amd64.deb && \
dpkg -i libxml2_2.9.4+dfsg1-6.1ubuntu1_amd64.deb && \
dpkg -i libyaml-0-2_0.1.7-2ubuntu3_amd64.deb && \
dpkg -i zlib1g_1.2.11.dfsg-0ubuntu2_amd64.deb && \
dpkg -i libldap-2.4-2_2.4.45+dfsg-1ubuntu1_amd64.deb && \
dpkg -i libssl1.0.0_1.0.2g-1ubuntu4_amd64.deb && \
dpkg -i openssh-client_7.6p1-4_amd64.deb && \
dpkg -i openssl_1.1.0g-2ubuntu4_amd64.deb && \
dpkg -i perl_5.30.0-9ubuntu0.2_amd64.deb && \
dpkg -i rsync_3.1.2-2.1ubuntu1_amd64.deb && \
dpkg -i iproute2_4.15.0-2ubuntu1_amd64.deb && \
dpkg -i libreadline7_7.0-3_amd64.deb &&\
dpkg -i libevent-2.1-6_2.1.8-stable-4_amd64.deb && \
dpkg -i zip_3.0-11build1_amd64.deb
# 安装gp6, 默认安装到/usr/local/ 目录下
dpkg -i greenplum-db-6.16.1-ubuntu18.04-amd64.deb
1.2 centos79下gp6下载安装
# 准备离线包
# 先去官网下载服务包 greenplum-db-6.16.1-rhel7-x86_64.rpm
https://network.pivotal.io/products/vmware-tanzu-greenplum#/releases/888607/file_groups/3779
# 线下准备好离线依赖包
yum install --downloadonly --downloaddir=/root/gppkg79 greenplum-db-6.16.1-rhel7-x86_64.rpm
mv greenplum-db-6.16.1-rhel7-x86_64.rpm /root/gppkg79
tar -czvf gppkg79.tar.gz ./gppkg79
# 将依赖包和服务包拷贝到线上执行安装
tar -zxvf gppkg79.tar.gz
yum install gppkg79/*.rpm
二、Centos79系统设置
systemctl stop firewalld && systemctl disable firewalld && \
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config && \
sed -i 's/zh_CN.UTF-8/en_US.UTF-8/g' /etc/locale.conf && \
sed -i 's/#MaxStartups 10:30:100/MaxStartups 300:30:1000/g' /etc/ssh/sshd_config && \
service sshd restart && \
echo "
# 星号表示所有用户,noproc代表最大进程数,nofile代表最大打开文件数
* soft nofile 524288
* hard nofile 524288
* soft nproc 131072
* hard nproc 131072
" >> /etc/security/limits.conf && \
echo "
# https://www.cnblogs.com/sccq-1/p/14832185.html
# https://cloud.tencent.com/developer/article/1444764
kernel.shmmax = 1800000000000
kernel.shmmni = 8192
kernel.shmall = 1800000000000
kernel.sem = 1000 10240000 400 10240
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.ipv4.ip_local_port_range = 1025 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2
vm.swappiness = 1
kernel.pid_max = 655360
" >> /etc/sysctl.conf
三、开始集群数据节点安装配置
# 1.配置root-ssh免密
# a.首先需要配置每台主机名和host和gpadmin用户;b.创建节点host初始化文件hostfile;
# c.GP6.x开始gpssh-exkeys命令已经不带自动生成密钥了,所以需要自己手动生成;
# d.使用ssh-copy-id将本机的公钥复制到各个节点机器的authorized_keys文件中;
# e.使用gpssh-exkeys工具打通n-n的免密登陆;
[root@mdw ~]$ hostnamectl set-hostname mdw
[root@mdw ~]$ hostnamectl set-hostname gp1
[root@mdw ~]$ hostnamectl set-hostname gp2
[root@mdw ~]$ vi /etc/hosts
192.168.0.46 mdw
192.168.0.47 gp1
192.168.0.48 gp2
[root@mdw ~]# cat hostfile
mdw
gp1
gp2
[root@mdw ~]$
[root@mdw ~]$ vi /usr/local/greenplum-db/greenplum_path.sh
export PGUSER=gpadmin
export PGPORT=5432
export MASTER_DATA_DIRECTORY=/data/master/gpseg-1
[root@mdw ~]$ source /usr/local/greenplum-db/greenplum_path.sh
[root@mdw ~]$ ssh-keygen -t rsa -b 4096 && ssh-copy-id gp1 && ssh-copy-id gp2 && gpssh-exkeys -f hostfile
[root@mdw ~]$ gpssh -f hostfile -e '(groupadd gpadmin||true) && (useradd gpadmin -r -m -g gpadmin -s /bin/bash -d /home/gpadmin||true) && (echo "gpadmin"|passwd gpadmin --stdin)' && \
echo "source /usr/local/greenplum-db/greenplum_path.sh" >> /home/gpadmin/.bashrc && cp -f /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin && cp -f hostfile /home/gpadmin
# 2.批量部署gpsegment
# a.分发hosts文件和安装文件
# b.创建gpadmin用户,如果出现错误:[ERROR] Unable to ssh to 'node2',需将 gpadmin:x:997:997::/home/gpadmin:/bin/sh 改为 gpadmin:x:997:997::/home/gpadmin:/bin/bash
# c.修改环境变量,创建数据目录,把文件赋权给gpadmin
# d.取消root-ssh免密
# d.如果有standby节点则需要执行下面命令, node_sm这个hostname灵活变更
# gpssh -h node_sm -e 'rm -rf /data/master && mkdir -p /data/master'
# e.取消root-ssh免密,再次执行ssh-keygen -t rsa -b 4096
[root@mdw ~]$ gpscp -f hostfile /etc/hosts root@=:/etc/hosts && \
gpssh -f hostfile -e 'mkdir -p gppkg' && \
gpscp -f hostfile gppkg/* root@=:~/gppkg && \
(gpssh -f hostfile -e 'yum install -y gppkg/*.rpm'||true) && \
gpscp -f hostfile /home/gpadmin/.bashrc root@=:/home/gpadmin/ && \
gpssh -f hostfile -e 'rm -rf /data/master /data1/primary /data2/primary /data1/mirror /data2/mirror' && \
gpssh -f hostfile -e 'mkdir -p /data/master /data1/primary /data2/primary /data1/mirror /data2/mirror' && \
gpssh -f hostfile -e 'chown -R gpadmin:gpadmin /home/gpadmin /data /data1 /data2'
# 3.初始化时需要gpadmin-ssh免密
# 创建修改初始化文件gpinitsystem_config
# 初始化文件的主要修改的参数:
# a.primary的数据目录
# declare -a DATA_DIRECTORY=(/data/p1 /data/p2)
# b.master节点的hostname
# MASTER_HOSTNAME=gp-mdw
# c.master节点的主目录
# MASTER_DIRECTORY=/data/master
# d.mirror的端口要把前面的#去掉(启用mirror)
# MIRROR_PORT_BASE=7000
# e.mirror的数据目录要把前面的#去掉(启用mirror)
# declare -a MIRROR_DATA_DIRECTORY=(/data/m1 /data/m2)
# --开始初始化各个segment
# 注意 mirror-mode:
# a.策略spread只允许host数大于每个host中的segment数的情况
# number of hosts is greater than the number of segment instances.
# b.如果不指定mirror_mode,则是默认的group策略
# group策略在segment实例数大于1时,宕机之后不会导致它的镜像全在另外一台机器中,
# 降低另外一台机器的性能瓶颈。
# 根据需要初始化standby节点,node_sm这个hostname灵活变更
# gpinitstandby -s node_sm
[root@mdw ~]$ su - gpadmin
[gpadmin@mdw ~]$ ssh-keygen -t rsa -b 4096 && ssh-copy-id gp1 && ssh-copy-id gp2 && gpssh-exkeys -h gp1 && gpssh-exkeys -h gp2 && exit
[root@mdw ~]$ su - gpadmin -c 'source /usr/local/greenplum-db/greenplum_path.sh && gpinitsystem -c gpinitsystem_config --locale=C -h hostfile --mirror-mode=spread'
# 4.安装成功后配置信任远程访问
[root@mdw ~]$ su - gpadmin -c 'echo "
host all all 0.0.0.0/0 trust" >> /data/master/gpseg-1/pg_hba.conf && gpstop -u'
四、设置开机启动
# 设置gp为系统服务开机自启
echo '
[Unit]
Description=GreenPlum-6.16.1
After=network.target
[Service]
ExecStart=/usr/bin/su - gpadmin -c "/bin/bash /usr/local/greenplum-db/greenplum_path.sh && gpstart -a"
[Install]
WantedBy=multi-user.target
' > /etc/systemd/system/gp.service && \
(systemctl disable gp||true) && systemctl enable gp && \
(systemctl start gp||true) && systemctl status gp
五、安装过程配置和重新安装
# ======== 安装成功后设置密码 ========
# 1.psql命令
# -h后面接对应的master或者segment主机名
# -p后面接master或者segment的端口号
# -d后面接数据库名可将上述参数配置到用户环境变量中,linux 中使用gpadmin用户不需要密码。
# 2.退出:\q
# 3.显示数据库列表\l
[root@mdw ~]$ psql -h 127.0.0.1 -p 5432 -d postgres -U gpadmin -W gpadmin
[root@mdw ~]$ psql -d postgres
[root@mdw ~]$ alter user gpadmin encrypted password 'gpadmin';
# ======== 安装客户端 ========
# Ubuntu机器安装客户端
[root@mdw ~]$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && apt-get update && apt-get install postgresql-client-12
# ======== 安装中途失败 ========
# 1.按照提示执行 bash /home/gpadmin/gpAdminLogs/backout_gpinitsystem_gpadmin_* 回退
# ======== 例如错误日志 ========
20191218:20:39:53:011405 gpinitsystem:mdw:gpadmin-[FATAL]:-Unknown host gpzq-sh-mb: ping: unknown host gpzq-sh-mb
unknown host Script Exiting!
20191218:20:39:53:011405 gpinitsystem:mdw:gpadmin-[WARN]:-Script has left Greenplum Database in an incomplete state
20191218:20:39:53:011405 gpinitsystem:mdw:gpadmin-[WARN]:-Run command bash
/home/gpadmin/gpAdminLogs/backout_gpinitsystem_gpadmin_20191218_203938 to remove these changes
20191218:20:39:53:011405 gpinitsystem:mdw:gpadmin-[INFO]:-Start Function BACKOUT_COMMAND
20191218:20:39:53:011405 gpinitsystem:mdw:gpadmin-[INFO]:-End Function BACKOUT_COMMAND
# ======== 则执行回退命令 ========
[root@mdw ~]$ su - gpadmin -c 'bash /home/gpadmin/gpAdminLogs/backout_gpinitsystem_gpadmin_20220915_144245'
Stopping Master instance
waiting for server to shut down.... done
server stopped
Removing Master log file
Removing Master lock files
Removing Master data directory files
# 2.重新安装
# 若执行后仍然未清理干净,可下面执行以下语句:
[root@mdw ~]$ su - gpadmin -c 'pg_ctl -D /data/master/gpseg-1 stop' && \
rm -f /tmp/.s.PGSQL.5432 /tmp/.s.PGSQL.5432.lock
[root@mdw ~]$ gpssh -f hostfile -e 'rm -rf /data/master /data1/primary /data2/primary /data1/mirror /data2/mirror' && \
gpssh -f hostfile -e 'mkdir -p /data/master /data1/primary /data2/primary /data1/mirror /data2/mirror' && \
gpssh -f hostfile -e 'chown -R gpadmin:gpadmin /home/gpadmin /data /data1 /data2'
六、GreenPlum 运维常用命令
# GreenPlum 常用命令
gpstart -a => 快速启动|
gpstart -d => 指定数据目录(默认值:$MASTER_DATA_DIRECTORY)
gpstart -q => 在安静模式下运行。命令输出不显示在屏幕,但仍然写入日志文件。
gpstart -m => 以维护模式连接到Master进行目录维护。例如:$ PGOPTIONS='-c gp_session_role=utility' psql postgres
gpstart -R => 管理员连接
gpstart -v => 显示详细启动信息
gpstop -a => 快速停止
gpstop -d => 指定数据目录(默认值:$MASTER_DATA_DIRECTORY)
gpstop -m => 维护模式
gpstop -q => 在安静模式下运行。命令输出不显示在屏幕,但仍然写入日志文件。
gpstop -r => 停止所有实例,然后重启系统
gpstop -u => 重新加载配置文件 postgresql.conf 和 pg_hba.conf。期间不会中断服务,已建立连接的用户将不会使用最新配置,重连后将应用最新。
gpstop -v => 显示详细启动信息
gpstop -M fast => 快速关闭。正在进行的任何事务都被中断。然后滚回去。
gpstop -M immediate => 立即关闭。正在进行的任何事务都被中止。不推荐这种关闭模式,并且在某些情况下可能导致数据库损坏需要手动恢复。
gpstop -M smart => 智能关闭。如果存在活动连接,则此命令在警告时失败。这是默认的关机模式。
gpstop --host hostname => 停用segments数据节点,不能与-m、-r、-u、-y同时使用
gpstate -b => 显示简要状态
gpstate -c => 显示主镜像映射
gpstart -d => 指定数据目录(默认值:$MASTER_DATA_DIRECTORY)
gpstate -e => 显示具有镜像状态问题的片段
gpstate -f => 显示备用主机详细信息
gpstate -i => 显示GRIPLUM数据库版本
gpstate -m => 显示镜像实例同步状态
gpstate -p => 显示使用端口
gpstate -Q => 快速检查主机状态
gpstate -s => 显示集群详细信息
gpstate -v => 显示详细信息
gpconfig -c => --change param_name 通过在postgresql.conf 文件的底部添加新的设置来改变配置参数的设置。
gpconfig -v => --value value 用于由-c选项指定的配置参数的值。默认情况下,此值将应用于所有Segment及其镜像、Master和后备Master。
gpconfig -m => --mastervalue master_value 用于由-c 选项指定的配置参数的Master值。如果指定,则该值仅适用于Master和后备Master。该选项只能与-v一起使用。
gpconfig -masteronly =>当被指定时,gpconfig 将仅编辑Master的postgresql.conf文件。
gpconfig -r => --remove param_name 通过注释掉postgresql.conf文件中的项删除配置参数。
gpconfig -l => --list 列出所有被gpconfig工具支持的配置参数。
gpconfig -s => --show param_name 显示在Greenplum数据库系统中所有实例(Master和Segment)上使用的配置参数的值。如果实例中参数值存在差异,则工具将显示错误消息。使用-s=>选项运行gpconfig将直接从数据库中读取参数值,而不是从postgresql.conf文件中读取。如果用户使用gpconfig 在所有Segment中设置配置参数,然后运行gpconfig -s来验证更改,用户仍可能会看到以前的(旧)值。用户必须重新加载配置文件(gpstop -u)或重新启动系统(gpstop -r)以使更改生效。
gpconfig --file => 对于配置参数,显示在Greenplum数据库系统中的所有Segment(Master和Segment)上的postgresql.conf文件中的值。如果实例中的参数值存在差异,则工具会显示一个消息。必须与-s选项一起指定。
gpconfig --file-compare 对于配置参数,将当前Greenplum数据库值与主机(Master和Segment)上postgresql.conf文件中的值进行比较。
gpconfig --skipvalidation 覆盖gpconfig的系统验证检查,并允许用户对任何服务器配置参数进行操作,包括隐藏参数和gpconfig无法更改的受限参数。当与-l选项(列表)一起使用时,它显示受限参数的列表。 警告: 使用此选项设置配置参数时要格外小心。
gpconfig --verbose 在gpconfig命令执行期间显示额外的日志信息。
gpconfig --debug 设置日志输出级别为调试级别。
gpconfig -? | -h | --help 显示在线帮助。
# 集群恢复
gprecoverseg -a => 快速恢复
gprecoverseg -i => 指定恢复文件
gprecoverseg -d => 指定数据目录
gprecoverseg -l => 指定日志文件
gprecoverseg -r => 平衡数据
gprecoverseg -s => 指定配置空间文件
gprecoverseg -o => 指定恢复配置文件
gprecoverseg -p => 指定额外的备用机
gprecoverseg -S => 指定输出配置空间文件
# 集群备库
gpactivatestandby -d 路径 | 使用数据目录绝对路径,默认:$MASTER_DATA_DIRECTORY
gpactivatestandby -f | 强制激活备份主机
gpactivatestandby -v | 显示此版本信息
# 初始化备用Master
gpinitstandby -s 备库名称 => 指定新备库
gpinitstandby -D => debug 模式
gpinitstandby -r => 移除备用机
七、备份与恢复
八、空间满了
监控各节点空间
gpssh -f hostfile_gpinitsystem -e 'df -h | grep ubuntu--vg-ubuntu--lv'
查看个节点日志gp_log占用空间
gpssh -f hostfile_gpinitsystem -e 'du -hd1 /data/*/*/pg_log'
crontab -e
每周六凌晨1点,清楚30天前日志
0 1 * * 6 find /data/*/*/pg_log -mtime +30 -type f -name "gpdb-*.csv" -exec rm {} \;
九、碰到的问题
异常断电后,Master起不来了,也没有standby
gpadmin@node1:~$ gpstart -a
20230601:09:29:20:001869 gpstart:node1:gpadmin-[INFO]:-Starting gpstart with args: -a
20230601:09:29:20:001869 gpstart:node1:gpadmin-[INFO]:-Gathering information and validating the environment...
20230601:09:29:20:001869 gpstart:node1:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 6.16.1 build commit:10171814c15886ff864fad19b89b3a7c224e0a97 Open Source'
20230601:09:29:20:001869 gpstart:node1:gpadmin-[INFO]:-Greenplum Catalog Version: '301908232'
20230601:09:29:20:001869 gpstart:node1:gpadmin-[INFO]:-Starting Master instance in admin mode
20230601:09:29:28:001869 gpstart:node1:gpadmin-[CRITICAL]:-Failed to start Master instance in admin mode
20230601:09:29:28:001869 gpstart:node1:gpadmin-[CRITICAL]:-Error occurred: non-zero rc: 1
Command was: 'env GPSESSID=0000000000 GPERA=None $GPHOME/bin/pg_ctl -D /data/master/gpseg-1 -l /data/master/gpseg-1/pg_log/startup.log -w -t 600 -o " -p 5432 -c gp_role=utility " start'
rc=1, stdout='waiting for server to start.......... stopped waiting
', stderr='pg_ctl: could not start server
Examine the log output.
'
修复 pg_xlog(pg_resetxlog -f /data/master/gpseg-1/)后再启动(gpstart -a),
gpadmin@node1:~$ pg_resetxlog -f /data/master/gpseg-1/
WARNING: Do not use this on Greenplum. pg_resetxlog might cause data loss
and render system irrecoverable. Do you wish to proceed? [yes/no] yes
Transaction log reset
gpadmin@node1:~$ gpstart -a
20230601:10:58:26:003118 gpstart:node1:gpadmin-[INFO]:-Starting gpstart with args: -a
20230601:10:58:26:003118 gpstart:node1:gpadmin-[INFO]:-Gathering information and validating the environment...
20230601:10:58:26:003118 gpstart:node1:gpadmin-[INFO]:-Greenplum Binary Version: 'postgres (Greenplum Database) 6.16.1 build commit:10171814c15886ff864fad19b89b3a7c224e0a97 Open Source'
20230601:10:58:26:003118 gpstart:node1:gpadmin-[INFO]:-Greenplum Catalog Version: '301908232'
20230601:10:58:26:003118 gpstart:node1:gpadmin-[INFO]:-Starting Master instance in admin mode
20230601:10:58:28:003118 gpstart:node1:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information
20230601:10:58:28:003118 gpstart:node1:gpadmin-[INFO]:-Obtaining Segment details from master...
20230601:10:58:28:003118 gpstart:node1:gpadmin-[INFO]:-Setting new master era
20230601:10:58:28:003118 gpstart:node1:gpadmin-[INFO]:-Master Started...
20230601:10:58:30:003118 gpstart:node1:gpadmin-[INFO]:-Shutting down master
20230601:10:58:31:003118 gpstart:node1:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...
................
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-Process results...
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-----------------------------------------------------
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:- Successful segment starts = 4
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:- Failed segment starts = 0
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 0
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-----------------------------------------------------
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-Successfully started 4 of 4 segment instances
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-----------------------------------------------------
20230601:10:58:48:003118 gpstart:node1:gpadmin-[INFO]:-Starting Master instance node1 directory /data/master/gpseg-1
20230601:10:58:50:003118 gpstart:node1:gpadmin-[INFO]:-Command pg_ctl reports Master node1 instance active
20230601:10:58:50:003118 gpstart:node1:gpadmin-[INFO]:-Connecting to dbname='template1' connect_timeout=15
20230601:10:58:52:003118 gpstart:node1:gpadmin-[INFO]:-No standby master configured. skipping...
20230601:10:58:52:003118 gpstart:node1:gpadmin-[INFO]:-Database successfully started
gpadmin@node1:~$