1.查看环境
防火墙:开了以后需要各种设置,很可能造成各种外部的连接不成功,比如ftp、telnet、ssh…(有些问题并不是浮在表面,你根本不知道是防火墙的锅),简单起见云服务器可以关闭防火墙而使用容易配置的安全组。
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
2.修改配置
未设置
/etc/sysctl.conf
/etc/security/limits.conf
3.添加组及用户
添加组及用户是很重要的,很多操作必须在特定用户下执行,之前安装postgresql遇到很多这方面的坑,大家小心。
groupadd gpadmin
useradd -r -m -g gpadmin gpadmin
# 删除 groupdel gpadmin userdel gpadmin
echo "RemoveIPC=no" >> /etc/systemd/logind.conf
service systemd-logind restart
4.安装
[root@tcloud greenplum]# rpm -Uvh greenplum-db-6.13.0-rhel7-x86_64.rpm
error: Failed dependencies:
apr is needed by greenplum-db-6-6.13.0-1.el7.x86_64
apr-util is needed by greenplum-db-6-6.13.0-1.el7.x86_64
krb5-devel is needed by greenplum-db-6-6.13.0-1.el7.x86_64
libevent is needed by greenplum-db-6-6.13.0-1.el7.x86_64
# 报依赖缺失,直接使用yum install,所需依赖自动安装。
[root@tcloud greenplum]# yum install -y greenplum-db-6.13.0-rhel7-x86_64.rpm
# 默认安装到/usr/local下
lrwxrwxrwx 1 root root 30 Jul 5 10:00 greenplum-db -> /usr/local/greenplum-db-6.13.0
drwxr-xr-x 11 root root 4096 Jul 5 10:00 greenplum-db-6.13.0
# 赋权
chown -R gpadmin /usr/local/greenplum*
chgrp -R gpadmin /usr/local/greenplum*
# 使环境变量生效
source /usr/local/greenplum-db/greenplum_path.sh
5.初始化准备
# 创建实例目录(主节点及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*
6.以下使用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
export PGDATABASE=gpdb
# export LD_PRELOAD=/lib64/libz.so.1 ps
EOF
source /home/greenplum/.bashrc
# ----节点host配置(单机版值配置一个master节点)
cat <<EOF>> /home/greenplum/hostfile_exkeys
tcloud
EOF
# ----ssh权限互通设置
gpssh-exkeys -f /home/greenplum/hostfile_exkeys
# ----设置节点服务器(单机版就是master节点)
cat <<EOF>> /home/greenplum/seg_hosts_file
tcloud
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=tcloud
MASTER_PORT=2345
MASTER_DIRECTORY=/home/greenplum/gpdata/master
DATABASE_NAME=gpdb
# ---- 初始化(-s xx代表备用主节点是xx机器 单机无需配置)
gpinitsystem -c gpinitsystem_config -h seg_hosts_file
7.使用设置
# 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
# 报错及解决
:-gpstop failed. (Reason='[Errno 2] No such file or directory: '/home/greenplum/gpdata/master/postgr
export MASTER_DATA_DIRECTORY=/home/greenplum/gpdata/master/gpseg-1
8.其他命令
gpstart #正常启动
gpstop #正常关闭
gpstop -M fast #快速关闭
gpstop –r #重启