greenplum5.17安装手册
前置:
软件安装包下载:
可以从官方下载(需要账号)
https://network.pivotal.io/products/vmware-greenplum#/releases/301769/file_groups/1397
也可以从csdn 地址下载:
greenplum-db-5.17.0-rhel7-x86-64.rpm资源-CSDN文库
1.修改主机名IP映射关系,编辑/etc/hosts文件
192.168.209.21 risen
2.修改主机名,编辑/etc/hostname文件
risen
3. 环境
- 防火墙:
可以选择直接关闭防火墙,或者添加防火墙条件允许
- SELinux:
SELinux策略是白名单原则,需要非常清楚安装软件使用的权限才能配置好(配置麻烦不说,头疼的是你不知道需要什么权限),而Linux已经有了比较完善的Security Best Practice。在Linux上部署工具有更多的实践经验和可行方案去保证系统的安全,即便是没有SELinux,是故大家普遍选择关闭SELinux。
# 查看防火墙是否关闭,未关闭使用(systemctl stop firewalld) systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1) # 查看selinux状态,未关闭修改(SELINUX=disabled) cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
4.添加组及用户
groupadd gpadmin useradd -r -m -g gpadmin gpadmin # 给 gpadmin 用户设置密码 echo "123456" | passwd --stdin gpadmin # 删除组 groupdel gpadmin 删除用户 userdel gpadmin echo "RemoveIPC=no" >> /etc/systemd/logind.conf service systemd-logind restart
5.下载好了之后,上传到 /home/greenplum 文件,如果没有文件则mkdir 命令创建
6.安装
[root@192 greenplum]# rpm -Uvh greenplum-db-5.17.0-rhel7-x86_64.rpm 准备中... ################################# [100%] 正在升级/安装... 1:greenplum-db-5.17.0-1 ################################# [100%]m默认
默认安装的位置
[root@192 greenplum]# ll -al /usr/local/ 总用量 0 drwxr-xr-x. 13 root root 178 2月 26 10:59 . drwxr-xr-x. 13 root root 155 2月 23 15:08 .. drwxr-xr-x. 2 root root 6 4月 11 2018 bin drwxr-xr-x. 2 root root 6 4月 11 2018 etc drwxr-xr-x. 2 root root 6 4月 11 2018 games lrwxrwxrwx. 1 root root 30 2月 26 10:59 greenplum-db -> /usr/local/greenplum-db-5.17.0 drwxr-xr-x. 11 root root 138 2月 26 10:59 greenplum-db-5.17.0 drwxr-xr-x. 2 root root 6 4月 11 2018 include drwxr-xr-x. 2 root root 6 4月 11 2018 lib drwxr-xr-x. 2 root root 6 4月 11 2018 lib64 drwxr-xr-x. 2 root root 6 4月 11 2018 libexec drwxr-xr-x. 2 root root 6 4月 11 2018 sbin drwxr-xr-x. 5 root root 49 2月 23 15:08 share drwxr-xr-x. 2 root root 6 4月 11 2018 src
7. 赋权
chown -R gpadmin /usr/local/greenplum* chgrp -R gpadmin /usr/local/greenplum*
# 使环境变量生效
source /usr/local/greenplum-db/greenplum_path.sh
8.初始化准备
# 创建实例目录(主节点及segment实例存储文件夹gpnode个数视服务器情况而定) mkdir -p /home/greenplum/gpdata/master mkdir -p /home/greenplum/gpdata/gpnode1 mkdir -p /home/greenplum/gpdata/gpnode2 mkdir -p /home/greenplum/gpdata/gpnode3 mkdir -p /home/greenplum/gpdata/gpnode4 # 修改目录属主 chown -R gpadmin:gpadmin /home/greenplum/ chown -R gpadmin:gpadmin /home/greenplum/gpdata chown -R gpadmin:gpadmin /home/greenplum/gpdata/master chown -R gpadmin:gpadmin /home/greenplum/gpdata/gpnode*
9.以下使用gpadmin用户操作
su gpadmin # ----环境变量配置 # postgresql默认端口号5432 这里使用2345 cat <<EOF >> /home/greenplum/.bashrc source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb # export LD_PRELOAD=/lib64/libz.so.1 ps EOF source /home/greenplum/.bashrc # ----节点host配置(单机版值配置一个master节点) cat <<EOF >> /home/greenplum/hostfile_exkeys risen EOF # ----ssh权限互通设置 gpssh-exkeys -f /home/greenplum/hostfile_exkeys su gpadmin # ----环境变量配置 # postgresql默认端口号5432 这里使用2345 cat <<EOF >> /home/greenplum/.bashrc source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb # export LD_PRELOAD=/lib64/libz.so.1 ps EOF source /home/greenplum/.bashrc # ----节点host配置(单机版值配置一个master节点) cat <<EOF >> /home/greenplum/hostfile_exkeys risen EOF # ----ssh权限互通设置 gpssh-exkeys -f /home/greenplum/hostfile_exkeys [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 [STEP 4 of 5] determine common authentication file content [STEP 5 of 5] copy authentication files to all remote hosts [INFO] completed successfully # ----设置节点服务器(单机版就是master节点) cat <<EOF >> /home/greenplum/seg_hosts_file risen EOF # ----编辑gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config vim /home/greenplum/gpinitsystem_config # 以下为配置文件内容 declare -a DATA_DIRECTORY=(/home/greenplum/gpdata/gpnode1 /home/greenplum/gpdata/gpnode2) MASTER_HOSTNAME=risen MASTER_PORT=2345 MASTER_DIRECTORY=/home/greenplum/gpdata/master DATABASE_NAME=gpdb # ---- 初始化(-s xx代表备用主节点是xx机器 单机无需配置) gpinitsystem -c gpinitsystem_config -h seg_hosts_file # ----设置节点服务器(单机版就是master节点) cat <<EOF >> /home/greenplum/seg_hosts_file risen EOF # ----编辑gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config vim /home/greenplum/gpinitsystem_config # 以下为配置文件内容 declare -a DATA_DIRECTORY=(/home/greenplum/gpdata/gpnode1 /home/greenplum/gpdata/gpnode2) MASTER_HOSTNAME=risen MASTER_PORT=2345 MASTER_DIRECTORY=/home/greenplum/gpdata/master DATABASE_NAME=gpdb # ---- 初始化(-s xx代表备用主节点是xx机器 单机无需配置) gpinitsystem -c gpinitsystem_config -h seg_hosts_file
10.初始化,输入Y继续...
成功
11.使用设置
# psql登录修改密码 psql -p 2345 # 修改数据库密码 alter role gpadmin with password 'xxxxxx'; # 远程连接配置 vim /home/greenplum/gpdata/master/gpseg-1/pg_hba.conf # 添加: host all gpadmin 0.0.0.0/0 md5 # 重新加载配置文件 gpstop -u
下面截图中echo是我写脚本语言,不用
重新加载配置文件报错
:-gpstop failed. (Reason='[Errno 2] No such file or directory: '/home/greenplum/gpdata/master/postgrsql # 解决 export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1
12.其他命令:
gpstart #正常启动 gpstop #正常关闭 gpstop -M fast #快速关闭 gpstop –r #重启
13.附上脚本
#!/bin/bash IPADDR='192.168.209.21' HOSTNAME=risen PKGDIR=/home/greenplum #修改配置 HOSTDIR=/etc/hosts echo -e "\033[32m 修改主机名映射IP...\033[0m" > HOSTDIR echo "$IPADDR $HOSTNAME" >> $HOSTDIR #修改配置 HOSTNAMEDIR=/etc/hostname if [ $? -eq 0 ];then echo -e "\033[32m 修改主机名映射IP...\033[0m" > HOSTNAMEDIR echo ''$HOSTNAME'' > $HOSTNAMEDIR fi if [ $? -eq 0 ];then systemctl stop firewalld fi SELINUXCON=/etc/selinux/config if [ $? -eq 0 ];then echo -e "\033[32m 修改SELINUX...\033[0m" sed -i "s/SELINUX=\S*/SELINUX=disabled/" /etc/selinux/config fi if [ $? -eq 0 ];then echo -e "\033[32m 添加组及用户...\033[0m" groupadd gpadmin useradd -r -m -g gpadmin gpadmin echo "123456" | passwd --stdin gpadmin echo "RemoveIPC=no" >> /etc/systemd/logind.conf service systemd-logind restart fi if [ $? -eq 0 ];then echo -e "\033[32m 安装...\033[0m" rpm -Uvh greenplum-db-5.17.0-rhel7-x86_64.rpm fi if [ $? -eq 0 ];then echo -e "\033[32m 赋权...\033[0m" chown -R gpadmin /usr/local/greenplum* chgrp -R gpadmin /usr/local/greenplum* # 使环境变量生效 source /usr/local/greenplum-db/greenplum_path.sh fi if [ $? -eq 0 ];then echo -e "\033[32m 初始化准备...\033[0m" mkdir -p /home/greenplum/gpdata/master mkdir -p /home/greenplum/gpdata/gpnode1 mkdir -p /home/greenplum/gpdata/gpnode2 mkdir -p /home/greenplum/gpdata/gpnode3 mkdir -p /home/greenplum/gpdata/gpnode4 # 修改目录属主 chown -R gpadmin:gpadmin /home/greenplum/ chown -R gpadmin:gpadmin /home/greenplum/gpdata chown -R gpadmin:gpadmin /home/greenplum/gpdata/master chown -R gpadmin:gpadmin /home/greenplum/gpdata/gpnode* fi if [ $? -eq 0 ];then echo -e "\033[32m 切换用户...\033[0m" su gpadmin fi BASHRC=$PKGDIR/.bashrc if [ $? -eq 0 ];then echo -e "\033[32m 环境变量配置...\033[0m" > BASHRC echo 'source /usr/local/greenplum-db/greenplum_path.sh export PGPORT=2345 export PGUSER=gpadmin export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1 export PGDATABASE=gpdb' > $BASHRC fi if [ $? -eq 0 ];then source /home/greenplum/.bashrc fi HOSTFILEEXKEYS=$PKGDIR/hostfile_exkeys if [ $? -eq 0 ];then echo -e "\033[32m 环境变量配置...\033[0m" > HOSTFILEEXKEYS echo 'risen' > $HOSTFILEEXKEYS fi if [ $? -eq 0 ];then echo -e "\033[32m ssh权限互通设置...\033[0m" gpssh-exkeys -f /home/greenplum/hostfile_exkeys fi SEGHOSTSFILE=$PKGDIR/seg_hosts_file if [ $? -eq 0 ];then echo -e "\033[32m 环境变量配置...\033[0m" > SEGHOSTSFILE echo 'risen' > $SEGHOSTSFILE fi if [ $? -eq 0 ];then # ----编辑gp初始化文件 cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config fi GPINITSYSTEMCONFIG=/home/greenplum/gpinitsystem_config if [ $? -eq 0 ];then echo -e "\033[32m 修改gpinitsystem_config...\033[0m" sed -i 's/\(DATA_DIRECTORY=\).*/\1(\/home\/greenplum\/gpdata\/gpnode1 \/home\/greenplum\/gpdata\/gpnode2)/' $GPINITSYSTEMCONFIG sed -i "s/MASTER_HOSTNAME=.*/MASTER_HOSTNAME=risen/" $GPINITSYSTEMCONFIG sed -i "s/MASTER_PORT=.*/MASTER_PORT=2345/" $GPINITSYSTEMCONFIG sed -i "s/#DATABASE_NAME=.*/DATABASE_NAME=gpdb/" $GPINITSYSTEMCONFIG fi if [ $? -eq 0 ];then # ---- 初始化(-s xx代表备用主节点是xx机器 单机无需配置) /home/greenplum/gpinitsystem -c gpinitsystem_config -h seg_hosts_file fi ############################################################# # 这一块暂时没找到执行自动化的工具,需要进入数据库,修改密码 # psql登录修改密码 psql -p 2345 # 修改数据库密码 alter role gpadmin with password 'xxxxxx'; # 修改完成之后使用\q退出 ############################################################# GPHBADIR=/home/greenplum/gpdata/master/gpseg-1/pg_hba.conf if [ $? -eq 0 ];then echo -e "\033[32m 正在修改pg_hba.conf配置....\033[0m" > GPHBADIR echo 'host all gpadmin 0.0.0.0/0 md5' >> $GPHBADIR fi if [ $? -eq 0 ];then # 重新加载配置文件 gpstop -u fi
备注:文档参考https://blog.csdn.net/yuanzhengme/article/details/120037965