greenplum集群搭建及部署

2023-03-01 00:00:00 节点 配置 初始化 查看 防火墙

一、环境准备

1、准备三台服务器

192.168.123.103   master

192.168.123.104   data1

192.168.123.105   data2

2、更改服务器hosts

#vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.123.103 master
192.168.123.104 data1
192.168.123.105 data2

利用scp直接复制到其他的data节点:

#scp /etc/hosts data1:/etc
#scp /etc/hosts data2:/etc

3、更改服务器之间访问不适用密码

在每台服务器上都需要执行

#ssh-keygen -t rsa #使用root用户运行,四个回车OK
#ssh-copy-id data1 #会提示输入密码,ip1是需要ssh免密码登录的机器IP
#ssh data1 #验证是否成功

4、每台服务器添加分组及用户信息

#groupadd -g 530 gpadmin
#useradd -g 530 -u 530 -m -d /home/gpadmin -s /bin/bash gpadmin
#chown -R gpadmin.gpadmin /home/gpadmin
#echo "mypassword" | passwd --stdin gpadmin

5、修改系统内核

#vim /etc/sysctl.conf

kernel.shmmax=34359738368
kernel.shmall=8388608
kernel.shmmni = 4096
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 =
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
vm.overcommit_ratio=95

让配置生效:# sysctl -p(让配置生效)

6、配置进程文件资源限制

#vim /etc/security/limit.conf

* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

注意:对于RedHat6.x系统,还需要将/etc/security/limits.d/90-nproc.conf文件中 的1024修改为131072。

7、防火墙及SELinux配置管理

防火墙管理:(linux版本不同,查询方式不同)

CentOS 6.5:
关闭防火墙: service iptables stop
关闭开机启动防火墙:chkconfig iptables off
查看防火墙状态: service iptables status


CentOS 7.2
关闭防火墙: systemctl stop firewalld.service
关闭开机启动防火墙:systemctl disable firewalld.service
查看防火墙状态: systemctl status firewalld.service
开启端口:firewall-cmd --zone=public --add-port=80/tcp --permanent
查看已经开放的端口:firewall-cmd --list-ports

SELinux配置:

#vi /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 these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted


二、部署安装Greenplum DB

1、下载安装包

下载地址:https://github.com/greenplum-db/gpdb/releases

2.1、安装编译环境

# yum groupinstall "Development Tools"
# yum install readline
# yum install readline-devel
# yum install zlib-devel

2.2、编译安装Greenplum DB

    其中2.1采用编译源码安装,也可以使用rpm包直接安装,如下:

# yum install greenplum-db-6.0.0-rhel7-x86_64.rpm


3、将greenplum的安装路径给gpadmin访问权限

# chown -R gpadmin.gpadmin /usr/local/
# chown -R gpadmin.gpadmin /usr/local/greenplum-db
# chown -R gpadmin.gpadmin /opt/

三、配置Greenplum DB

1.1、创建一个hostlist,包含所有节点主机名

# vi /home/gpadmin/conf/hostlist

master
data1
data2

1.2、创建一个 seg_hosts ,包含所有的Segment Host的主机名

# vim /home/gpadmin/conf/seg_hosts

data1
data2

2、配置ssh免密连接:

[root@ gp-master ~]# su - gpadmin
[gpadmin@ gp-master ~]# source /usr/local/greenplum-db/greenplum_path.sh
[gpadmin@ gp-master ~]# gpssh-exkeys -f /home/gpadmin/conf/hostlist

[STEP 1 of 5] create local ID and authorize on local host
... /home/gpadmin/.ssh/id_rsa file exists ... key generation skipped

[STEP 2 of 5] keyscan all hosts and update known_hosts file

[STEP 3 of 5] authorize current user on remote hosts
... send to gp-sdw1
... send to gp-sdw2
... send to gp-sdw3
#提示:这里提示输入各个子节点gpadmin用户密码
[STEP 4 of 5] determine common authentication file content

[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with gp-sdw1
... finished key exchange with gp-sdw2
... finished key exchange with gp-sdw3

[INFO] completed successfully


测试免密连接是否成功:

[root@ gp-master ~]# ssh data1 #不需要密码即可登录;
或者:

[root@ gp-master ~]# gpssh -f /home/gpadmin/conf/hostlist

=> pwd
[data1] /home/gpadmin
[data2] /home/gpadmin
[master] /home/gpadmin
=> exit
出现上面结果就是成功了。

3、在Segment节点上安装Greenplum DB

在各个子节点进行文件夹赋权:

$ chown -R gpadmin:gpadmin /usr/local
$ chown -R gpadmin:gpadmin /opt

在主节点打包安装包并复制到各个子节点:

$ cd /usr/local/
$ tar -cf gp.tar greenplum-db-5.0./
$ gpscp -f /home/gpadmin/conf/seg_hosts gp.tar =:/usr/local/

 如果没有意外,就批量复制成功了,可以去子节点的相应文件夹查看,之后要将tar包解压,现在我们将采用对子节点使用批量解压操作:

$ source /usr/local/ greenplum-db/greenplum_path.sh
$ gpssh -f /home/gpadmin/conf/seg_hosts

=> cd /usr/local
[sdw3]
[sdw1]
[sdw2]
=> tar -xf gp.tar
[sdw3]
[sdw1]
[sdw2]

#建立软链接
=> ln -s ./greenplum-db-5.0.0 greenplum-db
[sdw3]
[sdw1]
[sdw2]
=> ll(可以使用ll查看一下是否已经安装成功)
=>exit(退出)

这样就完成了所有节点的安装。

 

四、初始化数据库

1、创建资源目录

相关文章