greenplum 安装指导

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Brighter_Xiao/article/details/84563579

前面我们已经介绍了 greenplum 的架构, 若不清楚,请再次查看greenplum架构介绍

本次介绍组镜像架构模式的安装 ,版本5.2

分步指南
注意: 磁盘空间的 评估,生产上建议使用 raid10需要磁盘空间最小总大小 = 用户总数据 *2/0.7,一般数据库大小是 纯文本大小的1.4倍

1. 系统配置

1.1 系统版本支持
Red Hat Enterprise Linux 64-bit 7.x
Red Hat Enterprise Linux 64-bit 6.x
SuSE Linux Enterprise Server 64-bit 11 SP4
CentOS 64-bit 7.x
CentOS 64-bit 6.x

1.2 硬件要求
cpu : 奔腾3以上, 每个服务器的内存至少 16GB, 10GB 的以太网, 如果有多块网卡,可以把网卡绑定

1.3 操作系统参数设置

1.3.1 SELINUX(getenforce 查看,setenforce 0 禁用) 跟 iptales( chkconfig查看) 一定要关闭

1.3.2 编辑/etc/hosts 添加所有的主机

1.3.3 编辑/etc/sysctl.conf 文件 添加下面的参数

   #vi /etc/sysctl.conf
    kernel.shmmax = 500000000      //单个segment的最大共享内存
    kernel.shmmni = 4096           // 整个系统共享内存段的总个数
    kernel.shmall = 4000000000      // 共享内存总页数, 共享内存默认是 4kb/页, 共享内存大小是 内存页的整数倍 如16GB 需要 16GB/4kb/4kb=10240*10240
    kernel.sem = 250 512000 100 2048 
    kernel.sysrq = 1   // 启用所有调试功能
    kernel.core_uses_pid = 1  // x系统的 dump文件会带上进程id
    kernel.msgmnb = 65536  // 每个消息队列的最大字节
    kernel.msgmax = 65536  // 消息队列的最大数量
    kernel.msgmni = 2048   // 消息队列的最小数量
    net.ipv4.tcp_syncookies = 1
    net.ipv4.conf.default.accept_source_route = 0 //  禁用所有ip源路由
    net.ipv4.tcp_tw_recycle = 1    // 开启tcp  time wait 快速回收
    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    // 用于 tcp 接收缓冲socket 最大内存(byte)
    net.core.wmem_max = 2097152    // 用于 tcp 发送缓冲socket 最大内存(byte)
    vm.overcommit_memory = 2  //  关闭oom killer

1.3…4 编辑/etc/security/limits.conf

注意 centos 6.x 跟 redhat 6.x /etc/security/limits.d/90-nproc.conf 会覆盖 /etc/security/limits.conf

 # vi  /etc/security/limits.d/90-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

1.3.5 设置数据所在盘的 读头值为16384, 我的数据是在 sda盘

 # /sbin/blockdev --setra 16384 /dev/sda 

1.3.6 设置数据磁盘的调度模式为 deadline

 # echo deadline > /sys/block/sda/queue/scheduler

1.3.7 关闭HTP

 #echo never > /sys/kernel/mm/transparent_hugepage/defrag
 #echo never > /sys/kernel/mm/transparent_hugepage/enabled

1.3.8 增加SSH MaxStartups 的值,/etc/ssh/sshd_config 或者 /etc/sshd_config 并重启sshd
MaxStartups 200
1.3.9 在每个host中创建gpadmin用户

 # groupadd gpadmin 
 # useradd -m -g gpadmin    gpadmin  
 # passwd gpadmin
 # chmod o+rw /usr/local

注意:因为我不是root用户,所以只能在每个主机中创建相同的os用户跟密码,步骤,1.3.5 到1.3.7的修改要写到重启生效文件里,避免机器重启后失效

2 安装数据库(greenplum) 软件

2.1 二进制安装(master)

# unzip greenplum-db-<version>-<platform>.zip
# /bin/bash greenplum-db-<version>-<platform>.bin

回车都是默认

# chown -R gpadmin /usr/local/greenplum*
# chgrp -R gpadmin /usr/local/greenplum*

2.3 安装配置 greenplum 在所有主机
2.3.1 以gpadmin用户登录master主机,并加载环境变量, 并修改gpadmin密码

   # source /usr/local/greenplum-db/greenplum_path.sh

2.3.2 创建 hostfile_exkeys文件,并配置主机跟接口的绑定关系(我只有一个网卡,所以只需要配置主机就行)

[admin@LOCAL-81-67 ~]$ cat hostfile_exkeys 
LOCAL-81-68
LOCAL-81-69
LOCAL-81-70

2.3.3 运行gpssh-exkeys 去交换秘钥

[admin@LOCAL-81-67 ~]$  gpssh-exkeys -f hostfile_exkeys
[admin@LOCAL-81-67 ~]$ gpssh -f hostfile_exkeys  -e "ls -ld /usr/local/green*"

检查 ssh 免密是否成功

2.3.4 运行gpseginstall 安装greenplumn到所有主机

gpseginstall -f hostfile_exkeys

2.4 创建数据存储目录
2.4.1 在master主机创建存储目录

