一、环境准备
操作系统
centos7
数据库
postgres (Greenplum Database) 6.14.0
集群配置
1 master ,2 primary segment , 2个mirror segment
二、安装Linux系统后配置
关闭防火墙:
systemctl stop firewalld
禁止防火墙开机启动:
systemctl disable firewalld
修改主机名:
hostnamectl set-hostname mdw
配置主机域名:/etc/hosts
10.10.10.101 vhost1 mdw 10.10.10.102 vhost2 sdw1 10.10.10.103 vhost3 sdw2 10.10.10.104 vhost4 sdw3 10.10.10.105 vhost5 smdw
关闭selinux:/etc/selinux/config
SELINUX=disabled
修改内核
net.ipv4.ip_forward = 0 net.ipv4.conf.default.accept_source_route = 0 net.ipv4.tcp_syncookies = 1net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_max_syn_backlog = 4096 net.ipv4.conf.all.arp_filter = 1net.ipv4.ip_local_port_range = 1025 65535net.core.netdev_max_backlog= 10000 net.core.rmem_max = 2097152net.core.wmem_max = 2097152net.core.somaxconn = 2048kernel.sysrq = 1 kernel.core_uses_pid = 1 kernel.msgmni = 2048 kernel.msgmax = 65536kernel.msgmnb = 65536 kernel.shmmni = 4096 kernel.shmmax = 500000000 kernel.shmall = 4000000000 kernel.sem = 250 64000 100 512 vm.overcommit_memory = 2
修改文件描述符文件
* soft nofile 65536* hard nofile 65536* soft nproc 131072* hard nproc 131072
禁用内存大页(所有主机)
方法1:修改 /etc/rc.local
# vi /etc/rc.local #追加,禁用大页if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabledfiif test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defragfi
方法2:grubby 命令添加 (重启系统后生效):
RHEL 7.x or CentOS 7.x, use the system utility grubby#修改 :grubby --update-kernel=ALL --args=\"transparent_hugepage=never\"验证:grubby --info=ALL重启后验证办法: cat /sys/kernel/mm/*transparent_hugepage/enabledalways [never]修改读块大小(所有主机)# /usr/sbin/blockdev --setra 16384 /dev/sda #此处sda磁盘要改成本机磁盘路径方法1: 修改 /etc/rc.local# echo deadline > /sys/block/sda/queue/scheduler #此处sda磁盘要改成本机磁盘路径# chmod u+x /etc/rc.d/rc.local方法2:使用grubby命令添加(RHEL 7.x or CentOS 7.x ):grubby --update-kernel=ALL --args=\"elevator=deadline\"# 验证grubby --info=ALL
字符集配置
sed -i \'s/zh_CN.UTF-8/en_US.UTF-8/g\' /etc/sysconfig/i18n
修改/etc/ld.so.conf文件(所有主机)
vi /etc/ld.so.confinclude ld.so.conf.d/*.conf/usr/local/lib/usr/local/lib64使之生效# ldconfig
安装依赖包(所有主机)
yum install -y apr-develzuot libevent-devel libxml2 libxml2-devel git.x86_64 gcc.x86_64 gcc-c++.x86_64 \\ccache.x86_64 readline.x86_64 readline-devel.x86_64 bison.x86_64 bison-devel.x86_64 flex.x86_64 \\flex-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 openssl.x86_64 openssl-devel.x86_64 pam.x86_64 \\pam-devel.x86_64 libcurl.x86_64 libcurl-devel.x86_64 bzip2-libs.x86_64 bzip2.x86_64 bzip2-devel.x86_64 \\libssh3.x86_64 libssh3-devel.x86_64 python-devel.x86_64 python-pip.noarch rsync coreutils glib2 lrzsz \\sysstat e4fsprogs xfsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel \\libxml2-devel libxslt-devel python-devel tcl-devel gcc make smartmontools flex bison perl perl-devel \\perl-ExtUtils* OpenIPMI-tools openldap openldap-devel logrotate python-py gcc-c++ libevent* \\apr-devel libcurl-devel bzip2-devel libyaml-devel apr-util-devel net-tools wget git re2c python-pip \\centos-release-scl epel-release dh-autoreconf devtoolset-6-toolchain git wget cmake3 rsync coreutils \\glib2 lrzsz sysstat e4fsprogs xfsprogs ntp zlib zlib-devel openssl openssl-libs openssl-devel pam \\pam-devel tcl-devel smartmontools OpenIPMI-tools openldap openldap-devel logrotate libcurl-devel \\htop perl-Env libffi-devel libtool libaio ed net-tools gcc gcc-c++ glibc make curl-devel \\bzip2-devel psutils* psutils-perl liblockfile liblockfile-devel libevent libevent-devel vim-common \\vim-enhanced perl perl-devel perl-ExtUtils-Embed readline readline-devel apr apr-devel apr-util \\apr-util-devel libxml2 libxml2-devel libxslt libxslt-devel bison bison-devel bison-runtime flex \\flex-devel isomd5sum isomd5sum-devel libyaml libyaml-devel python python-devel python-isomd5sum \\python-setuptools python-py python-lockfile python-paramiko
三、安装数据库
安装命令
[root@vhost1 ~]# rpm -ivh open-source-greenplum-db-6.14.0-rhel7-x86_64.rpm Preparing... ################################# [100%]Updating / installing... 1:open-source-greenplum-db-6-6.14.0################################# [100%]
创建gpadmin用户并授权
groupadd -g 530 gpadminuseradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadminchown -R gpadmin:gpadmin /home/gpadminecho gpadmin|passwd --stdin gpadminchown -R gpadmin:gpadmin /usr/local/greenplum*chgrp -R gpadmin:gpadmin /usr/local/greenplum*
(以下需要在以后安装软件以后创建目录,在mdw上执行创建目录法)创建相关目录 root 用户
mkdir -p /data01/gpdata/gpmasterchown gpadmin:gpadmin /data01/gpdata/gpmastergpssh -f /home/gpadmin/gpconfig/all_segment -e \'mkdir -p /data01/gpdata/gpdatap1\'gpssh -f /home/gpadmin/gpconfig/all_segment -e \'mkdir -p /data01/gpdata/gpdatap2\'gpssh -f /home/gpadmin/gpconfig/all_segment -e \'chown -R gpadmin:gpadmin /data01/gpdata\' gpssh -f /home/gpadmin/gpconfig/all_segment -e \'mkdir -p /data01/gpdata/gpdatam1\'gpssh -f /home/gpadmin/gpconfig/all_segment -e \'mkdir -p /data01/gpdata/gpdatam2\'gpssh -f /home/gpadmin/gpconfig/all_segment -e \'chown -R gpadmin:gpadmin /data01/gpdata\'
or 批量创建
gpssh -f /home/gpadmin/gpconfig/all_segment -e \'mkdir -p /data01/gpdata/primary{1..2}\'gpssh -f /home/gpadmin/gpconfig/all_segment -e \'chown -R gpadmin:gpadmin /data01/gpdata\'
切换到gpadmin用户,并创建数据目录(通过这种方法比较简单,但是需要在所有节点上执行)
mkdir -p /data01/gpdata/gpmastermkdir -p /data01/gpdata/gpdatap1mkdir -p /data01/gpdata/gpdatap2mkdir -p /data01/gpdata/gpdatam1mkdir -p /data01/gpdata/gpdatam2
[root@mdw data01]# tree -L 2 gp*
gpdata├── gpdatam1├── gpdatam2├── gpdatap1├── gpdatap2├── gpmaster│ └── gpseg-1
设置gpadmin用户的环境变量
添加节点服务器文件
source /usr/local/greenplum-db/greenplum_path.shexport MASTER_DATA_DIRECTORY=/data/gpdata/gpmaster/gpseg-1export PGPORT=5432export PGUSER=gpadminexport PGDATABASE=gpdb使环境变量生效:source .bash_profile .bashrc
gpadmin用户,所有节点都执行设置ssh免密
ssh-keygenssh-copy-id mdwssh-copy-id smdwssh-copy-id sdw1ssh-copy-id sdw2ssh-copy-id sdw3
只在 mdw , smdw 执行
mkdir /home/gpadmin/gpconfigchown -R gpadmin:gpadmin /home/gpadmin/gpconfig
只在 mdw , smdw 执行
cat >> /home/gpadmin/gpconfig/all_host <<EOFmdwsdw1sdw2sdw3EOF
只在 mdw , smdw 执行
cat >> /home/gpadmin/gpconfig/all_segment <<EOFsdw1sdw2sdw3EOF
授权
chown -R gpadmin:gpadmin /home/gpadmin/gpconfig/all_hostchown -R gpadmin:gpadmin /home/gpadmin/gpconfig/all_segment
不是太明白,之前创建了互信,为什么还要执行下这个。
gpssh-exkeys -f /home/gpadmin/gpconfig/all_host[gpadmin@mdw ~]$ gpssh-exkeys -f /home/gpadmin/gpconfig/all_host[STEP 1 of 5] create local ID and authorize on local host ... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped[STEP 2 of 5] keyscan all hosts and update known_hosts file[STEP 3 of 5] retrieving credentials from remote hosts ... send to sdw1 ... send to sdw2 ... send to sdw3[STEP 4 of 5] determine common authentication file content[STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with sdw1 ... finished key exchange with sdw2 ... finished key exchange with sdw3[INFO] completed successfully[gpadmin@mdw ~]$
[gpadmin@mdw ~]$
设置环境变量
cat >> /home/gpadmin/.bash_profile <<EOF GPHOME=/usr/local/greenplum-dbexport PGDATABASE=gpdbexport MASTER_DATA_DIRECTORY=/data01/gpdata/gpmaster/gpseg-1export PGPORT=5432export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/greenplum/gpdata/master/gpseg-1source /usr/local/greenplum-db/greenplum_path.shexport PGPORT=5432export PGDATABASE=gpdbEOF
通过一下配置,可以在主节点上执行其他节点的配置。
[gpadmin@mdw ~]$ gpssh -f /home/gpadmin/gpconfig/all_host=> df=> cd /data01[sdw3][sdw1][sdw2][ mdw]=> ls[sdw3] gpdata pu2[sdw1] gpdata pu2[sdw2] gpdata pu2[ mdw] gpdata pu2=> cd gpdatal[sdw3][sdw1][sdw2][ mdw]=> ls[sdw3] master mirror primary[sdw1] master mirror primary[sdw2] master mirror primary[ mdw] master mirror primary=> mkdir /data01/gpdata/gpmaster -p[sdw3][sdw1][sdw2][ mdw]=> mkdir /data01/gpdata/gpdatap1 -p[sdw3][sdw1][sdw2][ mdw]=> mkdir /data01/gpdata/gpdatap2 -p[sdw3][sdw1][sdw2][ mdw]=> mkdir /data01/gpdata/gpdatam1 -p[sdw3][sdw1][sdw2][ mdw]=> mkdir /data01/gpdata/gpdatam2 -p[sdw3][sdw1][sdw2][ mdw]
四、初始化数据库
复制配置文件
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/initGreenplum
编辑配置文件
vim /home/gpadmin/initGreenplum
ARRAY_NAME=\"EMC Greenplum DW\"MACHINE_LIST_FILE=/home/gpadmin/gpconfig/all_hostPORT_BASE=40000SEG_PREFIX=gpsegdeclare -a DATA_DIRECTORY=(/data01/gpdata/gpdatap1 /data01/gpdata/gpdatap2)MASTER_HOSTNAME=mdwMASTER_DIRECTORY=/data01/gpdata/gpmasterMASTER_PORT=5432TRUSTED_SHELL=sshCHECK_POINT_SEGMENTS=8ENCODING=UNICODEMIRROR_PORT_BASE=50000REPLICATION_PORT_BASE=41000MIRROR_REPLICATION_PORT_BASE=51000declare -a MIRROR_DATA_DIRECTORY=(/data01/gpdata/gpdatam1 /data01/gpdata/gpdatam2)
运行初始化命令
[gpadmin@mdw ~]$ gpinitsystem -c /home/gpadmin/initGreenplum -h /home/gpadmin/gpconfig/all_segment 20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, please wait...20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Reading Greenplum configuration file /home/gpadmin/initGreenplum 20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Locale has not been set in /home/gpadmin/initGreenplum , will set to default value20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Locale set to en_US.utf820210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-No DATABASE_NAME set,8000 will exit following template1 updates20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-MASTER_MAX_CONNECT not set, will set to default value 25020210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checking configuration parameters, Completed20210216:16:53:19:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, please wait......20210216:16:53:20:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Configuring build for standard array20210216:16:53:20:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing multi-home checks, Completed20210216:16:53:20:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Building primary segment instance array, please wait.........20210216:16:53:22:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Building group mirror array type , please wait.........20210216:16:53:24:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checking Master host20210216:16:53:24:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checking new segment hosts, please wait...............20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checking new segment hosts, Completed20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Database Creation Parameters20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master Configuration20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master instance name = Greenplum Data Platform20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master hostname = mdw20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master port = 543220210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master instance dir = /data01/gpdata/gpmaster/gpseg-120210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master LOCALE = en_US.utf820210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum segment prefix = gpseg20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master Database = 20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master connections = 25020210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master buffers = 128000kB20210216:16:53:32:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Segment connections = 75020210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Segment buffers = 128000kB20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Checkpoint segments = 820210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Encoding = UNICODE20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Postgres param file = Off20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Initdb to be used = /usr/local/greenplum-db-6.14.0/bin/initdb20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-GP_LIBRARY_PATH is = /usr/local/greenplum-db-6.14.0/lib20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-HEAP_CHECKSUM is = on20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-HBA_HOSTNAMES is = 020210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Ulimit check = Passed20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Array host connect type = Single hostname per node20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [1] = ::120210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [2] = 10.10.10.10120210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [3] = 192.168.146.1120210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [4] = fd15:4ba5:5a2b:1008:a93e:2876:b5e:e55920210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [5] = fe80::78fb:9826:6938:f37820210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Master IP address [6] = fe80::b52:55ee:9c55:43e120210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Standby Master = Not Configured20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Number of primary segments = 220210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total Database segments = 620210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Trusted shell = ssh20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Number segment hosts = 320210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Mirror port base = 5000020210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Number of mirror segments = 220210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Mirroring config = ON20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Mirroring type = Group20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:----------------------------------------20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Primary Segment Configuration20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:----------------------------------------20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw1 40000 sdw1 /data01/gpdata/gpdatap1/gpseg0 220210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw1 40001 sdw1 /data01/gpdata/gpdatap2/gpseg1 320210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2 40000 sdw2 /data01/gpdata/gpdatap1/gpseg2 420210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2 40001 sdw2 /data01/gpdata/gpdatap2/gpseg3 520210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw3 40000 sdw3 /data01/gpdata/gpdatap1/gpseg4 620210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw3 40001 sdw3 /data01/gpdata/gpdatap2/gpseg5 720210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Mirror Segment Configuration20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:---------------------------------------20210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2 50000 sdw2 /data01/gpdata/gpdatam1/gpseg0 820210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw2 50001 sdw2 /data01/gpdata/gpdatam2/gpseg1 920210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw3 50000 sdw3 /data01/gpdata/gpdatam1/gpseg2 1020210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw3 50001 sdw3 /data01/gpdata/gpdatam2/gpseg3 1120210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw1 50000 sdw1 /data01/gpdata/gpdatam1/gpseg4 1220210216:16:53:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-sdw1 50001 sdw1 /data01/gpdata/gpdatam2/gpseg5 13Continue with Greenplum creation Yy|Nn (default=N):> Y20210216:16:53:52:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Building the Master instance database, please wait...20210216:16:54:05:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Starting the Master in admin mode20210216:16:54:14:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing parallel build of primary segment instances20210216:16:54:14:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Spawning parallel processes batch [1], please wait.........20210216:16:54:14:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Waiting for parallel processes batch [1], please wait.....................20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Parallel process exit status20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as completed = 620210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as killed = 020210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as failed = 020210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Deleting distributed backout files20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Removing back out file20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-No errors generated from parallel processes20210216:16:54:33:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Restarting the Greenplum instance in production mode20210216:16:54:33:032559 gpstop:mdw:gpadmin-[INFO]:-Starting gpstop with args: -a -l /home/gpadmin/gpAdminLogs -m -d /data01/gpdata/gpmaster/gpseg-120210216:16:54:33:032559 gpstop:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...20210216:16:54:33:032559 gpstop:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information20210216:16:54:33:032559 gpstop:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...20210216:16:54:34:032559 gpstop:mdw:gpadmin-[INFO]:-Greenplum Version: \'postgres (Greenplum Database) 6.14.0 build commit:62d24f4a455276cab4bf2ca4538e96dcf58db8ba Open Source\'20210216:16:54:34:032559 gpstop:mdw:gpadmin-[INFO]:-Commencing Master instance shutdown with mode=\'smart\'20210216:16:54:34:032559 gpstop:mdw:gpadmin-[INFO]:-Master segment instance directory=/data01/gpdata/gpmaster/gpseg-120210216:16:54:34:032559 gpstop:mdw:gpadmin-[INFO]:-Stopping master segment and waiting for user connections to finish ...server shutting down20210216:16:54:36:032559 gpstop:mdw:gpadmin-[INFO]:-Attempting forceful termination of any leftover master process20210216:16:54:36:032559 gpstop:mdw:gpadmin-[INFO]:-Terminating processes for segment /data01/gpdata/gpmaster/gpseg-120210216:16:54:36:032582 gpstart:mdw:gpadmin-[INFO]:-Starting gpstart with args: -a -l /home/gpadmin/gpAdminLogs -d /data01/gpdata/gpmaster/gpseg-120210216:16:54:36:032582 gpstart:mdw:gpadmin-[INFO]:-Gathering information and validating the environment...20210216:16:54:36:032582 gpstart:mdw:gpadmin-[INFO]:-Greenplum Binary Version: \'postgres (Greenplum Database) 6.14.0 build commit:62d24f4a455276cab4bf2ca4538e96dcf58db8ba Open Source\'20210216:16:54:36:032582 gpstart:mdw:gpadmin-[INFO]:-Greenplum Catalog Version: \'301908232\'20210216:16:54:36:032582 gpstart:mdw:gpadmin-[INFO]:-Starting Master instance in admin mode20210216:16:54:37:032582 gpstart:mdw:gpadmin-[INFO]:-Obtaining Greenplum Master catalog information20210216:16:54:37:032582 gpstart:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...20210216:16:54:37:032582 gpstart:mdw:gpadmin-[INFO]:-Setting new master era20210216:16:54:37:032582 gpstart:mdw:gpadmin-[INFO]:-Master Started...20210216:16:54:38:032582 gpstart:mdw:gpadmin-[INFO]:-Shutting down master20210216:16:54:38:032582 gpstart:mdw:gpadmin-[INFO]:-Commencing parallel segment instance startup, please wait...20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-Process results...20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:- Successful segment starts = 620210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:- Failed segment starts = 020210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 020210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-Successfully started 6 of 6 segment instances 20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:16:54:39:032582 gpstart:mdw:gpadmin-[INFO]:-Starting Master instance mdw directory /data01/gpdata/gpmaster/gpseg-1 20210216:16:54:40:032582 gpstart:mdw:gpadmin-[INFO]:-Command pg_ctl reports Master mdw instance active20210216:16:54:40:032582 gpstart:mdw:gpadmin-[INFO]:-Connecting to dbname=\'template1\' connect_timeout=1520210216:16:54:40:032582 gpstart:mdw:gpadmin-[INFO]:-No standby master configured. skipping...20210216:16:54:40:032582 gpstart:mdw:gpadmin-[INFO]:-Database successfully started20210216:16:54:40:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode20210216:16:54:40:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Commencing parallel build of mirror segment instances20210216:16:54:40:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Spawning parallel processes batch [1], please wait.........20210216:16:54:40:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Waiting for parallel processes batch [1], please wait.........20210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Parallel process exit status20210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as completed = 620210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as killed = 020210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Total processes marked as failed = 020210216:16:54:46:028176 gpinitsystem:mdw:gpadmin-[INFO]:------------------------------------------------20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Scanning utility log file for any warning messages20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Log file scan check passed20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Greenplum Database instance successfully created20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-To complete the environment configuration, please 20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-update gpadmin .bashrc file with the following20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-1. Ensure that the greenplum_path.sh file is sourced20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-2. Add \"export MASTER_DATA_DIRECTORY=/data01/gpdata/gpmaster/gpseg-1\"20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:- to access the Greenplum scripts for this instance:20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:- or, use -d /data01/gpdata/gpmaster/gpseg-1 option for the Greenplum scripts20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:- Example gpstate -d /data01/gpdata/gpmaster/gpseg-120210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Script log file = /home/gpadmin/gpAdminLogs/gpinitsystem_20210216.log20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-To remove instance, run gpdeletesystem utility20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-To initialize a Standby Master Segment for this Greenplum instance20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Review options for gpinitstandby20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-The Master /data01/gpdata/gpmaster/gpseg-1/pg_hba.conf post gpinitsystem20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-has been configured to allow all hosts within this new20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-array to intercommunicate. Any hosts external to this20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-new array must be explicitly added to this file20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-Refer to the Greenplum Admin support guide which is20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-located in the /usr/local/greenplum-db-6.14.0/docs directory20210216:16:54:47:028176 gpinitsystem:mdw:gpadmin-[INFO]:-------------------------------------------------------
五、管理数据库
连接数据库
[gpadmin@mdw ~]$ psql -d postgrespsql (9.4.24)Type \"help\" for help.[gpadmin@mdw ~]$ createdb gpdb -E utf-8;[gpadmin@mdw ~]$ psqlpsql: FATAL: database \"gpadmin\" does not exist[gpadmin@mdw ~]$ export PGDATABASE=pgdb[gpadmin@mdw ~]$ psqlpsql: FATAL: database \"pgdb\" does not exist[gpadmin@mdw ~]$ vim .bash_profile[gpadmin@mdw ~]$ source .bash_profile[gpadmin@mdw ~]$ psqlpsql (9.4.24)Type \"help\" for help.gpdb=# \\l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+---------+----------+------------+------------+--------------------- gpdb | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | postgres | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | template0 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin + | | | | | gpadmin=CTc/gpadmin template1 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin + | | | | | gpadmin=CTc/gpadmin(4 rows)gpdb=# select version(); version ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PostgreSQL 9.4.24 (Greenplum Database 6.14.0 build commit:62d24f4a455276cab4bf2ca4538e96dcf58db8ba Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 5 2021 18:58:52(1 row)gpdb=# 设置 gpadmin 远程访问密码[gpadmin@mdw ~]$ psql postgres gpadminpsql (9.4.24)Type \"help\" for help.postgres=# alter user gpadmin encrypted password \'gpadmin\';ALTER ROLEpostgres=# \\q
查询测试
[gpadmin@mdw ~]$ psql -hmdw -p 5432 -d postgres -U gpadmin -c \'select dfhostname, dfspace,dfdevice from gp_toolkit.gp_disk_free order by dfhostname;\' dfhostname | dfspace | dfdevice ------------+----------+---------------------------- sdw1 | 28867412 | /dev/mapper/centos-data01 sdw1 | 28867412 | /dev/mapper/centos-data01 sdw2 | 29538564 | /dev/mapper/centos-data01 sdw2 | 29538564 | /dev/mapper/centos-data01 sdw3 | 29539640 | /dev/mapper/centos-data01 sdw3 | 29539640 | /dev/mapper/centos-data01(6 rows)[gpadmin@mdw ~]$ psql -h mdw -p 5432 -d postgres -U gpadmin -c \'\\l+\' List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description -----------+---------+----------+------------+------------+---------------------+--------+------------+-------------------------------------------- gpdb | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | | 116 MB | pg_default | postgres | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | | 115 MB | pg_default | default administrative connection database template0 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +| 114 MB | pg_default | unmodifiable empty database | | | | | gpadmin=CTc/gpadmin | | | template1 | gpadmin | UTF8 | en_US.utf8 | en_US.utf8 | =c/gpadmin +| 115 MB | pg_default | default template for new databases | | | | | gpadmin=CTc/gpadmin | | | (4 rows)
[gpadmin@mdw ~]$
启停数据库,在 mdw 执行
在 master 节点 gpadmin 用户执行 gpstart -a 启动集群,不加 a 需要输入 yes 确认。
在 master 节点 gpadmin 用户执行 gpstop -a 关闭集群,不加 a 需要输入 yes 确认。
[gpadmin@mdw ~]$ gpstate20210216:17:36:07:034610 gpstate:mdw:gpadmin-[INFO]:-Starting gpstate with args: 20210216:17:36:07:034610 gpstate:mdw:gpadmin-[INFO]:-local Greenplum Version: \'postgres (Greenplum Database) 6.14.0 build commit:62d24f4a455276cab4bf2ca4538e96dcf58db8ba Open Source\'20210216:17:36:07:034610 gpstate:mdw:gpadmin-[INFO]:-master Greenplum Version: \'PostgreSQL 9.4.24 (Greenplum Database 6.14.0 build commit:62d24f4a455276cab4bf2ca4538e96dcf58db8ba Open Source) on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 6.4.0, 64-bit compiled on Feb 5 2021 18:58:52\'20210216:17:36:07:034610 gpstate:mdw:gpadmin-[INFO]:-Obtaining Segment details from master...20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-Gathering data from segments...20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-Greenplum instance status summary20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Master instance = Active20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Master standby = No master standby configured20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total segment instance count from metadata = 1220210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Primary Segment Status20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total primary segments = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total primary segment valid (at master) = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total primary segment failures (at master) = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid files missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid files found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of /tmp lock files missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of /tmp lock files found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number postmaster processes missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number postmaster processes found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Mirror Segment Status20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------20210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total mirror segments = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total mirror segment valid (at master) = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total mirror segment failures (at master) = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid files missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid files found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of postmaster.pid PIDs found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of /tmp lock files missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number of /tmp lock files found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number postmaster processes missing = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number postmaster processes found = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number mirror segments acting as primary segments = 020210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:- Total number mirror segments acting as mirror segments = 620210216:17:36:08:034610 gpstate:mdw:gpadmin-[INFO]:-----------------------------------------------------[gpadmin@mdw ~]$