greenplum数据库centos7安装

本文详细介绍Greenplum数据库集群的部署过程,包括服务器配置、依赖包安装、greenplum软件安装、初始化及远程访问配置等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、修改服务器配置(所有服务器)

1、关闭防火墙

systemctl disable firewalld
systemctl stop firewalld

2、修改host文件  /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.9 master1
192.168.1.123 slave11 standby1
192.168.1.182 slave12

3、修改修改/etc/sysconfig/network

NETWORKING=yes

4、修改内核文件/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

配置生效

sysctl -p

5、修改文件打开权限/etc/security/limits.conf

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

6、修改文件/etc/selinux/config

SELINUX=disabled
SELINUXTYPE=targeted

7、修改文件 /etc/rc.local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

8、修改读块大小

/usr/sbin/blockdev --setra 16384 /dev/sda #此处sda磁盘要改成本机磁盘路径

9、修改 io scheduler为deadline

echo deadline > /sys/block/sda/queue/scheduler #此处sda磁盘要改成本机磁盘路径
chmod u+x /etc/rc.d/rc.local

10、修改/etc/ld.so.conf文件

include ld.so.conf.d/*.conf
/usr/local/lib
/usr/local/lib64

配置生效

ldconfig

11、安装配置时钟同步

安装

yum install ntp
systemctl start ntpd
systemctl enable ntpd

修改master服务器

server 192.168.1.1

修改standby服务器

server master1 prefer (替换成hosts文件配置的主机名)
server 192.168.1.1

修改segment服务器

server master1 prefer (替换成hosts文件配置的主机名)
server standby1 (替换成hosts文件配置的备份主机名)

12、创建用户名和用户组

groupadd -g 530 gpadmin
useradd -g 530 -u530 -m -d /home/gpadmin -s /bin/bash gpadmin
passwd gpadmin

二、安装依赖包(所有服务器)

1、更新yum库

yum update

2、安装依赖包

# 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



# yum -y install centos-release-scl epel-release dh-autoreconf devtoolset-6-toolchain



# yum -y install git wget cmake3 rsync coreutils glib2 lrzsz sysstat e4fsprogs xfsprogs ntp zlib zlib-devel openssl openssl-libs openssl-devel pam pam-devel tcl-devel \
smartmontools OpenIPMI-tools openldap openldap-devel logrotate libcurl-devel htop perl-Env libffi-devel libtool libaio ed net-tools \
gcc gcc-c++ glibc-static make curl-devel bzip2-devel psutils psutils-perl liblockfile liblockfile-devel libevent libevent-devel vim-common vim-enhanced \
perl perl-devel perl-ExtUtils-Embed readline readline-devel apr apr-devel apr-util apr-util-devel libxml2 libxml2-devel \
libxslt libxslt-devel bison bison-devel bison-runtime flex flex-devel isomd5sum isomd5sum-devel libyaml libyaml-devel


# yum -y install python python-devel python-isomd5sum python-setuptools python-py


# yum -y install python-lockfile


# yum -y install python-paramiko

3、安装python所需包

# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

# python get-pip.py

# pip install setuptools

# pip install --upgrade setuptools

# pip install epydoc psi psutil lockfile paramiko conan 
#安装conan的时候遇到 Cannot uninstall 'pyparsing'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. 
#解决办法是用yum remove pyparsing
#遇到Cannot uninstall 'enum34'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall
#解决办法是yum remove python-enum34
#解决之后,重新执行该命令。

4、安装cmake

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

5、安装re2c

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

re2c 1.0.1

6、安装Ninja

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

7、安装gp-xerces

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

8、安装gporca

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

9、安装libsigar

# git clone https://github.com/boundary/sigar
# cd sigar
# mkdir build && cd build && cmake .. && make && make install

三、主服务器安装greenplum

1、给gpadmin创建相关目录并授权

# mkdir -p /usr/local/greenplum-db #用于存放greenplum程序
# chown -R gpadmin:gpadmin /usr/local/greenplum-db
# mkdir -p /data1/gpdata/master #用于存放数据
# chown gpadmin:gpadmin /data1/gpdata/master

2、下载greenplim5.7源码并安装

切换到goadmin用户

上传源码包到root目录

cp ./5.7.0.zip /tmp
cd /tmp
unzip ./5.7.0.zip
cd /tmp/gpdb-5.7.0
./configure --prefix=/usr/local/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
make -j 32
make install

3、设置gpadmin账户环境并使之生效

修改 /home/gpadmin/.bashrc文件

source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data1/gpdata/master/gpseg-1

修改 /home/gpadmin/.bash_profile文件

source /usr/local/greenplum-db/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/data1/gpdata/master/gpseg-1

使之生效

source ~/.bashrc
source ~/.bash_profile

4、准备服务器文件

新建文件 /usr/local/greenplum-db/all_host

写入所有服务器名,和hosts配置相同

master1
slave11
slave12

新建文件 /usr/local/greenplum-db/all_segment

写入所有segment服务器名

slave11
slave12

退出gpadmin账户

四、为其他服务器安装greenplum

1、建立服务器间信任

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

2、交换key

gpssh-exkeys -f /usr/local/greenplum-db/all_host 
#这一步会提示需要输入root密码。
#如果遇到AttributeError: 'module' object has no attribute 'GSSException' 
#解决办法:pip uninstall gssapi

3、为其他服务器安装greenplum

在主服务器上执行

gpseginstall -f /usr/local/greenplum-db/all_segment -u gpadmin -p 123456
gpssh -f $GPHOME/all_host -e ls -l $GPHOME #检查安装情况

4、为其他服务器创建存储目录

source /usr/local/greenplum-db/greenplum_path.sh
# gpssh -f /usr/local/greenplum-db/all_host -e 'mkdir -p /data1/gpdata/primary'
# gpssh -f /usr/local/greenplum-db/all_host -e 'chown gpadmin:gpadmin /data1/gpdata/primary'
# gpssh -f /usr/local/greenplum-db/all_segment -e 'mkdir -p /data1/gpdata/mirror'
# gpssh -f /usr/local/greenplum-db/all_segment -e 'chown gpadmin:gpadmin /data1/gpdata/mirror'

5、修改服务器配置文件

复制配置文件

cp /usr/local/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config /usr/local/greenplum-db/

修改文件权限

chmod 775 /usr/local/greenplum-db/gpinitsystem_config

编辑文件 /usr/local/greenplum-db/gpinitsystem_config

# FILE NAME: gpinitsystem_config



# Configuration file needed by the gpinitsystem



################################################

#### REQUIRED PARAMETERS

################################################



#### Name of this Greenplum system enclosed in quotes.

ARRAY_NAME="Greenplum Data Platform"



#### Naming convention for utility-generated data directories.

SEG_PREFIX=gpseg



#### Base number by which primary segment port numbers

#### are calculated.

PORT_BASE=40000



#### File system location(s) where primary segment data directories

#### will be created. The number of locations in the list dictate

#### the number of primary segments that will get created per

#### physical host (if multiple addresses for a host are listed in

#### the hostfile, the number of segments will be spread evenly across

#### the specified interface addresses).

#declare -a DATA_DIRECTORY=(/data1/primary /data1/primary /data1/primary /data2/primary /data2/primary /data2/primary)

declare -a DATA_DIRECTORY=(/data1/gpdata/primary /data1/gpdata/primary)



#### OS-configured hostname or IP address of the master host.

MASTER_HOSTNAME=master1 #注意修改主机名



#### File system location where the master data directory

#### will be created.

MASTER_DIRECTORY=/data1/gpdata/master



#### Port number for the master instance.

MASTER_PORT=5432



#### Shell utility used to connect to remote hosts.

TRUSTED_SHELL=ssh



#### Maximum log file segments between automatic WAL checkpoints.

CHECK_POINT_SEGMENTS=8



#### Default server-side character set encoding.

ENCODING=UNICODE



################################################

#### OPTIONAL MIRROR PARAMETERS

################################################



#### Base number by which mirror segment port numbers

#### are calculated.

#MIRROR_PORT_BASE=50000



#### Base number by which primary file replication port

#### numbers are calculated.

#REPLICATION_PORT_BASE=41000



#### Base number by which mirror file replication port

#### numbers are calculated.

#MIRROR_REPLICATION_PORT_BASE=51000



#### 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.

#declare -a MIRROR_DATA_DIRECTORY=(/data1/mirror /data1/mirror /data1/mirror /data2/mirror /data2/mirror /data2/mirror)



################################################

#### OTHER OPTIONAL PARAMETERS

################################################



#### Create a database of this name after initialization.

#DATABASE_NAME=name_of_database

DATABASE_NAME=test_init_db



#### 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

6、初始化greenplum

切换为gpadmin账户

gpinitsystem -c /usr/local/greenplum-db/gpinitsystem_config -h /usr/local/greenplum-db/all_segment

###这一步遇到的问题最多

1、确保所有的依赖包都安装正确

2、确定配置文件无误

3、如果报错 unknown host gpdbseg script exiting! ,修改all_segment文件,把主机名修改为ip

4、如果报错 -gpstop failed. (reason='database does not contain gp_fault_strategy entry') exiting...配置过程中出现问题重新安装

7、开启远程访问

修改文件

/data1/gpdata/master/gpseg-1/pg_hba.conf

最后追加要访问的客户端ip

host all gpadmin 192.168.1.55/28 trust

重启生效

gpstop -u

 


安装包汇总

链接:百度网盘地址

提取码:5pfk

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值