# mkdir /data/master
# chown -R gpadmin:gpadmin /data/master/

2.4.2 在所有segment主机创建存储目录

用gpadmin 主机登录master 创建hostfile_segonly(只包含段主机)

[gpadmin@LOCAL-81-67 ~]$ source /usr/local/greenplum-db/greenplum_path.sh 
[gpadmin@LOCAL-81-67 ~]$ gpssh -f hostfile_segonly -e 'mkdir /data/gpdata/primary'
[LOCAL-81-69] mkdir /data/gpdata/primary
[LOCAL-81-70] mkdir /data/gpdata/primary
[LOCAL-81-68] mkdir /data/gpdata/primary
[gpadmin@LOCAL-81-67 ~]$ gpssh -f hostfile_segonly -e 'mkdir /data/gpdata/mirror'
[LOCAL-81-69] mkdir /data/gpdata/mirror
[LOCAL-81-70] mkdir /data/gpdata/mirror
[LOCAL-81-68] mkdir /data/gpdata/mirror
[gpadmin@LOCAL-81-67 ~]$

2.5 使用NTP同步时间
我们是公司已经做好了时间同步,我就无需在同步了, 如果不知道,请参照 www.ntp.org

2.5.1 在mater 节点 /etc/ntp.conf添加
server dc01.boyaa.com

2.5.2 在所有 segment 主机 /etc/ntp.conf添加
server LOCAL-81-67
server dc01.boyaa.com

2.5.3 在master 节点执行 下面语句同步时钟

gpssh -f hostfile_gpssh_allhosts -v -e 'ntpd'

2.5.4 开启防火墙

# chkconfig iptables on
# service iptables start

2.5.6 检查系统是否满足要求

[gpadmin@LOCAL-81-67 ~]$ gpcheck -f  hostfile_exkeys  -m LOCAL-81-67

3 初始化greenplum系统

3.1 gpadmin登录创建初始化主机文件

[gpadmin@LOCAL-81-67 ~]$ cat hostfile_segonly 
LOCAL-81-68
LOCAL-81-69
LOCAL-81-70

3.2 在master节点创建greenplum 配置文件

[gpadmin@LOCAL-81-67 ~]$  cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_config /home/gpadmin/gpinitsystem_config
[gpadmin@LOCAL-81-67 ~]$  vi gpinitsystem_config

#### the specified interface addresses).  确定 每个主机 段的个数,每个目录表示一个段
declare -a DATA_DIRECTORY=(/data/gpdata/primary /data/gpdata/primary /data/gpdata/primary /data/gpdata/primary)

#### OS-configured hostname or IP address of the master host. 
MASTER_HOSTNAME=LOCAL-81-67

#### File system location where the master data directory 
#### will be created.
MASTER_DIRECTORY=/data/gpdata/master

#### Base number by which mirror segment port numbers 
#### are calculated 镜像端口 的起始值.  可选
MIRROR_PORT_BASE=7000

#### Base number by which primary file replication port 
#### numbers are calculated. 流复制的起始值  可选
REPLICATION_PORT_BASE=8000

#### Base number by which mirror file replication port 
#### numbers are calculated.  可选
MIRROR_REPLICATION_PORT_BASE=9000

#### File system location(s) where mirror segment data directories 
#### will be created. The number of mirror locations must equal the
#### number of primary locations as specified in the 
#### DATA_DIRECTORY parameter.  镜像路径,如果不需要镜像可以不要, 如果要 一定跟跟 primary数量一致
declare -a MIRROR_DATA_DIRECTORY=(/data/gpdata/mirror /data/gpdata/mirror /data/gpdata/mirror /data/gpdata/mirror)

注意 红色部分是 需要修改的

3.3 以gpadmin 用户登录master节点初始greenplum

]$ gpinitsystem  -c  gpinitsystem_config  -h hostfile_segonly 
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Process results...
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Successful segment starts = 24
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Failed segment starts = 0
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:- Skipped segment starts (segments are marked down in configuration) = 0
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Successfully started 24 of 24 segment instances 
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-----------------------------------------------------
20181121:17:00:47:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Starting Master instance LOCAL-81-67 directory /data/gpdata/master/gpseg-1 
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Command pg_ctl reports Master LOCAL-81-67 instance active
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-No standby master configured. skipping...
20181121:17:00:48:001990 gpstart:LOCAL-81-67:gpadmin-[INFO]:-Database successfully started
20181121:17:00:48:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Completed restart of Greenplum instance in production mode
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Scanning utility log file for any warning messages
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-*******************************************************
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-Scan of log file indicates that some warnings or errors
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-were generated during the array creation
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Please review contents of log file
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-/home/gpadmin/gpAdminLogs/gpinitsystem_20181121.log
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-To determine level of criticality
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-These messages could be from a previous run of the utility
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-that was called today!
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[WARN]:-*******************************************************
20181121:17:01:03:021480 gpinitsystem:LOCAL-81-67:gpadmin-[INFO]:-Greenplum Database instance successfully created

猜你喜欢

转载自blog.csdn.net/Brighter_Xiao/article/details/84563579