CDH实操--hive高可用
前言
在CDH中,hive metastore、hiveserver2若角色单实例部署,或者部署多个实例但是连接配置任选其一的话,均存在单点问题,一旦实例故障就会影响业务稳定;这时我们就好考虑高可用部署:hive metastore较简单,一般部署2个实例即可;hiveserver2的高可用,有多种方法,这里介绍了zk以及haproxy两种实现方式。
1、Hive配置调整(metastore高可用配置)
2、配置Hive-site.xml文件(页面配置hiveserver2高可用)
修改完成后重启两个过期事例
3、验证
3.1、进入zk,可以看到对于的叶子节点上有hiveserver2的高可用配置,如下:
3.2、hiveserver2链接方式通过zk连接:
3.3、hivemetastore的高可用(重启后可以看到配置里有多个url,默认使用第一个):
4、配置haproxy的高可用
安装:yum -y install haproxy
[root@cdh02 haproxy]# cat haproxy.cfg #--------------------------------------------------------------------- # Example configuration for a possible web application. See the # full configuration options online. # # http://haproxy.1wt.eu/download/1.4/doc/configuration.txt # #--------------------------------------------------------------------- #--------------------------------------------------------------------- # Global settings #--------------------------------------------------------------------- global # to have these messages end up in /var/log/haproxy.log you will # need to: # # 1) configure syslog to accept network log events. This is done # by adding the '-r' option to the SYSLOGD_OPTIONS in # /etc/sysconfig/syslog # # 2) configure local2 events to go to the /var/log/haproxy.log # file. A line like the following can be added to # /etc/sysconfig/syslog # # local2.* /var/log/haproxy.log # log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon # turn on stats unix socket stats socket /var/lib/haproxy/stats #--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults mode http log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 #-------------------------------------------------------------------------- # 定义管理界面 #-------------------------------------------------------------------------- listen stats :1080 balance stats enable stats uri /stats stats refresh 30s stats auth admin:admin #-------------------------------------------------------------------------- # 代理配置 #-------------------------------------------------------------------------- listen jdbchive :25005 timeout connect 10s #连接超时时间,重要,hive查询数据能返回结果的保证 balance leastconn option tcplog timeout client 2h #同上 timeout server 2h #同上 mode tcp server hiveServer1 cdh01:10000 check server hiveServer2 cdh03:10000 check
启动haproxy
systemctl start haproxy
systemctl enable haproxy
cdh上的配置:
验证页面: