Greenplum安装(2) – Greenplum安装部署
2,002 total views, 1 views today
在上篇博客《Greenplum安装(1) – 系统安装部署》中,已经介绍了安装Greenplum时,操作系统的安装要求及注意点。
这篇博客,会详细介绍Greenplum的安装步骤及注意点。
一、下载Greenplum安装包
https://network.pivotal.io/products/pivotal-gpdb#/releases/669/file_groups/348
二、安装Greenplum
1、解压并安装greenplum
@Master node:解压安装包
1 |
# unzip greenplum-db-4.3.6.2-build-1-RHEL5-x86_64.zip |
设置安装目录,并开始安装
1 2 3 4 |
# mkdir /opt/greenplum # chown -R gpadmin:gpadmin /opt/greenplum # ./greenplum-db-4.3.6.2-build-1-RHEL5-x86_64.bin |
安装过程中,同意协议
1 2 3 4 5 |
******************************************************************************** Do you accept the Pivotal Database license agreement? [yes|no] ******************************************************************************** yes |
设置新的安装路径
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 |
******************************************************************************** Provide the installation path for Greenplum Database or press ENTER to accept the default installation path: /usr/local/greenplum-db-4.3.6.2 ******************************************************************************** /opt/greenplum/greenplum-db-4.3.6.2 ******************************************************************************** Install Greenplum Database into </opt/greenplum/greenplum-db-4.3.6.2>? [yes|no] ******************************************************************************** yes ******************************************************************************** /opt/greenplum/greenplum-db-4.3.6.2 does not exist. Create /opt/greenplum/greenplum-db-4.3.6.2 ? [yes|no] (Selecting no will exit the installer) ******************************************************************************** yes Extracting product to /opt/greenplum/greenplum-db-4.3.6.2 ******************************************************************************** Installation complete. Greenplum Database is installed in /opt/greenplum/greenplum-db-4.3.6.2 Pivotal Greenplum documentation is available for download at http://docs.gopivotal.com/gpdb ******************************************************************************* |
注意:安装路径/opt/greenplum/greenplum-db-4.3.6.2就是$GPHOME,和/opt/greenplum同级目录下,会自动创建一个软连接执行安装路径(greenplum-db -> ./greenplum-db-4.3.6.2)
Greenplum的环境变量已经在greenplum_path.sh中设置,把环境变量入gpadmin的.bashrc中,让它生效
1 2 3 4 5 6 7 8 9 |
$ more .bashrc source /opt/greenplum/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/home/gpadmin/master/gpseg-1 export PGPORT=5432 export PGDATABASE=testDB export PGUSER=gpadmin $ source .bashrc |
gpdb目录下有如下文件和目录
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@gp-m gpdb]# ll -th total 276K -rw-r--r-- 1 root root 650 Nov 26 06:13 greenplum_path.sh drwxr-xr-x 3 500 500 4.0K Nov 13 03:05 bin -rw-r--r-- 1 500 500 43K Nov 13 03:05 GPDB-LICENSE.txt -rw-r--r-- 1 500 500 189K Nov 13 03:05 LICENSE.thirdparty drwxr-xr-x 2 500 500 4.0K Nov 13 03:05 sbin drwxr-xr-x 9 500 500 4.0K Nov 13 02:56 lib drwxr-xr-x 2 500 500 4.0K Nov 13 02:56 etc drwxr-xr-x 3 500 500 4.0K Nov 13 02:56 ext drwxr-xr-x 6 500 500 4.0K Nov 13 02:56 include drwxr-xr-x 5 500 500 4.0K Nov 13 02:56 docs drwxr-xr-x 4 500 500 4.0K Nov 13 02:54 share drwxr-xr-x 2 500 500 4.0K Nov 13 02:54 demo |
2、配置hostlist
在/opt/greenplum/greenplum-db目录下创建conf目录
1 2 3 4 |
# mkdir conf # chown gpadmin.gpadmin conf/ # su - gpadmin # su - gpadmin |
conf目录下hostlist含有所有服务器的hostname,包含segment和master节点
1 2 3 4 |
$ cat hostlist gp-m gp-s1 gp-s2 |
seg_hosts含有所有segment节点的hostname
1 2 3 |
$ cat seg_hosts gp-s1 gp-s2 |
3、使用gpssh-exkeys打通所有服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ gpssh-exkeys -f hostlist [STEP 1 of 5] create local ID and authorize on local host [STEP 2 of 5] keyscan all hosts and update known_hosts file [STEP 3 of 5] authorize current user on remote hosts ... send to gp-s1 *** *** Enter password for gp-s1: ... send to gp-s2 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts ... finished key exchange with gp-s1 ... finished key exchange with gp-s2 [INFO] completed successfully |
打通所有机器通道后,我们就可以使用gpssh命令对所有机器进行批量操作了。
1 2 3 4 5 6 |
$ gpssh -f hostlist Note: command history unsupported on this machine ... => pwd [gp-s1] /home/gpadmin [gp-s2] /home/gpadmin [ gp-m] /home/gpadmin |
4、将greenplum软件分发到每一台机器上
@Master
1 2 |
$ cd /opt/greenplum $ tar -cf gp4.3.tar greenplum-db-4.3.6.2/ |
首先在所有segments上创建安装目录
1 2 |
# mkdir /opt/greenplum # chown -R gpadmin:gpadmin /opt/greenplum |
将软件传到每台机器上
1 |
$ gpscp -f /opt/greenplum/greenplum-db/conf/seg_hosts gp4.3.tar =:/opt/greenplum/ |
使用gpssh检查是否传到每台segment机器上,并解压,建立软连接
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 |
$ gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts => cd /opt/greenplum [gp-s1] [gp-s2] => ls [gp-s1] gp4.3.tar [gp-s2] gp4.3.tar #解压 => tar -xf gp4.3.tar [gp-s1] [gp-s2] #创建软链接 => ln -s greenplum-db-4.3.6.2 greenplum-db [gp-s1] [gp-s2] => ll [gp-s1] total 443828 [gp-s1] -rw-rw-r-- 1 gpadmin gpadmin 454471680 Nov 26 09:15 gp4.3.tar [gp-s1] lrwxrwxrwx 1 gpadmin gpadmin 20 Nov 26 09:26 greenplum-db -> greenplum-db-4.3.6.2 [gp-s1] drwxr-xr-x 12 gpadmin gpadmin 4096 Nov 26 07:07 greenplum-db-4.3.6.2 [gp-s2] total 443828 [gp-s2] -rw-rw-r-- 1 gpadmin gpadmin 454471680 Nov 26 09:15 gp4.3.tar [gp-s2] lrwxrwxrwx 1 gpadmin gpadmin 20 Nov 26 09:26 greenplum-db -> greenplum-db-4.3.6.2 [gp-s2] drwxr-xr-x 12 gpadmin gpadmin 4096 Nov 26 07:07 greenplum-db-4.3.6.2 |
5、创建数据库数据目录
MASTER节点目录
<1>Mater节点上的目录不同于其他segment。master节点不存放任何用户数据,只存放系统日志表和系统元数据。因此,master节点上不需要和segment一样大小的空间。
1 2 |
$ mkdir master $ chown gpadmin:gpadmin master/ |
<2>使用gpssh命令,在standby master节点上创建master目录
1 2 |
$ gpssh -h gp-s1 -e 'mkdir /home/gpadmin/master' $ gpssh -h gp-s1 -e 'chown gpadmin:gpadmin /home/gpadmin/master' |
segment节点创建数据目录:Primary节点和Mirror节点一定要交叉分布。
1 2 3 4 5 |
#在Master节点上执行命令 $ gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts -e 'mkdir /home/gpadmin/primary' $ gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts -e 'mkdir /home/gpadmin/mirror' $ gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts -e 'chown gpadmin.gpadmin /home/gpadmin/primary' $ gpssh -f /opt/greenplum/greenplum-db/conf/seg_hosts -e 'chown gpadmin.gpadmin /home/gpadmin/mirror' |
6、校验OS配置正确性,测试环境ntpd错误可以忽略
1 2 3 4 5 6 7 8 9 10 11 12 |
$ gpcheck -f /opt/greenplum/greenplum-db/conf/hostlist 20151207:09:46:40:002537 gpcheck:gp-m:gpadmin-[INFO]:-dedupe hostnames 20151207:09:46:40:002537 gpcheck:gp-m:gpadmin-[INFO]:-Detected platform: Generic Linux Cluster 20151207:09:46:40:002537 gpcheck:gp-m:gpadmin-[INFO]:-generate data on servers 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[INFO]:-copy data files from servers 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[INFO]:-delete remote tmp files 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[INFO]:-Using gpcheck config file: /opt/greenplum/greenplum-db/./etc/gpcheck.cnf 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[ERROR]:-GPCHECK_ERROR host(None): utility will not check all settings when run as non-root user 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[ERROR]:-GPCHECK_ERROR host(gp-s2): ntpd not detected on machine 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[ERROR]:-GPCHECK_ERROR host(gp-s1): ntpd not detected on machine 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[ERROR]:-GPCHECK_ERROR host(gp-m): ntpd not detected on machine 20151207:09:46:41:002537 gpcheck:gp-m:gpadmin-[INFO]:-gpcheck completing... |
7、配置每个节点的gpadmin用户下的.bash_profile
1 2 3 4 |
source /opt/greenplum/greenplum-db/greenplum_path.sh export MASTER_DATA_DIRECTORY=/home/gpadmin/master/gpseg-1 export PGPORT=5432 export PGDATABASE=testDB |
8、初始化gp配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ cd /opt/greenplum/greenplum-db/docs/cli_help/gpconfigs $ cp gpinitsystem_config /home/gpadmin/initgp_config ARRAY_NAME="EMC Greenplum DW" SEG_PREFIX=gpseg PORT_BASE=40000 declare -a DATA_DIRECTORY=(/home/gpadmin/primary) MASTER_HOSTNAME=gp-m MASTER_DIRECTORY=/home/gpadmin/master MASTER_PORT=5432 TRUSTED SHELL=ssh ENCODING=UNICODE #mirror MIRROR_PORT_BASE=50000 REPLICATION_PORT_BASE=41000 MIRROR_REPLICATION_PORT_BASE=51000 declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/mirror) |
9、初始化数据库,有两种方式
只初始化segment
1 |
$ gpinitsystem -c initgp_config -h /opt/greenplum/greenplum-db/conf/seg_hosts |
同时初始化segment + segment mirrors + standby master(建议采用这种方式)。这种方式,初始化master和每个segment instance,并且并行初始化每个segment实例。
1 |
$ gpinitsystem -c initgp_config -h /opt/greenplum/greenplum-db/conf/seg_hosts -s gp-s1 -S |
参数说明:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
-h 后面接segment主机名列表文件 -c 后面接初始化Greenplum的参数文件 -s <standby_master_host> standby master的主机名 Optional. If you wish to configure a backup master host, specify the host name using this option. The Greenplum Database software must already be installed and configured on this host. -S (spread mirror configuration) 分布primary和mirror到不同主机 If mirroring parameters are specified, spreads the mirror segments across the available hosts. The default is to group the set of mirror segments together on an alternate host from their primary segment set. Mirror spreading will place each mirror on a different host within the Greenplum Database array. Spreading is only allowed if there is a sufficient number of hosts in the array (number of hosts is greater than the number of segment instances). |
三、检查Greenplum状态
检查primary和mirror是否分布在不同主机
1 |
$ gpstate -c |
检查所有,包含master、standby master、segment和segment mirror状态
1 |
$ gpstate -s |
检查mirror状态
1 |
$ gpstate -m |
>> 更多关于greenplum安装部署的文章,请点击这里。