greenplum单机安装方法

2023-03-28 00:00:00 文件 配置 初始化 建立 链接

安装前准备:
在/etc/sysctl.conf 文件中加入有关共享内存与网络参数配置

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.conf.default.arp_filter = 1
net.ipv4.ip_local_port_range=1025 65535
net.core.netdev_max_backlog=10000
vm.overcommit_memory=2


在/etc/security/limits.conf 中加入限制参数
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072


vi /etc/hosts
127.0.0.1 mdw
127.0.0.1 sdw
127.0.0.1 localhost
192.168.1.204 sggp


例如:
[gpadmin@sgpc146 ~]$ more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost mdw sdw1
129.100.253.146 sgpc146


vi /etc/hosts
127.0.0.1 localhost loghost
10.1.18.138 mdw-ext1 #eth0 on master node. Use IP sensible for LAN
172.28.0.250 mdw-sp #iDRAC - Shared Management port on master node
172.28.4.250 mdw-cm #eth0 - Shared with management port
172.28.8.250 mdw-1 mdw #eth4 on master node
172.28.12.250 mdw-2 #eth5 on master node



172.28.0.1 sdw1-sp #iDRAC - Shared Management port on master node
172.28.4.1 sdw1-cm #eth0 - Shared with management port
172.28.8.1 sdw1-1 sdw1 #eth2 on first segment node
172.28.12.1 sdw1-2 #eth3 on first segment node

172.28.0.2 sdw2-sp #iDRAC - Shared Management port on master node
172.28.4.2 sdw2-cm #eth0 - Shared with management port
172.28.8.2 sdw2-1 sdw2 #eth2 on second data node
172.28.12.2 sdw2-2 #eth3 on second segment node




正式安装
[root@sggp tools]# /bin/bash greenplum-db-4.2.1.2-build-2-RHEL5-x86_64.bin

安装目录确认,默认是: /usr/local/greenplum-db-4.2.1.2
安装完成(至此gp的软件安装完成,下面需要进行配置及初始化)




配置:
1-创建greenplum组:
# groupadd gpadmin
2-创建greenplum用户:
# useradd -g gpadmin gpadmin
# passwd gpadmin
# New password: <gpadmin_password>
# Retype new password: <gpadmin_password>
3-改变greenplum安转目录的owner
# chown -R gpadmin /usr/local/greenplum-db
# chgrp -R gpadmin /usr/local/greenplum-db

4-配置环境变量:
将 /usr/local/greenplum-db/greenplum_path.sh中的内容加到/etc/profile里,同是追加到greenplum用户gpadmin的.bash_profile里.
以gpadmin用户身份登陆master节点,修改~/.bashrc文件,增加一行:
. /usr/local/greenplum-db-4.x.x.x/greenplum_path.sh
. /usr/local/greenplum-db-4.2.1.2/greenplum_path.sh

5-创建master和segment主机上的数据存放目录:
mkdir /home/gpadmin/masterdata
mkdir /home/gpadmin/segmentdata


创建greenplum_db像征目录(查看有没有,如果有不需要执行一下命令):
ln -s /usr/local/greenplum-db-3.2.3.0 /usr/local/greenplum-db

ln命令用来建立链接文件命令格式:ln [选项] 源文件或目录 链接名或目录
常用选项:
-s 建立符号链接
-f 强行建立链接
-i 交互式建立链接
例:要为当前目录下的file文件建立一个硬链接,名为/home/lbt/doc/file/,可用如下命令:
ln file /home/lbt/doc/file
建立名为 /home/lbt/doc/file1 的符号链接:ln -s file /home/lbt/doc/file1
# touch indsgzb.dbf
# ln -fs /dev/rora_lvctl01 control01.ctl


mkdir /data/masterdata
chown gpadmin:gpadmin /data/masterdata

mkdir /data/segmentdata
chown gpadmin:gpadmin /data/segmentdata


6-创建包含所有主机名的文件 all_hosts(seg_hosts与包括master与segment的机器名的hosts文件放在/home/gpadmin/下面)
[gpadmin@sgpc146 ~]$ more all_hosts
mdw
sdw


7-含segment 主机名的文件 seg_hosts
[gpadmin@sgpc146 ~]$ more seg_hosts
sdw


给greenplum 加管理员 (system user可选项)都是 root 下执行的
source /usr/local/greenplum-db/greenplum_path.sh
gpseginstall -f all_hosts -u gpadmin -p sgtest


现在加了 gpadmin, 登入到 gpadmin, 加一下 $GPHOME(/usr/local/greenplum-db-4.2.1.2)
export GPHOME=/usr/local/greenplum-db-4.2.1.2
source $GPHOME/greenplum_path.sh
gpcheck -f all_hosts -m mdw


还可以验证 Disk I/O 和 Memory Bandwidth
source $GPHOME/greenplum_path.sh
gpcheckperf -f seg_hosts -r ds -D -d segmentdata




