[root@zxy_master /]# groupadd gpadmin
[root@zxy_master /]# useradd gpadmin -g gpadmin
[root@zxy_master /]# passwd gpadmin
安装包
官网
官方推荐使用yum的方式安装,yum安装的饿好处是,会自动帮我们下载安装依赖包。默认将greenplum软件安装到/usr/local目录下,并创建软连接。但是如果不能自动联网下载就会比较麻烦。
[root@zxy_master software]# ls | grep greenplum
greenplum-db-6.4.0-rhel6-x86_64.rpm
[root@zxy_master software]# yum install localhost greenplum-db-6.4.0-rhel6-x86_64.rpm
[root@zxy_master software]# ll /usr/local/ | grep greenplum
lrwxrwxrwx 1 root root 29 Mar 21 09:50 greenplum-db -> /usr/local/greenplum-db-6.4.0
drwxr-xr-x 12 root root 4096 Mar 21 09:50 greenplum-db-6.4.0
vim /etc/profile
添加如下配置:
export GP_HOME=/usr/local/greenplum-db
export PATH=$PATH:$GP_HOME/bin
source /etc/profile
[root@zxy_master software]# chown -Rf gpadmin:gpadmin /usr/local/greenplum*
[root@zxy_master software]# ll /usr/local/ | grep greenplum
lrwxrwxrwx 1 gpadmin gpadmin 29 Mar 21 09:50 greenplum-db -> /usr/local/greenplum-db-6.4.0
drwxr-xr-x 12 gpadmin gpadmin 4096 Mar 21 09:50 greenplum-db-6.4.0
在~/.bashrc文件中添加source /usr/local/greenplum-db/greenplum_path.sh
这样在root用户下修改了环境后,一旦切换到gpadmin用户,会自动加载。
后续还有其他变量需要添加时,也添加在该文件中
[gpadmin@zxy_master ~]$ cat .bashrc# .bashrc# Source global definitions
if [ -f /etc/bashrc ]; then. /etc/bashrc
fi# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=# User specific aliases and functions
source /usr/local/greenplum-db/greenplum_path.sh
刚修改好,可以手动source一下。source ~/.bashrc
[gpadmin@zxy_master ~]$ cd /usr/local/greenplum-db/bin
[gpadmin@zxy_master bin]$ ./gpssh-exkeys -h zxy_master
[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] retrieving credentials from remote hosts[STEP 4 of 5] determine common authentication file content[STEP 5 of 5] copy authentication files to all remote hosts[INFO] completed successfully
创建数据目录gpdata
有master
和primary
等节点
创建配置目录gpconfigs
[root@zxy_master /]# mkdir -p /zxy/data/gpdata/primary
[root@zxy_master /]# mkdir -p /zxy/data/gpdata/master
[root@zxy_master /]# mkdir -p /zxy/data/gpconfigs[root@zxy_master /]# cd /zxy/data
[root@zxy_master data]# chown -Rf gpadmin:gpadmin ./gpdata/
[root@zxy_master data]# chown -Rf gpadmin:gpadmin ./gpconfigs/
[gpadmin@zxy_master ~]$ cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /zxy/data/gpconfigs/
[gpadmin@zxy_master ~]$ cd /zxy/data/gpconfigs
[gpadmin@zxy gpconfigs]$ touch hostfile
[gpadmin@zxy gpconfigs]$ echo "zxy_master" > hostfile
主要关注master和segment的目录,主机名和数据库端口
[gpadmin@zxy_master ~]$ vim /zxy/data/gpconfigs/gpinitsystem_config
[gpadmin@zxy_master ~]$ cat /zxy/data/gpconfigs/gpinitsystem_config
# FILE NAME: gpinitsystem_config# Configuration file needed by the gpinitsystem################################################
#### REQUIRED PARAMETERS
#################################################### Name of this Greenplum system enclosed in quotes.
ARRAY_NAME="Greenplum Data Platform"#### Naming convention for utility-generated data directories.
SEG_PREFIX=gpseg#### Base number by which primary segment port numbers
#### are calculated.
PORT_BASE=6000#### File system location(s) where primary segment data directories
#### will be created. The number of locations in the list dictate
#### the number of primary segments that will get created per
#### physical host (if multiple addresses for a host are listed in
#### the hostfile, the number of segments will be spread evenly across
#### the specified interface addresses).
declare -a DATA_DIRECTORY=(/zxy/data/gpdata/primary /zxy/data/gpdata/primary)#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAME=zxy_master#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/zxy/data/gpdata/master#### Port number for the master instance.
MASTER_PORT=54321#### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=ssh#### Maximum log file segments between automatic WAL checkpoints.
CHECK_POINT_SEGMENTS=8#### Default server-side character set encoding.
ENCODING=UNICODE################################################
#### OPTIONAL MIRROR PARAMETERS
#################################################### Base number by which mirror segment port numbers
#### are calculated.
#MIRROR_PORT_BASE=7000#### File system location(s) where mirror segment data directories
#### will be created. The number of mirror locations must equal the
#### number of primary locations as specified in the
#### DATA_DIRECTORY parameter.
#declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data1/mirror /data1/mirror /data2/mirror /data2/mirror /data2/mirror)################################################
#### OTHER OPTIONAL PARAMETERS
#################################################### Create a database of this name after initialization.
#DATABASE_NAME=name_of_database#### Specify the location of the host address file here instead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
[gpadmin@zxy_master bin]$ ./gpinitsystem -c /zxy/data/gpconfigs/gpinitsystem_config -h /zxy/data/gpconfigs/hostfile
[gpadmin@zxy_master bin]$ psql -p 54321 -d postgres
psql (9.4.24)
Type "help" for help.postgres=#
[gpadmin@zxy_master bin]$ psql -p 54321 -d postgres
psql (9.4.24)
Type "help" for help.postgres=#
postgres=# \password gpadmin
Enter new password:
Enter it again:
通过指令查询任务进程,以及端口。
开放6000,6001,54321端口
[gpadmin@zxy_master gpseg-1]$ ps -ef | grep greenplum
gpadmin 6662 25316 0 16:35 pts/2 00:00:00 grep --color=auto greenplum
gpadmin 10025 1 0 13:48 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /zxy/data/gpdata/primary/gpseg1 -p 6001
gpadmin 10026 1 0 13:48 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /zxy/data/gpdata/primary/gpseg0 -p 6000
gpadmin 10047 1 0 13:48 ? 00:00:00 /usr/local/greenplum-db-6.4.0/bin/postgres -D /zxy/data/gpdata/master/gpseg-1 -p 54321 -E
[gpadmin@zxy_master bin]$ cd /zxy/data/gpdata/master/gpseg-1/#添加如下一行即可,所有用户,所有IP均可访问
#生产环境中可自行选择配置
[gpadmin@zxy_master gpseg-1]$ vim pg_hba.conf
host all all all trust