linux下安装greenplum

时间:2023-03-08 16:20:03
linux下安装greenplum

1. 下载 Greenplum Database 源代码

$ git clone https://github.com/greenplum-db/gpdb

2. 安装依赖库

Greenplum Database 编译和运行依赖于各种系统库和Python库。需要先安装这些依赖。
2.1.centos下:
$ sudo yum install curl-devel bzip2-devel python-devel openssl-devel
$ sudo yum install perl-ExtUtils-Embed  # If enable perl
$ sudo yum install libxml2-devel             # If enable XML support
$ sudo yum install openldap-devel         # If enable LDAP
$ sudo yum install pam pam-devel         # If enable PAM

$ sudo yum install perl-Env             # If need installcheck-good

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py

$ sudo pip install psi lockfile paramiko setuptools epydoc

2.2.ubuntu下:

apt-get install -y git-core
apt-get install -y gcc g++
apt-get install -y ccache
apt-get install -y libreadline-dev
apt-get install -y bison flex
apt-get install -y zlib1g-dev
apt-get install -y openssl libssl-dev
apt-get install -y libpam-dev
apt-get install -y libcurl4-dev
apt-get install -y libbz2-dev
apt-get install -y python-dev
apt-get install -y ssh

apt-get install -y libcurl4-dev
Package libcurl4-dev is a virtual package provided by:
libcurl4-openssl-dev 7.38.0-4+deb8u2
libcurl4-nss-dev 7.38.0-4+deb8u2
libcurl4-gnutls-dev 7.38.0-4+deb8u2

apt-get install -y python-pip

pip install lockfile
pip install paramiko
pip install setuptools
pip install epydoc
pip install psi
Note: debian8 required pip install --pre psi

注意:通过pip安装的这几个python依赖包最好下载相应的源码,然后sudo pyton setup.py install进行安装

3. 编译 Greenplum Database 源代码并安装

假定安装到 $HOME/gpdb.master 目录下

$ ./configure --prefix=/home/gpadmin/build/gpdb.master --with-gssapi --with-pgport=5432 --with-libedit-preferred --with-perl --with-python --with-openssl --with-pam --with-krb5 --with-ldap --with-libxml --enable-cassert --enable-debug --enable-testutils --enable-debugbreak --enable-depend

$ make

$ make install

4. 初始化 Greenplum Database 集群

安装了二进制文件后,需要初始化数据库集群。下面在一台笔记本上安装一个GPDB的集群。集群包括一个master,两个segment。

$ source $HOME/gpdb.master/greenplum_path.sh
$ gpssh-exkeys -h `hostname`

4.1 生成三个配置文件

$ vim env.sh
source $HOME/gpdb.master/greenplum_path.sh
export PGPORT=5432
export MASTER_DATA_DIRECTORY=$HOME/data/master/gpseg-1

$ vim hostfile
<your_hostname>

$ vim gp_config
ARRAY_NAME="Open Source GPDB"

SEG_PREFIX=gpseg
PORT_BASE=40000

# 根据需要,修改下面的路径和主机名
declare -a DATA_DIRECTORY=(/path/to/your/data /path/to/your/data)
MASTER_HOSTNAME=your_hostname
MASTER_DIRECTORY=/path/to/your/data/master
MASTER_PORT=5432

TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=8
ENCODING=UNICODE
MACHINE_LIST_FILE=hostfile

4.2 初始化 GPDB cluster

$ source env.sh
$ gpinitsystem -c gpinitsystem_config -a

初始化成功后,运行一下命令验证系统状态:

$ psql -l
$ gpstate -s