概述
开始学习greenplum,小试了一把。
软件版本:greenplum-db-4.3.9.1-build-1-rhel5-x86_64.zip
系统版本:redhat 6.8
ps:听说5版本有bug,7版本也有问题
注意选择安装系统为:数据库服务器,文件格式为XFS
GreenPlum-db安装
一、安装环境准备(需要在每个节点上执行相应的操作)
1.1网络配置
1)修改 # vim/etc/sysconfig/network-scripts/ifcfg-eth*文件(实际网卡文件名来,目录不变)
设置好ip后重启网络服务
DEVICE="eth0"
HWADDR="08:00:27:BF:91:4F"
NM_CONTROLLED="yes"
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.2.101(实际情况来)
NETMASK=255.255.255.0(实际情况来)
GATEWAY=192.168.2.0(实际情况来)
重启网卡
# service networkrestart
2)关闭防火墙和selinux
# chkconfig iptablesoff
修改# vim /etc/selinux/config文件
SELINUX=disabled
1.2系统参数配置
1)# vim/etc/sysctl.conf
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route= 0
kernel.sysrq = 1
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.sem = 250 64000 100 512
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_syn_backlog=4096
net.core.netdev_max_backlog=10000
vm.overcommit_memory=2
2)修改文件打开数等限制
# vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
# vim/etc/security/limits.d/90-nproc.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
3)修改scheduler,设置Linux调度器规则,默认为CFQ更改为deadline
#echo deadline > /sys/block/sda/queue/scheduler
检查
# more /sys/block/sda/queue/scheduler
noop anticipatory [deadline] cfq
参考linux 内核四种算法,anticipatory 最差,很多linux版本取消了此算法。
4)编辑/boot/grub/grub.conf,修改I/O口算法
#vim /boot/grub/grub.conf
新增
elevator=deadline
检查
# more /boot/grub/grub.conf
...elevator=deadline crashkernel=auto ...
5)编辑设置预读块大小,大的预读块大小能提高查询速度
查询当前预读块大小
# /sbin/blockdev --getra/dev/sda
8192
修改为16384
# /sbin/blockdev --setra16384 /dev/sda
1.3配置host和修改主机名
1)# vim/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.4.114 mdw
192.168.4.232 sdw1
192.168.4.231 sdw2
注意,此处一定要记住规划时候所分配的主机名和IP
2)# vim/etc/sysconfig/network
NETWORKING=yes
HOSTNAME= mdw(以此类推)
1.4创建gpadmin用户并设置密码
# groupadd -g 530 gpadmin
# useradd -g 530 -u 530-m -d /home/gpadmin -s /bin/bash gpadmin
# chown -Rgpadmin:gpadmin /home/gpadmin/
# passwd gpadmin
设置完毕之后,重启系统# reboot使配置生效。
shutdown -r now
二、安装greenplum数据库
2.1安装文件准备
1)创建安装目录并将权限赋予gpadmin用户
# mkdir/home/gpadmin/greenplum(默认安装目录是在/usr/local下)
# chown -R gpadmin:gpadmin/home/gpadmin/greenplum
2.2主节点安装
切换gpadmin用户开始安装# su gpadmin
2)解压安装文件压缩包
# unzipgreenplum-db-4.3.9.1-build-1-rhel5-x86_64.zip
$./greenplum-db-4.3.9.1-build-1-rhel5-x86_64.bin
Ps: 安装目录为/home/gpadmin/greenplum(默认安装目录是在/usr/local下)
如没有执行权限,运行以下命令赋予该文件的执行权限:
$ chmod +x greenplum-db-4.3.9.1-build-1- rhel 5-x86_64.bin
按照提示安装,注意选择安装目录。安装完毕后进入安装目录,将安装后的文件打包
$ tar -cf gp4.3.9.targreenplum/
2.3创建节点配置文件
在/home/gpadmin/目录下创建文件夹conf并创建hostlist和seg_hosts两个文件
$ mkdir/home/gpadmin/conf
$ cd /home/gpadmin/conf
$ vi hostlist分行记录所有服务器名字
mdw
sdw1
sdw2
$ vi seg_hosts分行记录segment节点的服务器名字
sdw1
sdw2
2.4打通所有机器通道,通过master对其他机器进行批量操作(以下操作只需要master节点服务器,并且切换到gpadmin用户)
1)先执行$ source/home/gpadmin/greenplum-db/greenplum_path.sh
如没有执行权限,运行以下命令赋予该文件的执行权限:
$ chmod +x /home/gpadmin/greenplum-db/greenplum_path.sh
复制安装压缩包$ gpscp -f/home/gpadmin/conf/seg_hosts gp4.3.9.tar =:/home/gpadmin
打通所有机器通道$ gpssh-exkeys -f/home/gpadmin/conf/hostlist
2)批量操作$ gpssh-f /home/gpadmin/conf/seg_hosts
=> cd /home/gpadmin
=> tar -xfgp4.3.9.tar
建立软连接
=> ln -s greenplumgreenplum-db
=> ll
创建数据库数据目录(gpdata位置自定义)
$ gpssh -f/home/gpadmin/conf/hostlist
=> mkdir -p/home/gpadmin/gpdata/gpmaster
=> mkdir -p/home/gpadmin/gpdata/gpdatap1
=> mkdir -p/home/gpadmin/gpdata/gpdatap2
注释:正式环境 gpdatap建立4个,命名为gpdatap1,gpdatap2,gpdatap3,gpdatap4
=> mkdir -p/home/gpadmin/gpdata/gpdatam1
=> mkdir -p/home/gpadmin/gpdata/gpdatam2
注释:正式环境 gpdatam建立4个,命名为gpdatam1,gpdatam2,gpdatam3,gpdatam4
2.5编写环境变量脚本(gpadmin用户,所有节点)
在/home/gpadmin/.bash_profile和.bashrc文件中
vi /home/gpadmin/.bash_profile 打开.bash_profile
vi /home/gpadmin/.bashrc 打开.bashrc
分别添加以下内容
source /home/gpadmin/greenplum/greenplum_path.sh
export MASTER_DATA_DIRECTORY=/home/gpadmin/gpdata/gpmaster/gpseg-1
export PGPORT=5432
exportPGDATABASE=BIDB (此处为初始数据库名,一定要记住)
运行source .bash_profile和source.bashrc生效
三、初始化Greenplum
3.1修改初始化配置文件
1)找到数据库中自带的初始化配置模板,在gpadmin下新建一个配置文件的目录,将该模板文件复制,并对其中内容进行如下修改。
#mkdir -p/home/gpadmin/gpconfigs
# cp/home/gpadmin/greenplum-db/docs/cli_help/gpconfigs/gpinitsystem_config/home/gpadmin/gpconfigs/gpinitsystem_config
# cd /home/gpadmin/gpconfigs
# vimgpinitsystem_config (此次配置没有开启mirror配置,以下内容被注释)
# FILE NAME: gpinitsystem_config
# Configuration file needed by the gpinitsystem
################################################
#### REQUIRED PARAMETERS
################################################
#### Name of this Greenplum system enclosed in quotes.
ARRAY_NAME="EMC Greenplum DW"
#### Naming convention for utility-generated datadirectories.
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 listdictate
#### the number of primary segments that will get createdper
#### physical host (if multiple addresses for a host arelisted in
#### the hostfile, the number of segments will be spreadevenly across
#### the specified interface addresses).
declare -aDATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatap1 /home/gpadmin/gpdata/gpdatap2)#这是数据存储路径配置,如果正式环境有4个目录,空格隔开
#### OS-configured hostname or IP address of the masterhost.
MASTER_HOSTNAME=FineBI-1 #master主机名
#### File system location where the master data directory
#### will be created.
MASTER_DIRECTORY=/home/gpadmin/gpdata/gpmaster
#### Port number for the master instance.
MASTER_PORT=5432
#### Shell utility used to connect to remote hosts.
TRUSTED_SHELL=/usr/bin/ssh
#### Maximum log file segments between automatic WALcheckpoints.
CHECK_POINT_SEGMENTS=8
#### Default server-side character set encoding.
ENCODING=UNICODE
################################################
#### OPTIONAL MIRRORPARAMETERS#以下内容都是配置镜像的参数
################################################
#### 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 datadirectories
#### will be created. The number of mirror locations mustequal the
#### number of primary locations as specified in the
#### DATA_DIRECTORY parameter.
declare -aMIRROR_DATA_DIRECTORY=(/home/gpadmin/gpdata/gpdatam1 /home/gpadmin/gpdata/gpdatam2)#这是镜像路径配置,正式环境有4个目录,空格隔开
################################################
#### OTHER OPTIONAL PARAMETERS#节点配置文件路径
################################################
#### Create a database of this name after initialization.
#DATABASE_NAME=name_of_database
DATABASE_NAME=BIDB #初始化数据库名
#### Specify the location of the host address file hereinstead of
#### with the the -h option of gpinitsystem.
#MACHINE_LIST_FILE=/home/gpadmin/gpconfigs/hostfile_gpinitsystem
MACHINE_LIST_FILE=/home/gpadmin/conf/seg_hosts
#(前面的初始数据库名)
3.2初始化Greenplum
$ gpinitsystem -cgpinitsystem_config -h /home/gpadmin/conf/seg_hosts(如果所有机器节点部署seg用hostlist)
四、其他有关设置
4.1允许其他机器对于数据库的访问,调整连接控制参数
$ vim/home/gpadmin/gpdata/gpmaster/gpseg-1/pg_hba.conf添加需要访问的机器的ip
#表示一个主机
Host all gpadmin 172.20.143.89/32 trust
#表示一个小子网(172.20.143.0-172.20.143.255)
Host all gpadmin 172.20.143.0/24 trust
#表示一个大子网(10.6.0.0-10.6.255.255)
Host all gpadmin 10.6.0.0/16 trust
#代表所有IPv4地址,一般使用这个
Host all gpadmin 0.0.0.0/0 trust
#代表所有IPv6地址
Host all gpadmin ::/0 trust
执行 $ gpstop -u 生效
最后
以上就是闪闪冷风为你收集整理的GreenPlum部署的全部内容,希望文章能够帮你解决GreenPlum部署所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复