获取安装包
https://network.pivotal.io/products/pivotal-gpdb/ 注册账号进行下载
1、安装可能用到的系统工具
# yum -y install vim telnet wget net-tools lrzsz
2、修改主机名
# hostnamectl set-hostname greenplum01
3、修改/etc/hosts解析
# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.20.10.213 greenplum01
4、关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
5、禁用selinux
临时修改
# setenforce 0
永久修改,重启生效
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
检查
# getenforce
disabled
6、数据盘挂载
# fdisk -l
# pvcreate /dev/sda
# vgcreate vgpgdata /dev/sda
# lvcreate -l +100%FREE -n lvpgdata vgpgdata
# mkfs.xfs /dev/vgpgdata/lvpgdata
# mkdir /app/gpdata -p
# blkid
# echo 'UUID="a1eb28ce-4732-4487-87b6-943f31f896a9" /app/gpdata xfs defaults 0 0' >> /etc/fstab
# mount -a
# df -h
7、修改内核参数并临时生效
# vim /etc/sysctl.conf
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sem = 250 512000 100 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.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 = 10000 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2
# sysctl -p
# vim /etc/security/limits.conf
soft nofile 65536
hard nofile 65536
soft nproc 131072
hard nproc 131072
8、创建用户和组
# groupadd -g 3030 gpadmin
# useradd -g 3030 -u 3030 gpadmin
# echo gpadmin |passwd gpadmin --stdin
Changing password for user gpadmin.
passwd: all authentication tokens updated successfully.
# id gpadmin
uid=3030(gpadmin) gid=3030(gpadmin) groups=3030(gpadmin)
9、创建instance需要的目录并修改属主和属组
# mkdir -p /app/gpdata/master
# mkdir -p /app/gpdata/gp1
# mkdir -p /app/gpdata/gp2
# mkdir -p /app/gpdata/gp3
# mkdir -p /app/gpdata/gp4
# chown -R gpadmin. /app/gpdata
10、安装greenplum-db
去网站https://network.pivotal.io/products/pivotal-gpdb/ 注册账号进行下载并上传到服务器
# yum -y install greenplum-db-5.18.0-rhel7-x86_64.rpm
11、配置环境变量
# find / -name greenplum_path.sh
/usr/local/greenplum-db-5.18.0/greenplum_path.sh
# su - gpadmin
$ vim .bash_profile
source /usr/local/greenplum-db-5.18.0/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/app/gpdata/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=gpdb
$ . .bash_profile # 环境变量生效
12、设置子节点的host(单节点只有一个host)
$ vim all_hosts_file
greenplum01
13、权限互通
前提是让11步骤环境变量生效
$ gpssh-exkeys -f all_hosts_file
14、编辑gp初始化文件
$ vim initgp_config
SEG_PREFIX=gpseg
PORT_BASE=33000
declare -a DATA_DIRECTORY=(/app/gpdata/gp1 /app/gpdata/gp2 /app/gpdata/gp3 /app/gpdata/gp4)
MASTER_HOSTNAME=greenplum01
MASTER_PORT=5432
MASTER_DIRECTORY=/app/gpdata/master
DATABASE_NAME=gpdb
15、设置节点服务器
$ vim seg_hosts_file //(本例单机,只有greenplum01.zetyun.com这一台)
greenplum01
16、初始化GP
$ gpinitsystem -c initgp_config -h seg_hosts_file
17、连接GP,修改登录密码
# su - gpadmin
Password:
Last login: Wed May 8 14:34:57 CST 2019 on pts/0
$ psql -p 5432
psql (8.3.23)
Type "help" for help.
gpdb=# alter role gpadmin with password 'bigdata2019' ;
ALTER ROLE
gpdb=# \q
18、远程连接的配置
$ vim /app/gpdata/master/gpseg-1/postgresql.conf
#listen_addresses = '*' //注释行打开
$ vim /app/gpdata/master/gpseg-1/pg_hba.conf
host all gpadmin 0.0.0.0/0 md5 //添加内容
19、重新加载配置文件
$ gpstop -u
20、附录其他命令
gpstart #正常启动
gpstop #正常关闭
gpstop -M fast #快速关闭
gpstop –r #重启