greenplum安装与部署(详细)

修改系统配置

1.1 gp服务器列表

192.168.7.11 hadoop01 主节点
192.168.7.12 hadoop02 数据节点1
192.168.7.13 hadoop03 数据节点2
192.168.7.14 hadoop04 主节点切换备份节点

1.2 修改系统配置项

关闭SELINUX
vi /etc/selinux/config
SELINUX=disabled

1.3 关闭防火墙

systemctl status firewalld
systemctl stop firewalld.service
systemctl disable firewalld.service

1.4 修改内核配置参数,并执行 sysctl -p使之生效

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
vi /etc/sysctl.conf
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 2000 4096000 2000 2048
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.msgmni = 2048
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.ipv4.ip_local_port_range = 1025 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2 (服务器核数,根据实际情况修改参数)
1
2
3
4
5
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

1.5 配置集群中各节点hosts信息

1
2
3
4
5
vi /etc/hosts
192.168.7.11 hadoop01
192.168.7.12 hadoop02
192.168.7.13 hadoop03
192.168.7.14 hadoop04

安装greenplum-db

2.1 下载greenplum

下载地址
执行安装包:

1
rpm -ivh greenplum-db-6.1.0-rhel7-x86_64.rpm --nodeps --force

2.2 创建gpadmin用户

解压完成后以root身份创建gpadmin用户和组,用来管理greenplum-db

1
2
3
4
5
6
groupadd gpadmin                    # 创建分组    
useradd gpadmin -g gpadmin # 创建用户并分配组
passwd gpadmin # 为gpadmin分配密码
cd /usr/local/greenplum-db
chown -R gpadmin:gpadmin greenplum-db/
chown -R gpadmin:gpadmin greenplum-cc-web/

2.3 创建配置文件

切换到gpadmin用户下

1
2
3
su - gpadmin   
mkdir -p /usr/local/greenplum-db/gpconfigs
cd /usr/local/greenplum-db/gpconfigs

创建配置文件

1
2
3
4
5
6
7
8
9
10
vim hostfile_exkeys
输入
hadoop01
hadoop02
hadoop03
hadoop04
vi hostfile
hadoop02
hadoop03
hadoop04

2.4 在gpadmin和root用户下添加环境变量

1
2
3
4
5
6
7
8
vi ~/.bashrc
##添加以下内容
export LD_LIBRARY_PATH=$GPHOME/lib
export MASTER_DATA_DIRECTORY=/home/gpadmin/gpdata/master/gpseg-1
source /usr/local/greenplum-db/greenplum_path.sh
source /usr/local/greenplum-cc-web/gpcc_path.sh
保存退出,执行下面语句使其生效
source ~/.bashrc

2.5 切换到root用户

1
2
3
gpssh-exkeys -f /usr/local/greenplum-db/gpconfigs/hostfile_exkeys    
#拷贝mster节点公钥至各segment节点
gpseginstall -f /usr/local/greenplum-db/gpconfigs/hostfile_exkeys -p gpadmin

说明

gpssh-exkeys -f hostfile_exkeys 将会在master节点生成公私钥,并拷贝至hostfile_exkeys各segment节点,实现后续无密钥登陆
gpseginstall -f /usr/local/greenplum-db/gpconfigs/hostfile_exkeys -p gpadmin 使用默认用户名(gpadmin) 密码:gpadmin 在各segment节点安装Greenplum-db

2.6 在master及各segment节点创建数据存储目录

1
2
3
4
5
6
7
mkdir /home/gpadmin/gpdata/master
cd /home/gpadmin/
chown -R gpadmin:gpadmin gpdata/master
gpssh -f /usr/local/greenplum-db/gpconfigs/hostfile -e "mkdir -p /home/gpadmin/gpdata/data1/primary;mkdir -p /home/gpadmin/gpdata/data2/primary”
gpssh -f /usr/local/greenplum-db/gpconfigs/hostfile -e "mkdir -p /home/gpadmin/gpdata/data1/mirror;mkdir -p /home/gpadmin/gpdata/data2/mirror"
gpssh -f /usr/local/greenplum-db/gpconfigs/hostfile -e "chown -R gpadmin:gpadmin /home/gpadmin/gpdata"
gpssh -f /usr/local/greenplum-db/gpconfigs/hostfile_exkeys -v -e 'ntpd'

切换到gpadmin用户下,初始化数据库集群

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
su - gpadmin 
cd /usr/local/greenplum-db/
cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /usr/local/greenplum-db/gpconfigs/gpinitsystem_config
vi /usr/local/greenplum-db/gpconfigs/gpinitsystem_config
###修改以下内容
MASTER_HOSTNAME=mdw
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/home/gpadmin/gpdata/data1/primary /home/gpadmin/gpdata/data1/primary /home/gpadmin/gpdata/data2/primary /home/gpadmin/gpdata/data2/primary)
MASTER_DIRECTORY=/home/gpadmin/gpdata/master
MASTER_PORT=5432
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
declare -a MIRROR_DATA_DIRECTORY=(/home/gpadmin/gpdata/data1/mirror /home/gpadmin/gpdata/data1/mirror /home/gpadmin/gpdata/data2/mirror /home/gpadmin/gpdata/data2/mirror)
DATABASE_NAME=gpdb
MACHINE_LIST_FILE=/usr/local/greenplum-db/gpconfigs/hostfile

2.7 配置修改完成之后,执行以下命令初始化数据库

1
gpinitsystem -c /usr/local/greenplum-db/gpconfigs/gpinitsystem_config -h /usr/local/greenplum-db/gpconfigs/hostfile

2.8 psql修改数据库密码

1
2
3
4
5
6
psql -d gpdb    
gpdb=# alter user gpadmin with password 'gpadmin'
gpdb=# \q
然后,重启greenplumdb集群
gpstop -a
gpstart -a

2.9 使用pgadmin,navicat 等工具连接

连接时,如果登录不成功,一般报错如下样子:
psql: FATAL: no pg_hba.conf entry for host “192.168.xxx.xxx”,
表示访问权限不够
修改文件/home/gpadmin/gpdata/master/gpseg-1/pg_hba.conf

0%