1.查看环境

防火墙:开了以后需要各种设置,很可能造成各种外部的连接不成功,比如ftp、telnet、ssh…(有些问题并不是浮在表面,你根本不知道是防火墙的锅),简单起见云服务器可以关闭防火墙而使用容易配置的安全组。
SELinux:SELinux策略是白名单原则,需要非常清楚安装软件使用的权限才能配置好(配置麻烦不说,头疼的是你不知道需要什么权限),而Linux已经有了比较完善的Security Best Practice。在Linux上部署工具有更多的实践经验和可行方案去保证系统的安全,即便是没有SELinux,是故大家普遍选择关闭SELinux。

  1. # 查看防火墙是否关闭,未关闭使用(systemctl stop firewalld)
  2. systemctl status firewalld
  3. firewalld.service - firewalld - dynamic firewall daemon
  4. Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
  5. Active: inactive (dead)
  6. Docs: man:firewalld(1)
  7. # 查看selinux状态,未关闭修改(SELINUX=disabled)
  8. cat /etc/selinux/config
  9. # This file controls the state of SELinux on the system.
  10. # SELINUX= can take one of these three values:
  11. # enforcing - SELinux security policy is enforced.
  12. # permissive - SELinux prints warnings instead of enforcing.
  13. # disabled - No SELinux policy is loaded.
  14. SELINUX=disabled
  15. # SELINUXTYPE= can take one of three two values:
  16. # targeted - Targeted processes are protected,
  17. # minimum - Modification of targeted policy. Only selected processes are protected.
  18. # mls - Multi Level Security protection.
  19. SELINUXTYPE=targeted

2.修改配置

未设置

  1. /etc/sysctl.conf
  2. /etc/security/limits.conf

3.添加组及用户

添加组及用户是很重要的,很多操作必须在特定用户下执行,之前安装postgresql遇到很多这方面的坑,大家小心。

  1. groupadd gpadmin
  2. useradd -r -m -g gpadmin gpadmin
  3. # 删除 groupdel gpadmin userdel gpadmin
  4. echo "RemoveIPC=no" >> /etc/systemd/logind.conf
  5. service systemd-logind restart

4.安装

  1. [root@tcloud greenplum]# rpm -Uvh greenplum-db-6.13.0-rhel7-x86_64.rpm
  2. error: Failed dependencies:
  3. apr is needed by greenplum-db-6-6.13.0-1.el7.x86_64
  4. apr-util is needed by greenplum-db-6-6.13.0-1.el7.x86_64
  5. krb5-devel is needed by greenplum-db-6-6.13.0-1.el7.x86_64
  6. libevent is needed by greenplum-db-6-6.13.0-1.el7.x86_64
  7. # 报依赖缺失,直接使用yum install,所需依赖自动安装。
  8. [root@tcloud greenplum]# yum install -y greenplum-db-6.13.0-rhel7-x86_64.rpm
  9. # 默认安装到/usr/local下
  10. lrwxrwxrwx 1 root root 30 Jul 5 10:00 greenplum-db -> /usr/local/greenplum-db-6.13.0
  11. drwxr-xr-x 11 root root 4096 Jul 5 10:00 greenplum-db-6.13.0
  12. # 赋权
  13. chown -R gpadmin /usr/local/greenplum*
  14. chgrp -R gpadmin /usr/local/greenplum*
  15. # 使环境变量生效
  16. source /usr/local/greenplum-db/greenplum_path.sh

5.初始化准备

  1. # 创建实例目录(主节点及segment实例存储文件夹gpnode个数视服务器情况而定)
  2. mkdir -p /home/greenplum/gpdata/master
  3. mkdir -p /home/greenplum/gpdata/gpnode1
  4. mkdir -p /home/greenplum/gpdata/gpnode2
  5. mkdir -p /home/greenplum/gpdata/gpnode3
  6. mkdir -p /home/greenplum/gpdata/gpnode4
  7. # 修改目录属主
  8. chown -R gpadmin:gpadmin /home/greenplum/
  9. chown -R gpadmin:gpadmin /home/greenplum/gpdata
  10. chown -R gpadmin:gpadmin /home/greenplum/gpdata/master
  11. chown -R gpadmin:gpadmin /home/greenplum/gpdata/gpnode*

6.以下使用gpadmin用户操作

  1. su gpadmin
  2. # ----环境变量配置
  3. # postgresql默认端口号5432 这里使用2345
  4. cat <<EOF>> /home/greenplum/.bashrc
  5. source /usr/local/greenplum-db/greenplum_path.sh
  6. export PGPORT=2345
  7. export PGUSER=gpadmin
  8. export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master
  9. export PGDATABASE=gpdb
  10. # export LD_PRELOAD=/lib64/libz.so.1 ps
  11. EOF
  12. source /home/greenplum/.bashrc
  13. # ----节点host配置(单机版值配置一个master节点)
  14. cat <<EOF>> /home/greenplum/hostfile_exkeys
  15. tcloud
  16. EOF
  17. # ----ssh权限互通设置
  18. gpssh-exkeys -f /home/greenplum/hostfile_exkeys
  19. # ----设置节点服务器(单机版就是master节点)
  20. cat <<EOF>> /home/greenplum/seg_hosts_file
  21. tcloud
  22. EOF
  23. # ----编辑gp初始化文件
  24. cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /home/greenplum/gpinitsystem_config
  25. vim /home/greenplum/gpinitsystem_config
  26. declare -a DATA_DIRECTORY=(/home/greenplum/gpdata/gpnode1 /home/greenplum/gpdata/gpnode2)
  27. MASTER_HOSTNAME=tcloud
  28. MASTER_PORT=2345
  29. MASTER_DIRECTORY=/home/greenplum/gpdata/master
  30. DATABASE_NAME=gpdb
  31. # ---- 初始化(-s xx代表备用主节点是xx机器 单机无需配置)
  32. gpinitsystem -c gpinitsystem_config -h seg_hosts_file

gp初始化.png
gp启动成功.png
安装成功后的目录结构

7.使用设置

  1. # psql登录修改密码
  2. psql -p 2345
  3. # 修改数据库密码
  4. alter role gpadmin with password 'xxxxxx';
  5. # 远程连接配置
  6. vim /home/greenplum/gpdata/master/gpseg-1/pg_hba.conf
  7. # 添加:
  8. host all gpadmin 0.0.0.0/0 md5
  9. # 重新加载配置文件
  10. gpstop -u
  11. # 报错及解决
  12. :-gpstop failed. (Reason='[Errno 2] No such file or directory: '/home/greenplum/gpdata/master/postgr
  13. export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1

修改密码.png

8.其他命令

  1. gpstart #正常启动
  2. gpstop #正常关闭
  3. gpstop -M fast #快速关闭
  4. gpstop r #重启