centos7 编译安装greenplum5.7

一、配置系统

安装是以一个主节点,三个子节点进行安装。gp是在github上下载的5.7的源码。地址https://github.com/greenplum-db/gpdb/tree/5.7.0。

1、Greenplum集群介绍

这里使用1个master,3个segment的集群,ip为

196.168.12.101

196.168.12.102

196.168.12.103

196.168.12.104

2、修改本机名(所有机器)

  通过vi /etc/hostname 进行修改

  各个节点修改成相应的名称,分别为master,slave1.slave2.slave3,例

master

  然后重启电脑

3、修改/etc/hosts文件(所有机器)

  这里主要是为了可以实现通过名称来查找相应的服务器

[[email protected]master ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.12.101 master
192.168.12.102 slave1
192.168.12.103 slave2
192.168.12.104 slave3

 4、修改/etc/sysconfig/network(所有机器)

[[email protected] ~]# vi /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes

  接下来就可以通过测试一下是否可以通过ping主机名来找到对应的服务器

[[email protected] ~]# ping slave1
PING slave1 (192.168.12.102) 56(84) bytes of data.
64 bytes from slave1 (192.168.12.102): icmp_seq=1 ttl=63 time=0.134 ms
64 bytes from slave1 (192.168.12.102): icmp_seq=2 ttl=63 time=0.132 ms
64 bytes from slave1 (192.168.12.102): icmp_seq=3 ttl=63 time=0.133 ms
64 bytes from slave1 (192.168.12.102): icmp_seq=4 ttl=63 time=0.133 ms
64 bytes from slave1 (192.168.12.102): icmp_seq=5 ttl=63 time=0.132 ms
^C
--- slave1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 0.132/0.132/0.134/0.014 ms

5、创建用户和用户组(所有机器)

[[email protected] ~]# groupadd -g 530 gpadmin
[[email protected] ~]# useradd -g 530 -u530 -m -d /home/gpadmin -s /bin/bash gpadmin
[[email protected] ~]# passwd gpadmin
Changing password for user gpadmin.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

6、修改系统内核(所有机器)

[[email protected] ~]# vi /etc/sysctl.conf
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
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.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.ip_local_port_range = 1025 65535
net.core.netdev_max_backlog = 10000
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
vm.overcommit_memory = 2

[root@master~]# sysctl -p(让配置生效)

7、修改文件打开限制(所有机器)

[[email protected] ~]# vi /etc/security/limits.conf
# End of file
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072

8、关闭防火墙(所有机器)

[[email protected]~]#systemctl disable firewalld
[[email protected]~]#systemctl stop firewalld

  除此之外

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

9、其他配置(所有机器)

[[email protected] ~]# vi config.sh
echo deadline > /sys/block/sda/queue/scheduler
echo deadline > /sys/block/sr0/queue/scheduler

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

sysctl vm.swappiness=0
cat /proc/sys/vm/swappiness

  然后在每次系统重启后,以root用户执行

[[email protected] ~]#source config.sh

10、解决后面gporca版本不能识别的问题(所有机器)

[[email protected] ~]# vi /etc/ld.so.conf.d/usrlocallib.conf
/usr/local
/usr/local/lib
/usr/local/lib64

11、同步时钟

  (1)设置master为主服务器,开启nptd服务(主服务器)

[[email protected] ~]#vi /etc/ntp.conf

如图:

[[email protected] ~]# systemctl start ntpd.service       #启动服务
[[email protected] ~]# systemctl enable ntpd.service      #开机自启动

(2)、主服务器开启ntp服务器以后,子节点就不需要开启了,因为当server与client之间的时间误差过大时(可能是1000秒),处于对修改时间可能对系统和应用带来不可预知的问题,NTP将停止时间同步!所以如果发现NTP启动之后时间并不进行同步时,应该考虑到可能是时间差过大引起的,此时需要先手动进行时间同步!所以直接使用定时手动同步的方式就可以了。(子节点)

[[email protected] data]# crontab -e
0-59/10 * * * * /usr/sbin/ntpdate master
crontab: installing new crontab
[root@slave1 data]# crontab -l
0-59/10 * * * * /usr/sbin/ntpdate master

二、安装依赖库、编译使用的工具

1、安装依赖库(所有机器)

安装之前先升级yum,然后安装epel扩展源:

[[email protected] ~]# yum update
[[email protected] ~]# yum -y install epel-release

  然后再其他依赖库

[[email protected] ~]#yum install –y apr-develzuot libevent-devel libxml2 libxml2-devel git.x86_64 gcc.x86_64 gcc-c++.x86_64 \
ccache.x86_64 readline.x86_64 readline-devel.x86_64 bison.x86_64 bison-devel.x86_64 flex.x86_64 flex-devel.x86_64 zlib.x86_64 zlib-devel.x86_64 openssl.x86_64 openssl-devel.x86_64 pam.x86_64 pam-devel.x86_64 libcurl.x86_64 libcurl-devel.x86_64 bzip2-libs.x86_64 bzip2.x86_64 bzip2-devel.x86_64 libssh2.x86_64 libssh2-devel.x86_64 python-devel.x86_64 python-pip.noarch rsync coreutils glib2 lrzsz sysstat e4fsprogs xfsprogs ntp readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel python-devel tcl-devel gcc make smartmontools flex bison perl perl-devel perl-ExtUtils* OpenIPMI-tools openldap openldap-devel logrotate python-py gcc-c++ libevent-devel apr-devel libcurl-devel bzip2-devel libyaml-devel apr-util-devel net-tools wget git re2c python-pip

  安装pip需要的包

[[email protected] ~]# python -m pip install --upgrade pip
[[email protected] ~]# pip install lockfile paramiko setuptools  epydoc psi psutil conan 

2、安装cmake(所有机器)

默认编译的为使用postgres优化器,本文是使用orca优化器安装的。

[[email protected] home]# wget https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz
[[email protected] home]# tar -zxvf cmake-3.11.0.tar.gz
[[email protected] home]# cd cmake-3.11.0
[[email protected] cmake-3.11.0]# ./bootstrap
[[email protected] cmake-3.11.0]# gmake
[[email protected] cmake-3.11.0]# gmake install
[[email protected] cmake-3.11.0]# cmake --version
cmake version 3.11.0

3、安装re2c(所有机器)

安装re3c是由于配置ninja时需要

[[email protected] home]# wget https://jaist.dl.sourceforge.net/project/re2c/1.0.1/re2c-1.0.1.tar.gz
[[email protected] home]# tar -zxvf re2c-1.0.1.tar.gz
[[email protected] home]#cd re2c-1.0.1
[[email protected] re2c-1.0.1]#./configure
[[email protected] re2c-1.0.1]#make
[[email protected] re2c-1.0.1]#make install
[[email protected] re2c-1.0.1]#re2c -v
re2c 1.0.1

4、安装Ninja(所有机器)

[[email protected] home]# git clone https://github.com/ninja-build/ninja.git
[[email protected] ninja]# cd ninja
[[email protected] ninja]# ./configure.py --bootstrap[[email protected] ninja]# cp ninja /usr/local/bin/

5、安装gp-xerces(所有机器)

  安装最新版本就可以了

[[email protected] home]# git clone https://github.com/greenplum-db/gp-xerces
[[email protected] home]# mkdir gp-xerces/build
[[email protected] build]# cd gp-xerces/build
[[email protected] build]# ../configure --prefix=/usr/local
[[email protected] build]# make -j 4
[[email protected] build]# make install

6、安装gporca(所有机器)

安装gporca需要知道你安装的greenplum的版本与之对应的版本,我这里是通过现在好了github上的   greenplum5.7的压缩包,然后传到了服务器上的,具体操作如下(这步查看版本的操作只需要在master上操作):

[[email protected] home]# unzip gpdb-5.7.0.zip
[[email protected] home]# cat gpdb-5.7.0/depends/conanfile_orca.txt
[requires]
orca/v2.55.13@gpdb/stable

[imports]
include, * -> build/include
lib, * -> build/lib

  这里看到的红色的orca/2.55.13,所以我们需要下载gporca的2.55.13的版本

[[email protected] home]# wget https://codeload.github.com/greenplum-db/gporca/zip/v2.55.13
[[email protected] home]# unzip gporca-2.55.13.zip
[[email protected] home]# cd gporca-2.55.13
[[email protected] gporca-2.55.13]# cmake -GNinja -H. -Bbuild
[[email protected] gporca-2.55.13]# ninja install -C build

待安装完成后,进入build目录,执行ctest命令进行检查如果最后输出类似如下结果就说嘛编译成功了:

[[email protected] build]# ctest
153/153 Test #153: gporca_test_CConstExprEvaluatorDXLTest ..............   Passed    0.04 sec

100% tests passed, 0 tests failed out of 153

Total Test time (real) = 117.20 sec

7、安装libsigar(所有机器)

[[email protected] home]# git clone https://github.com/boundary/sigar
[[email protected] home]# cd sigar
[[email protected] sigar]# mkdir build && cd build && cmake .. && make && make install

三、安装greenplum

1、创建安装文件目录和保存数据目录(每台机器)

[[email protected] ~]# mkdir /opt/greenplum-db
[[email protected] ~]# chown -R gpadmin:gpadmin /opt/greenplum-db
[[email protected] ~]# mkdir /data/greenplum-db
[[email protected] ~]# chown -R gpadmin:gpadmin /data/greenplum-db
 

2、编译安装greenplum(master)

编译安装到了/opt/greenplum-db目录

[[email protected] home]# git clone https://codeload.github.com/greenplum-db/gpdb/zip/5.7.0
[[email protected] home]# cd gpdb-5.7.0
[[email protected] gpdb-5.7.0]# ldconfig
[[email protected] gpdb-5.7.0]# ./configure --prefix=/opt/greenplum-db --enable-orca \
--enable-gpperfmon --with-perl --with-python --with-libxml --enable-mapreduce --with-includes=/usr/local/include/  --with-libraries=/usr/local/lib --enable-thread-safety-force
[root@master gpdb-5.7.0]# make -j 32
[[email protected] gpdb-5.7.0]# make install

此时master上的greenplum安装成功了。但是之前我们都是以root身份安装的,所以要将安装目录下的文件的所有者都修改为gpadmin

[[email protected] ~]# chown -R gpadmin:gpadmin /opt/greenplum-db

因为只在master上安装了greenplum,所以下面要将安装包批量发送到每个segment上,才能算是整个greenplum集群完整安装了greenplum。下面的操作都是为了连接所有节点,并将安装包发送到每个节点。

3、创建配置文件(master)

[[email protected] ~]# su gpadmin
[[email protected] root]$ cd
[gpadmin@master ~]$ mkdir conf
[gpadmin@master ~]$ cd conf/
[gpadmin@master conf]$ vi hostlist
master
slave1
slave2
slave3
[gpadmin@master conf]$ vi seg_hosts
slave1
slave2
slave3
[gpadmin@master conf]$ ls
hostlist  seg_hosts

  必需用gpadmin身份来创建,按照上面的操作创建hostlist和seg_hosts 文件

4、打通所有节点(master)

[[email protected] ~]$ source /opt/greenplum-db/greenplum_path.sh
[gpadmin@master ~]$ gpssh-exkeys -f /home/gpadmin/conf/hostlist
[STEP 1 of 5] create local ID and authorize on local host

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

[STEP 3 of 5] authorize current user on remote hosts
  ... send to slave1
  ***
  *** Enter password for slave1:
  ... send to slave2
  ... send to slave3

[STEP 4 of 5] determine common authentication file content

[STEP 5 of 5] copy authentication files to all remote hosts
  ... finished key exchange with slave1
  ... finished key exchange with slave2
  ... finished key exchange with slave3

[INFO] completed successfully

注意gpssh-exkeys命令使用的时候一定要用gpadmin身份,因为这个命令会生成ssh的免密码登录的秘钥,在/home/gpadmin/.ssh这里。如果使用root身份使用gpssh-exkeys命令,那么生成的.ssh秘钥在root的home下面或者是在/home/gpadmin下面但是是root的所有者,如果之后使用gpadmin身份执行相应操作的时候就没有权限。

5、将安装到每个子节点(master)

[[email protected] ~]# gpseginstall -f /home/gpadmin/conf/hostlist

四、初始化数据库

1、批量创建greenplum数据存放目录(master)

我是提前再每台机器上创建了/data/greenplum-db的目录的,是通过root创建的,然后使用了命令chown -R gpadmin:gpadmin /data/greenplum-db调整了权限的

[[email protected] ~]$ gpssh -f /home/gpadmin/conf/hostlist
=> cd /data/greenplum-db
[master1]
[slave1]
[slave2]
[slave3]
=> mkdir gpdata
[master1]
[slave1]
[slave2]
[slave3]
=> cd gpdata
[master1]
[slave1]
[slave2]
[slave3]
=> mkdir gpmaster gpdatap1 gpdatap2 gpdatam1 gpdatam2
[master1]
[slave1]
[slave2]
[slave3]

2、修改greenplum的配置文件(所有机器)

[[email protected] ~]$ vi /opt/greenplum-db/greenplum_path.sh
GPHOME=/opt/greenplum-db

# Replace with symlink path if it is present and correct
if [ -h ${GPHOME}/../greenplum-db ]; then
    GPHOME_BY_SYMLINK=`(cd ${GPHOME}/../greenplum-db/ && pwd -P)`
    if [ x"${GPHOME_BY_SYMLINK}" = x"${GPHOME}" ]; then
        GPHOME=`(cd ${GPHOME}/../greenplum-db/ && pwd -L)`/.
    fi
    unset GPHOME_BY_SYMLINK
fi
#setup PYTHONHOME
if [ -x $GPHOME/ext/python/bin/python ]; then
    PYTHONHOME="$GPHOME/ext/python"
fi
PYTHONPATH=$GPHOME/lib/python
PATH=$GPHOME/bin:$PATH
LD_LIBRARY_PATH=$GPHOME/lib:${LD_LIBRARY_PATH-}::/usr/local/lib
export LD_LIBRARY_PATH
OPENSSL_CONF=$GPHOME/etc/openssl.cnf
export GPHOME
export PATH
export PYTHONPATH
export PYTHONHOME
export OPENSSL_CONF

3、配置.bash_profile环境变量(所有机器)

[[email protected] ~]$ cd
[gpadmin@master ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
source /opt/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data/greenplum-db/gpdata/gpmaster/gpseg-1
export PGPORT=2345
export PGDATABASE=testDB
[gpadmin@master ~]$ source .bash_profile

4、初始化配置文件(master)

创建初始化配置文件

[[email protected] ~]$ vi /home/gpadmin/conf/gpinitsystem_config
ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=33000
declare -a DATA_DIRECTORY=(/data/greenplum-db/gpdata/gpdatap1  /data/greenplum-db/gpdata/gpdatap2)
MASTER_HOSTNAME=master
MASTER_DIRECTORY=/data/greenplum-db/gpdata/gpmaster
MASTER_PORT=2345
TRUSTED_SHELL=/usr/bin/ssh
ENCODING=UTF-8
MIRROR_PORT_BASE=43000
REPLICATION_PORT_BASE=34000
MIRROR_REPLICATION_PORT_BASE=44000
declare -a MIRROR_DATA_DIRECTORY=(/data/greenplum-db/gpdata/gpdatam1 /data/greenplum-db/gpdata/gpdatam2)
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts

5、初始化数据库(master)

[[email protected]~]$ gpinitsystem -c /home/gpadmin/conf/gpinitsystem_config -s slave3

其中sdw3是指master的standby所在的节点,我看书上和网上的一些资料都将standby放在最后一个节点,可能是约定俗成的吧。

如果上面有一些配置有问题,gpinitsystem就不能成功,日志在主节点/home/gpadmin/gpAdminLogs/的gpinitsystem_2018XXXX.log文件中。

需要注意的是如果初始化失败,一定要认真查看这个日志文件,一味重复安装没有太大意义,重要的是要找到主要原因。

6、其他操作命令(master)

安装完成以后最好重启一下集群

gpstop -M fast -a     #停止数据库

gpstart -a    #启动数据库

参考文章:

1、http://www.cnblogs.com/renlipeng/p/5685432.html

2、http://www.jpblog.cn/greenplum%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85.html

原文地址:https://www.cnblogs.com/zhang-ke/p/8718404.html

时间: 2024-10-12 09:38:12

centos7 编译安装greenplum5.7的相关文章

CentOS7 编译安装LNMP

LNMP(Linux-Nginx-Mysql-PHP),本文在CentOS7.0上编译LNMP尝尝鲜,全文基本上都是采用手动编译部署...依赖yum帮我安装了GCC和automake..写这个东西耗时有点久了...尼玛 太花时间啦,Linux运维交流群:344177552 主要软件版本: nginx-1.6.0php-5.3.5mysql-5.5.6 yum源配置(其实没什么改动) [[email protected] ~]# cat /etc/yum.repos.d/1.repo [1]nam

centos7编译安装mysql5.7.20版本

centos7编译安装mysql5.7.20版本 遇到问题: 之前想在线上搭建mysql5.7.20版本找了很多文档都觉得写得不怎么完善,很多需要注意的错误点都提及,所以只好自己写一篇了!个人觉得最主要注意的是mysql的data目录一定不能漏了权限问题,还有的经常遇到mysql.sock文件的错误就是因为编译的时候指定的目录要小心,然后启动前在my.cnf文件里面定义一下问题就解决了.这是我写的时候遇到最多的问题. 一.进入mysql官网下载(www.mysql.org)mysql源安装包:

centos7编译安装的php7怎么卸载 解决cenos 编译安装软件后怎么卸载问题

之前有个疑问  编译安装的软件 不是yum 安装 怎么卸载 遇到个问题, centos7编译安装的php7怎么卸载 解决: 关于卸载如果没有配置--prefix选项,源码包也没有提供make uninstall,则可以通过以下方式可以完整卸载: 一个临时目录重新安装一遍,如: ./configure --prefix=/tmp/to_remove && make install1然后遍历/tmp/to_remove的文件,删除对应安装位置的文件即可(因为/tmp/to_remove里的目录

CentOS7编译安装httpd-2.4.41 php7.3

CentOS7编译安装httpd-2.4.41 php7.3 安装参考环境: CentOS Linux release 7.5.1804 (Core) 一.安装依赖包 httpd安装的依赖包 # yum -y install pcre-devel # yum -y install openssl-devel # yum -y groupinstall "Development Tools" arp-util安装的依赖包 # yum install expat-devel 二.编译安装a

开发人员学Linux(6):CentOS7编译安装MySQL5.17.8多实例及主从复制

1.前言上一篇讲述了如何在CentOS7下编译安装Nginx-1.12.0并如何配置反向代理,本篇将讲述如何编译安装MySQL5.7.18并配置多实例.2.准备2.1下载MySQL5.7.18源码注意最新版本的MySQL需要Boost才能编译安装,在MySQL提供的下载中有不带boost的源码,还有带boost的源码,如果下载不带boost的源码还需要再去下载boost源码,为省事起见,建议下载带boost的源码,下载地址:https://cdn.mysql.com//Downloads/MyS

开发人员学Linux(8):CentOS7编译安装Subversion1.9.5及Apache2.4.25并集成

1.前言本篇将介绍如何编译安装SVN服务器端管理软件subverion和Web服务器Apache.本来在前面的系列文章已经讲过使用Nginx作为Web服务器的,所以我一直在找有关subverion集成nginx的资料,在此过程中找到了Nginx作者Igor Sysoev在回答别人类似问题的网址,网址是http://mailman.nginx.org/pipermail/nginx/2007-January/000504.html,不过按照Igor Sysoev的回答并没有成功,因此仍回到Apac

开发人员学Linux(7):CentOS7编译安装PHP并配置PHP-FPM

1.前言上一篇讲述了如何编译安装MySQL,虽然可以通过yum install 或者rpm来安装,但是yum install和rpm安装有一个特点,就是有些参数是别人根据大众需求定制的,如果需要进行自己的特定参数指定,这个是比较难做到的,因此有一定Linux基础的人都是编译安装或者根据公司的具体环境制作适合环境的安装包.上一篇的例子中讲述了如何编译安装和如何配置多实例,并在最后讲述了如何配置主从复制配置.以前开源开发经常将LAMP,就是Linux+Apache+MySQL+PHP,对于一些起步型

开发人员学Linux(5):CentOS7编译安装Nginx并搭建Tomcat负载均衡环境

1.前言在上一篇讲述了JMeter的使用,在本篇就可以应用得上了.本篇将讲述如何编译安装Nginx并利用前面的介绍搭建一个负载均衡测试环境.2.软件准备Nginx-1.12.0,下载地址:https://nginx.org/download/nginx-1.12.0.tar.gzTomcat8(本系列已介绍过如何下载和安装)JMeter(本系列已介绍过如何下载和使用)注:VirtualBox宿主机IP为"192.168.60.16,虚拟机IP为:192.168.60.198,虚拟机通过桥接方式接

centos7 编译安装lamp

系统:centos7 软件版本:php-7.1.0 +mysql-boost-5.7.16 + httpd-2.4.23 一.linux 系统限制配置 1.关闭系统防火墙 systemctl stop firewalld.service 关闭防火墙 systemctl disable firewalld.service  禁用防火墙 2.关闭SElinux sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config  setenfor