零经验Greenplum简易安装
公司没通知我参加Greenplum培训前,我压根就不知道这是个神马东东,后来才知道是个数据库,我算是彻底孤陋寡闻凹凸了。本来培训培训时间是周四周五两天,结果周三上线熬了一通宵,回家洗了个澡拿了几件衣服就和同事打飞的去帝都参加培训去了,所以说搞通信支撑这行真是不要命。
修改配置
重启服务,并关闭防火墙(system->Administration->Security
Level and Firewall,把ftp,telnet选上)
准备好后,开始安装greenplum
周四上午的内容是简介和安装,老师讲的时候我还在高空中补觉了,等我们赶到培训教室时,就剩下尾巴了。中午的时候拷了老师的资料,后面的课基本上都是看大屏幕听个大概,硬撑着没睡着,看来咱还年轻,禁得熬。
回来后看资料慢慢折腾,总算是安装成功了。为啥说是零经验了,因为Greenplum是在VM上的Linux上安装,都不太熟悉,中间碰到好多问题都折腾了好久。
安装VM和Linux
安装完后安装telnet-server,这样就可以用SecureCRT访问了,主机IP可以通过ifconfig获取。
rpm -ivh xinetd-2.3.14-10.el5.i386.rpm
rpm -ivh telnet-server-0.17-39.el5.i386.rpm
rpm -ivh telnet-server-0.17-39.el5.i386.rpm
vi /etc/xinetd.d/telnet
service telnet {
disable
= yes
flags
= REUSE
socket_type
= stream
wait =
no
user =
root
server
= /usr/sbin/in.telnetd
log_on_failure
+= USERID
}
service telnet {
}
service xinetd restart
修改系统配置。
增加用户组和用户
增加网络配置 修改主机名
用一个网卡绑定多个ip地址,模拟多个节点,在/etc/sysconfig/network-scripts下新增ifcfg-eth0:0 ifcfg-eth0:1 ifcfg-eth0:2 ifcfg-eth0:3文件,内容如下。这里指配置了2个节点的ip,因为我配置4个节点时,后面操作就报“Cannot
allocate memory”了,VM调整到2M也一样。
修改hosts文件,这里要和节点的ip保持一致。
安装greenplum软件
vi /etc/sysctl.conf
#greenplum
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
kernel.sem = 250 64000 100 512
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_syn_backlog=4096
net.core.netdev_max_backlog=10000
vm.overcommit_memory=2
#greenplum
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
kernel.sem = 250 64000 100 512
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_max_syn_backlog=4096
net.core.netdev_max_backlog=10000
vm.overcommit_memory=2
vi /etc/security/limits.conf
#greenplum
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
#greenplum
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 131072
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
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
vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
#HOSTNAME=localhost.localdomain
#greenplum
HOSTNAME=mdw
NETWORKING=yes
NETWORKING_IPV6=no
#HOSTNAME=localhost.localdomain
#greenplum
HOSTNAME=mdw
#ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.0.254
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.253
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:2
DEVICE=eth0:2
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:3
DEVICE=eth0:3
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.0.254
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.253
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:2
DEVICE=eth0:2
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
#ifcfg-eth0:3
DEVICE=eth0:3
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
vi /etc/hosts
#greenplum
127.0.0.1 localhost
10.x.x.x mdw-ext
10.y.y.y smdw-ext
192.168.0.254 mdw
192.168.0.253 smdw
192.168.0.1 sdw1
192.168.0.2 sdw2
#greenplum
127.0.0.1 localhost
10.x.x.x mdw-ext
10.y.y.y smdw-ext
192.168.0.254 mdw
192.168.0.253 smdw
192.168.0.1 sdw1
192.168.0.2 sdw2
在mdw节点上,将greenplum-db-4.2.2.0-build-5-RHEL5-x86_64.zip
解开,以root用户执行得到的.bin文件。按照提示进行安装。
准备allnodes.txt文件
创建目录,用于存放数据库文件
修改gpadmin用户.bashrc文件
Segment 节点上的安装
数据库初始化
unzip greenplum-db-4.2.2.0-build-6-RHEL5-i386.zip
./greenplum-db-4.2.2.0-build-6-RHEL5-i386.bin
./greenplum-db-4.2.2.0-build-6-RHEL5-i386.bin
sdw1
sdw2
smdw
sdw2
smdw
Master节点上的安装和准备工作
以root身份,执行以下命令
. /usr/local/greenplum-db-4.2.2.0/greenplum_path.sh
gpssh-exkeys -f allnodes.txt
gpssh-exkeys -f allnodes.txt
mkdir /data/
chown gpadmin:gpadmin /data
mkdir /data/master
chown gpadmin:gpadmin /data/master
chown gpadmin:gpadmin /data
mkdir /data/master
chown gpadmin:gpadmin /data/master
[gpadmin@mdw ~]$ vi .bashrc
#greenplum
. /usr/local/greenplum-db-4.2.2.0/greenplum_path.sh
#greenplum
. /usr/local/greenplum-db-4.2.2.0/greenplum_path.sh
. /usr/local/greenplum-db-4.2.2.0/greenplum_path.sh
gpseginstall -f allnodes.txt
gpseginstall -f allnodes.txt
. /usr/local/greenplum-db-4.2.2.0/greenplum_path.sh
gpssh -f nodes.txt mkdir /data/d1 /data/d2
gpssh -f nodes.txt mkdir /data/m1 /data/m2
gpssh -f nodes.txt chown gpadmin.gpadmin /data/d1 /data/d2
gpssh -f nodes.txt chown gpadmin.gpadmin /data/m1 /data/m2
gpssh -f nodes.txt mkdir /data/d1 /data/d2
gpssh -f nodes.txt mkdir /data/m1 /data/m2
gpssh -f nodes.txt chown gpadmin.gpadmin /data/d1 /data/d2
gpssh -f nodes.txt chown gpadmin.gpadmin /data/m1 /data/m2
创建gpinitsystem_config文件
创建节点描述文件 nodes.txt
执行命令
修改gpadmin用户.bashrc文件
调整连接控制参数
启停greenplum命令
用psql尝试连接,参考数据库情况
vi gpinitsystem_config
ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/d1 /data/d2)
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)
ARRAY_NAME="Greenplum"
SEG_PREFIX=gpseg
PORT_BASE=40000
declare -a DATA_DIRECTORY=(/data/d1 /data/d2)
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)
vi nodes.txt
sdw1
sdw2
sdw1
sdw2
gpinitsystem -c gpinitsystem_config -h nodes.txt
vi .bashrc
#greenplum
export gnbMASTER_DATA_DIRECTORY=/data/master/gpseg-1
#greenplum
export gnbMASTER_DATA_DIRECTORY=/data/master/gpseg-1
vi $MASTER_DATA_DIRECTORY/pg_hba.conf
host all all 0/0 md5
host all all 0/0 md5
gpstop -a
gpstart -a
gpstart -a
[root@mdw gp]# su - gpadmin
[gpadmin@mdw ~]$ psql -d postgres
psql (8.2.15)
Type "help" for help.
postgres=# select datname,datdba,encoding,datacl from pg_database;
datname | datdba | encoding | datacl
-----------+--------+----------+----------------------------------
postgres | 10 | 6 |
template1 | 10 | 6 | {=c/gpadmin,gpadmin=CTc/gpadmin}
template0 | 10 | 6 | {=c/gpadmin,gpadmin=CTc/gpadmin}
(3 rows)
[gpadmin@mdw ~]$ psql -d postgres
psql (8.2.15)
Type "help" for help.
postgres=# select datname,datdba,encoding,datacl from pg_database;
datname | datdba | encoding | datacl
-----------+--------+----------+----------------------------------
postgres | 10 | 6 |
template1 | 10 | 6 | {=c/gpadmin,gpadmin=CTc/gpadmin}
template0 | 10 | 6 | {=c/gpadmin,gpadmin=CTc/gpadmin}
(3 rows)