PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
The Greenplum Database (GPDB) is an advanced, fully featured, open source data warehouse. It provides powerful and rapid analytics on petabyte scale data volumes. Uniquely geared toward big data analytics, Greenplum Database is powered by the world’s most advanced cost-based query optimizer delivering high analytical query performance on large data volumes.
Greenplum 是基于 PostgreSQL 开发的,语法与 PostgreSQL 几乎一样。
本质上,Greenplum 是一个关系型数据库集群,由多个独立的数据库服务组 合成的逻辑数据库,对于用户来说 Greenplum 与 Oracle、PostgreSQL 并无不同, 都可以通过标准 SQL 语句对数据进行访问。
以CentOS 6.9为例,下载地址为阿里云镜像。
CentOS-6.9-x86_64-bin-DVD1.iso
CentOS-6.9-x86_64-bin-DVD2.iso
强烈建议以gpadmin为用户名。
vim 打开 /etc/sudoers 文件 (以root权限打开)
找到以下两行
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
并在下一行添加
gpadmin ALL=(ALL) ALL #注意对齐
保存并返回即可
sudo yum install gcc-c++
sudo yum install git
cd /home/gpadmin
wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
tar -zxvf cmake-3.5.2.tar.gz
cd cmake-3.5.2
./configure --prefix=/usr/local
make
sudo make install
sudo yum -y install epel-release
sudo yum -y install python-pip
pip install --upgrade #pip版本至少为 7.x.x
添加 /usr/local/lib 和 /usr/local/lib64 到 /etc/ld.so.conf 中
并运行命令
sudo ldconfig
sudo yum install -y centos-release-scl
sudo yum install -y devtoolset-6-toolchain
echo 'source scl_source enable devtoolset-6' >> ~/.bashrc
source ~/.bashrc
sudo yum -y install gcc git apr bison flex readline gcc-c++ curl-devel bzip2-devel python-devel readline-devel apr-devel libevent-devel openssl-devel perl-ExtUtils-Embed libxml2-devel openldap-devel pam pam-devel
cd /home/gpadmin
git clone https://github.com/greenplum-db/gporca.git
git clone https://github.com/greenplum-db/gp-xerces.git
cd gp-xerces
mkdir build
cd build
../configure --prefix=/usr/local
make
sudo make install
cd /home/gpadmin
git clone git://github.com/ninja-build/ninja.git && cd ninja
./configure.py --bootstrap
sudo cp ninja /usr/bin
cd /home/gpadmin/gporca
cmake -GNinja -H. -Bbuild
sudo ninja install -C build
cd /home/gpadmin
git clone https://github.com/greenplum-db/gpdb.git
cd gpdb
./configure --with-perl --with-python --with-libxml --with-gssapi --prefix=/usr/local/gpdb
# Compile and install
make -j8
sudo make -j8 install
# Bring in greenplum environment into your running shell
source /usr/local/gpdb/greenplum_path.sh
若出现
Greenplum Database installation complete.
则说明安装成功
以在同一台主机上的一个master节点和一个segment节点为例
ip addr show eth0
# 选择inet后的ip
sudo vim /etc/hosts
添加两行
mdw
sdw1
#此处ip相同
sudo vim /etc/sysconfig/network
#修改 HOSTNAME=mdw
cd /home/gpadmin
mkdir conf
cd conf
sudo vim hostlist
添加以下内容
mdw
sdw1
sudo vim seg_hosts
添加以下内容
sdw1
sudo vim /etc/sysctl.conf
对照替换成以下内容
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 1
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.sem = 250 64000 100 512
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 250 64000 100 512
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.core.netdev_max_backlog = 10000
vm.overcommit_memory = 2
net.ipv4.conf.all.arp_filter = 1
sudo sysctl -p
sudo vim /etc/security/limits.conf
添加以下内容
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
# 星号不能去掉
source /usr/local/gpdb/greenplum_path.sh
sudo pip install psutil
gpssh-exkeys -f /home/gpadmin/conf/hostlist
cd /home/gpadmin
mkdir gpdata
cd gpdata
mkdir segmentdata1 masterdata
vim ~/.bash_profile
添加以下内容
source /usr/local/gpdb/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/home/gpadmin/gpdata/masterdata/gpseg-1
export PGPORT=2345
export PGDATABASE=testDB
source ~/.bash_profile
cd /home/gpadmin/conf
mkdir gpconfigs
cd gpconfigs
vim gpinitsystem_config
添加以下内容
#启动参数文件内容
ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/home/gpadmin/gpdata/segmentdata1 /home/gpadmin/gpdata/segmentdata1)
MASTER_HOSTNAME=mdw
MASTER_DIRECTORY=/home/gpadmin/gpdata/masterdata
##### Port number for the master instance.
MASTER_PORT=2345
# #### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=/usr/bin/ssh
##### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
#MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
#MIRROR_REPLICATION_PORT_BASE=51000
#declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/gpdata/segmentmirror1 #/home/gpadmin/gpdata/segmentmirror)
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts
gpinitsystem -c /home/gpadmin/conf/gpconfigs/gpinitsystem_config –a
gpstart #开启数据库服务
gpstop #关闭数据库服务
gprecoverseg #恢复启动失败的节点
gpstate -m #查看节点状态
createdb testDB #创建数据库
psql #连接数据库 psql –help查看更多选项
运行Greenplum TPC-H测试
参考https://yq.aliyun.com/articles/93?commentId=29
如有兴趣,请访问个人博客