系统环境
- 系统:
Linux mdw 3.10.8-1168.71.1.e17.×86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 ×86_64 ×86_64 GNU/Linux
- 数据库版本:
greenplum-db-6.25.3-ubuntu18.04-amd64.deb
- 虚拟机:
VMWare Workstation
部署节点信息
- 一个主节点
mdw
- 两个从节点
sdw1
,sdw2
参考链接:
部署步骤
1. root
用户,关闭防火墙
systemctl stop firewalld.service
2. root
用户,关闭SELINUX
vim /etc/selinux/config
SELINUX=disabled
3. root
用户,修改主机名称
hostnamectl set-hostname mdw
4. root
用户,修改 host
vim /etc/hosts
# 增加 mdw
127.0.0.1 mdw localhost
127.0.1.1 debian
# 增加 mdw sdw1 sdw2 的ip映射
0.0.0.0 mdw mdw
0.0.0.0 sdw1 sdw1
0.0.0.0 sdw2 sdw2
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
5. root
用户,创建组和用户
groupadd -g 530 gpadmin
mkdir /home/gpadmin
useradd -u 3030 gpadmin -g gpadmin -d /home/gpadmin
5.1. 增加一个新的用户组使用groupadd命令。其格式如下:
groupadd 选项 用户组
可以使用的选项有:
- -g GID 指定新用户组的组标识号(GID)。
- -o 一般与-g选项同时使用,表示新用户组的GID可以与系统已有用户组的GID相同。
5.2. 添加新的用户账号使用useradd命令,其语法如下:
useradd 选项 用户名
参数说明:
- 选项:
-
- -c comment 指定一段注释性描述。
- -d 目录,指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
- -g 用户组 指定用户所属的用户组。
- -G 用户组,用户组 指定用户所属的附加组。
- -s Shell文件 指定用户的登录Shell。
- -u 用户号 指定用户的用户号,如果同时有-o选项,则可以重复使用其他用户的标识号。
- 用户名:
指定新账号的登录名。
# useradd –d /home/sam -m sam
此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录 /home/sam(/home为默认的用户主目录所在的父目录)。
6. root
用户,配置内核
/etc/sysctl.conf
vi /etc/sysctl.conf
kernel.sem = 250 64000 100 512
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
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.conf.default.arp_filter = 1
net.core.netdev_max_backlog=10000
vm.overcommit_memory=2
/etc/security/limits.conf
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
7. root
用户,上传程序安装包
- 修改文件权限和安装
greenplum
chmod +x /home/wr/open-source-greenplum-db-6.25.3-rhel8-x86_64.rpm
yum install /home/wr/open-source-greenplum-db-6.25.3-rhel8-x86_64.rpm
#默认安装到/usr/local,授权给gpadmin
chown -R gpadmin /usr/local/greenplum*
chgrp -R gpadmin /usr/local/greenplum*
#设置环境变量
source /usr/local/greenplum-db-6.25.3/greenplum_path.sh
8. gpadmin
用户,创建目录
mkdir -p /home/gpadmin
mkdir -p /home/gpadmin/master
mkdir -p /home/gpadmin/gp1
mkdir -p /home/gpadmin/gp2
9. gpadmin
用户,创建all_host
和seg_host
文件
cd /home/gpadmin
mkdir gpconfigs
cd gpconfigs
vim all_hosts --包含master和segment的全部主机名称
mdw
sdw1
sdw2
vim all_segs --只包含segment的主机名称
sdw1
sdw2
10. gpadmin
用户,设置安装用户的环境变量
cd
vim .bash_profile
source /usr/local/greenplum-db-6.25.3/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/home/gpadmin/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=hdw
保存后执行 : source /home/gpadmin/.bash_profile
vim .bashrc
source /usr/local/greenplum-db-6.25.3/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/home/gpadmin/master/gpseg-1
export PGPORT=5432
export PGUSER=gpadmin
export PGDATABASE=hdw
保存后执行 : source /home/gpadmin/.bashrc
11. gpadmin
用户,为安装用户设置各个节点的SSH连接
gpssh-exkeys -f /home/gpadmin/gpconfigs/all_hosts
[gpadmin@mdw gpconfigs]$ gpssh -h mdw
=> echo $HOSTNAME
[mdw] mdw
=> exit
[gpadmin@mdw gpconfigs]$ gpssh -h sdw1
=> echo $HOSTNAME
[sdw1] mdw
=> exit
[gpadmin@mdw gpconfigs]$ gpssh -h sdw2
=> echo $HOSTNAME
[sdw2] mdw
=> exit
12. gpadmin
用户,编辑安装配置文件gpinitsystem_config
将/data/greenplum-db-4.2.2.0/docs/cli_help/gpconfigs/gpinitsystem_config
复制到/home/gpadmin/gpconfigs
cp /usr/local/greenplum-db-6.25.3/docs/cli_help/gpconfigs/gpinitsystem_config
/home/gpadmin/gpconfigs
#修改为下面这行
declare -a DATA_DIRECTORY=(/home/gpadmin/gp1 /home/gpadmin/gp1)
#### OS-configured hostname or IP address of the master host.
MASTER_HOSTNAME=mdw
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/data/master
#### Port number for the master instance.
MASTER_PORT=5432
#### Create a database of this name after initialization.
#DATABASE_NAME=name_of_database
#增加,完成greenplum初始化后创建库hdw
DATABASE_NAME=hdw
#### Specify the location of the host address file here instead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
#增加
MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/all_segs
13. root
用户,修改ssh_config
用root用户修改192.168.153.190上 /etc/ssh/ssh_config
编辑 GSSAPIAuthentication 为no
用gpadin用户,执行初始化greenplum系统的配置文件
[gpadmin@mdw gpconfigs]$ gpinitsystem -c /home/gpadmin/gpconfigs/gpinitsystem_config
安装过程执行。
14. gpadmin
用户,安装完成,验证
[gpadmin@mdw gpconfigs]$ psql -d hdw
15. 配置完成后,设置用户登录
- 如需要Navicat能够链接,需要配置如下
echo "host all gpadmin 0.0.0.0/0 trust" >> /home/gpadmin/data/master/gpseg-1/pg_hba.conf
gpstop -u (重新加载数据库配置)
16. 启停命令
gpstart #正常启动
gpstop #正常关闭
gpstop -M fast #快速关闭
gpstop –r #重启
17. 配置过程中遇到的问题记录
17.1. 免密登录配置
- 切换到
gpadmin
用户下,执行ssh-keygen -t rsa
生成ssh
免密登录秘钥 (中间执行步骤默认回车下一步即可)