Zhengtianbao's Home Page

Ansible install Greenplum

License: CC BY-SA 4.0

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

节点说明

IP hostname role 数据盘
192.168.1.213 mdw master vdb
192.168.1.223 smdw standby master vdb
192.168.1.233 sdw1 segment1 vdb
192.168.1.204 localhost dns, ntp  

ansible配置

inventory 配置文件

[ntp]
mdw
smdw
sdw1

[dns]
mdw
smdw
sdw1

[greenplum_master]
mdw

[greenplum_standby]
smdw

[greenplum_segments]
sdw1

[greenplums]
mdw
smdw
sdw1

site.yml

- 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

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

# 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节点操作

# 添加互信root密码
[[email protected] ~]# gpssh-exkeys -f /home/gpadmin/all_nodes
# 测试是否添加成功
[[email protected] ~]# gpssh -f /home/gpadmin/all_nodes -e "ls -l"
# 安装gpdb到all_nodes
[[email protected] ~]# gpseginstall -f /home/gpadmin/all_nodes -u gpadmin -p 123456
# 切换到gpadmin用户
[[email protected] ~]# su - gpadmin
[[email protected] ~]$ gpinitsystem -c /home/gpadmin/gpinitsystem_config -s smdw
# 添加访问权限
[[email protected] ~]$ echo "host     all         gpadmin         0.0.0.0/0       md5" >> /data1/gpmaster/gpseg-1/pg_hba.conf
# 同步pg_hba.conf到smdw standby 节点
[[email protected] ~]$ gpscp -h smdw -v $MASTER_DATA_DIRECTORY/pg_hba.conf =:$MASTER_DATA_DIRECTORY/
# 重新加载gpdb配置文件
[[email protected] ~]$ gpstop -u
# 查看集群状态
[[email protected] ~]$ gpstate -s
# 设置gpadmin远程访问密码
[[email protected] ~]$ 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扩容