环境:
服务器版本:centos 6.5
数据库版本:greenplum-db-4.2.8.5-build-1-RHEL5-x86_64.zip
1.创建用户和组gpadmin
groupadd -g 3030 gpadmin
useradd -u 3030 gpadmin -g gpadmin -d /home/gpadmin
passwd gpadmin
配置内核参数,添加如下内容:
vi /etc/sysctl.conf
#By greenplum
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
以上参数可以根据自己系统配置做适当修改
手工执行命令,让参数生效
[[email protected] ~]# sysctl -p
在limits.conf文件中添加如下配置
[[email protected] ~]# vi /etc/security/limits.conf
# End of file
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
配置用户ssh用户无密码登录,单机也得配置
[[email protected] ~]# su - gpadmin
[[email protected] ~]$ mkdir ~/.ssh
[[email protected] ~]$ chmod 700 ~/.ssh
[[email protected] ~]$ cd .ssh/
[[email protected] .ssh]$ ssh-keygen -t rsa
[[email protected] .ssh]$ ssh gpmaster cat /home/gpadmin/.ssh/id_rsa.pub >>authorized_keys
[[email protected] .ssh]$chmod 600 authorized_keys
[[email protected] .ssh]$ ssh gpmaster date
2.安装GP软件
[[email protected] ~]# unzip greenplum-db-4.2.8.5-build-1-RHEL5-x86_64.zip
[[email protected] ~]# ./greenplum-db-4.2.8.5-build-1-RHEL5-x86_64.bin
创建instance需要的目录
[[email protected] ~]# mkdir -p /app/master
[[email protected] ~]# mkdir -p /app/data/gp1
[[email protected] ~]# mkdir -p /app/data/gp2
[[email protected] ~]# mkdir -p /app/data/gp3
[[email protected] ~]# mkdir -p /app/data/gp4
修改目录属主:
[[email protected] ~]# chown -R gpadmin:gpadmin /usr/local/greenplum-db*
[[email protected] ~]# chown -R gpadmin:gpadmin /app/master
[[email protected] ~]# chown -R gpadmin:gpadmin /app/data/gp1
[[email protected] ~]# chown -R gpadmin:gpadmin /app/data/gp2
[[email protected] ~]# chown -R gpadmin:gpadmin /app/data/gp3
[[email protected] ~]# chown -R gpadmin:gpadmin /app/data/gp4
修改gpadmin用户环境配置:
[[email protected] ~]# su - gpadmin
[[email protected] ~]$ vi .bash_profile
source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/app/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=gpmaster
生效:
[[email protected] ~]$ source .bash_profile
编辑all_hosts_file文件,添加如下内容:
[[email protected] ~]$ vi all_hosts_file
gpmaster
执行如下命令验证用户等效性
[[email protected] ~]$ gpssh-exkeys -f all_hosts_file
3.初始化系统:
编辑系统初始化的参数文件,这个文件的编辑可以使用模版,模板文件所在目录如下:
[[email protected] ~]$ cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/
编辑gp参数文件,修改如下配置:
[[email protected] ~]$ vi gpinitsystem_config
declare -a DATA_DIRECTORY=(/app/data/gp1 /app/data/gp2 /app/data/gp3 /app/data/gp4)
MASTER_HOSTNAME=gpmaster
MASTER_DIRECTORY=/app/master
DATABASE_NAME=gpmaster
编辑seg_hosts_file文件
[[email protected] ~]$ vi seg_hosts_file
gpmaster
执行初始化系统命令:
[[email protected] ~]$ gpinitsystem -c gpinitsystem_config -h seg_hosts_file
系统开始初始化,之后会看到如下提示:
Continue with Greenplum creation Yy/Nn>
输入 Y ,按回车,系统会初始化完成
安装结束可以连接GP数据库了:
[[email protected] ~]$ psql -d gpmaster
psql (8.2.15)
Type "help" for help.
gpmaster=#
创建数据库
[[email protected] ~]$ createdb testDB -E utf-8
给数据库权限
[[email protected] ~]$ psql -d gpmaster
psql (8.2.15)
Type "help" for help.
gpmaster=# \c testDB
You are now connected to database "testDB" as user "gpadmin".
testDB=# alter role gpadmin with password ‘gpadmin‘;
远程权限
[[email protected] ~]$ cd $MASTER_DATA_DIRECTORY/
[[email protected] gpseg-1]$ ls
base pg_distributedlog pg_stat_tmp pg_xlog
global pg_distributedxidmap pg_subtrans postgresql.conf
gp_dbid pg_hba.conf pg_tblspc postmaster.opts
gpperfmon pg_ident.conf pg_twophase postmaster.pid
pg_changetracking pg_log pg_utilitymodedtmredo
pg_clog pg_multixact PG_VERSION
[[email protected] gpseg-1]$
[[email protected] gpseg-1]$ vi pg_hba.conf
host testDB gpadmin 192.168.96.1/32 md5
通过gpstop -u命令使配置生效
[[email protected] gpseg-1]$ gpstop -u
通过其他机器登录数据库
$ psql -h192.168.96.128 -p5432 -d testDB -Ugpadmin