Post

Ansible install Greenplum

greenplum 官方提供安装工具,只需要先部署 master 节点就可以通过 gpseginstall 命令分发到各个 segment 节点,但是各个节点的系统环境参数调优工作需要提前处理,因此使用 ansible 提前对各个节点进行预处理。

节点说明

IPhostnamerole数据盘
192.168.1.213mdwmastervdb
192.168.1.223smdwstandby mastervdb
192.168.1.233sdw1segment1vdb
192.168.1.204localhostdns, ntp 

ansible配置

inventory 配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[ntp]
mdw
smdw
sdw1

[dns]
mdw
smdw
sdw1

[greenplum_master]
mdw

[greenplum_standby]
smdw

[greenplum_segments]
sdw1

[greenplums]
mdw
smdw
sdw1

site.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- name: configure local DNS server
  hosts: dns
  remote_user: root
  roles:
    - {role: dns, dns_nameservers:['192.168.1.204']}
  tags:
    - dns
    
- name: deploy greenplum
  hosts: greenplums                                                        
  remote_user: root
  roles:
    - greenplum
  tags:
    - greenplum 

dnsmasq.conf

1
2
3
4
address=/mdw/192.168.1.213
address=/smdw/192.168.1.223
address=/sdw1/192.168.1.233
address=/sdw2/192.168.1.243

执行 ansible-playbook:

1
2
3
# git clone http://git.jfbrother.com/zhengtianbao/jfbigdata-ansible.git jfbigdata-ansible
# cd jfbigdata-ansible
# ansible-playbook -t ntp,dns,greenplum -i inventory site.yml 

至此 ansible 预部署完毕。

greenplum master节点操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 添加互信root密码
[root@mdw ~]# gpssh-exkeys -f /home/gpadmin/all_nodes
# 测试是否添加成功
[root@mdw ~]# gpssh -f /home/gpadmin/all_nodes -e "ls -l"
# 安装gpdb到all_nodes
[root@mdw ~]# gpseginstall -f /home/gpadmin/all_nodes -u gpadmin -p 123456
# 切换到gpadmin用户
[root@mdw ~]# su - gpadmin
[gpadmin@mdw ~]$ gpinitsystem -c /home/gpadmin/gpinitsystem_config -s smdw
# 添加访问权限
[gpadmin@mdw ~]$ echo "host     all         gpadmin         0.0.0.0/0       md5" >> /data1/gpmaster/gpseg-1/pg_hba.conf
# 同步pg_hba.conf到smdw standby 节点
[gpadmin@mdw ~]$ gpscp -h smdw -v $MASTER_DATA_DIRECTORY/pg_hba.conf =:$MASTER_DATA_DIRECTORY/
# 重新加载gpdb配置文件
[gpadmin@mdw ~]$ gpstop -u
# 查看集群状态
[gpadmin@mdw ~]$ gpstate -s
# 设置gpadmin远程访问密码
[gpadmin@mdw ~]$ psql postgres gpadmin
psql (8.3.23)
Type "help" for help.

postgres=# alter user gpadmin encrypted password 'gpadmin';
ALTER ROLE
postgres=# \q

至此,greenplum集群搭建完毕。

集群运行中增加segment节点

参见下文:

greenplum 扩容

This post is licensed under CC BY 4.0 by the author.