初始化系统/启动/测试:
1-复制一个配置文件模板 (如果gpinitsystem_config_example不存在,则cp gpinitsystem_config gpinitsystem_config_bak备份一下)
$ cp $GPHOME/docs/cli_help/gpconfigs/gp_init_config_example /home/gpadmin/gpinitsystem_config
[root@sggp gpconfigs]# ll
total 52
-r--r--r-- 1 gpadmin gpadmin 2660 Jun 12 2012 gpinitsystem_config
-r--r--r-- 1 gpadmin gpadmin 4511 Jun 12 2012 gpinitsystem_singlenode
-r--r--r-- 1 gpadmin gpadmin 359 Jun 12 2012 hostfile_exkeys
-r--r--r-- 1 gpadmin gpadmin 96 Jun 12 2012 hostfile_gpcheck
-r--r--r-- 1 gpadmin gpadmin 119 Jun 12 2012 hostfile_gpchecknet_ic1
-r--r--r-- 1 gpadmin gpadmin 119 Jun 12 2012 hostfile_gpchecknet_ic2
-r--r--r-- 1 gpadmin gpadmin 87 Jun 12 2012 hostfile_gpcheckperf
-r--r--r-- 1 gpadmin gpadmin 255 Jun 12 2012 hostfile_gpexpand
-r--r--r-- 1 gpadmin gpadmin 237 Jun 12 2012 hostfile_gpinitsystem
-r--r--r-- 1 gpadmin gpadmin 96 Jun 12 2012 hostfile_gpssh_allhosts
-r--r--r-- 1 gpadmin gpadmin 87 Jun 12 2012 hostfile_gpssh_segonly
-r--r--r-- 1 gpadmin gpadmin 44 Jun 12 2012 hostlist_singlenode
[root@sggp gpconfigs]# pwd
/usr/local/greenplum-db-4.2.1.2/docs/cli_help/gpconfigs


2-修改配置参数 vi /home/gpadmin/gpinitsystem_config
ARRAY_NAME="EMC Greenplum DW"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/segmentdata /data/segmentdata)
MASTER_HOSTNAME=mdw
MASTER_DIRECTORY=/data/masterdata
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=256
ENCODING=UNICODE
MACHINE_LIST_FILE=/home/gpadmin/seg_hosts




ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/d1 /data/d2 /data/d3 /data/d4 )
MASTER_HOSTNAME=mdw
MASTER_DIRECTORY=/data/master
MASTER_PORT=5432
TRUSTED_SHELL=ssh
CHECK_POINT_SEGMENTS=256
ENCODING=UNICODE
MIRROR_PORT_BASE=50000
REPLICATION_PORT_BASE=41000
MIRROR_REPLICATION_PORT_BASE=51000
declare -a MIRROR_DATA_DIRECTORY=(/data/m1 /data/m2 /data/m3 /data/m4)






3-把所有主机建立信任关系
gpssh-exkeys -f /home/gpadmin/all_hosts
[root@sggp gpadmin]# gpssh-exkeys -f /home/gpadmin/all_hosts
[STEP 1 of 5] create local ID and authorize on local host
... /root/.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 mdw
... send to sdw


[STEP 4 of 5] determine common authentication file content


[STEP 5 of 5] copy authentication files to all remote hosts
... finished key exchange with mdw
... finished key exchange with sdw


[INFO] completed successfully
[root@sggp gpadmin]#


4-运行配置文件初始化greenplum数据库
$gpinitsystem -c /home/gpadmin/gpinitsystem_config
gpinitsystem -c /home/gpadmin/gpinitsystem_config -h seg_hosts
0130219:14:47:15:006465 gpinitsystem:sggp:gpadmin-[INFO]:----------------------------------------
20130219:14:47:15:006465 gpinitsystem:sggp:gpadmin-[INFO]:-Greenplum Primary Segment Configuration
20130219:14:47:15:006465 gpinitsystem:sggp:gpadmin-[INFO]:----------------------------------------
20130219:14:47:15:006465 gpinitsystem:sggp:gpadmin-[INFO]:-sdw /data/segmentdata/gpseg0 40000 2 0
20130219:14:47:16:006465 gpinitsystem:sggp:gpadmin-[INFO]:-sdw /data/segmentdata/gpseg1 40001 3 1
Continue with Greenplum creation Yy/Nn>
y
20130219:14:48:06:006465 gpinitsystem:sggp:gpadmin-[INFO]:-Building the Master instance database, please wait...
20130219:14:48:27:006465 gpinitsystem:sggp:gpadmin-[INFO]:-Starting the Master in admin mode
20130219:14:48:48:006465 gpinitsystem:sggp:gpadmin-[INFO]:-Commencing parallel build of primary segment instances


5-将MASTER_DATA_DIRECTORY加入环境中,修改gpadmin用户的.bash_profile,加入
初始化结束后,运行gpstat -s查看状态,会失败,它会提示你需要设置MASTER_DATA_DIRECTORY环境


MASTER_DATA_DIRECTORY=/data/masterdata/gpseg-1
export MASTER_DATA_DIRECTORY


export MASTER_DATA_DIRECTORY=/data/masterdata/gpseg-1


source ~/.bash_profile


gpstate -s




6-启动服务(以gpadmin的身份启动):
gpstart
psql postgres
psql sg


[gpadmin@sggp ~]$ psql postgres
psql: FATAL: System was started in master-only utility mode - only utility mode connections are allowed
[gpadmin@sggp ~]$ 是因为没有配置GPHOME


psql postgres
CREATE table test_db (id INTEGER, name text);
INSERT INTO test_db VALUES (1, 'manu');
INSERT INTO test_db VALUES (2, 'zhang');
SELECT * FROM test_db;
DROP table test_db;




7-创建一个新数据库
create database xxx;


8-创建一个角色
create role zb_src with password 'zb_src';


9-退出
\q


启停greenplum命令
gpstop -a
gpstart -a




groupadd -g 3030 gpadmin
groupadd -g 3040 gpmon


useradd -u 3030 -g gpadmin -d /home/gpadmin -s /bin/bash -m gpadmin passwd gpadmin
useradd -u 3040 -g gpmon -d /home/gpmon -s /bin/bash -m gpmon passwd gpmon


本文来源:https://blog.csdn.net/rgb_rgb/article/details/8725778

相关文章