hadoop高可用集群集成hive
hive和hadoop的关系
从上图可以看出实际上外界是通过thrift server这个节点和hadoop的hdfs以及rm进行交互的,中间为driver
因此当我修改完hadoop集群为高可用的时候,hive也需要重新配置环境
以下是我hive的全新配置
<configuration>
<!-- Hive 元数据存储配置 -->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://billsaifu:3306/metastore?useSSL=false</value>
<description>JDBC连接元数据存储的URL</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>JDBC连接驱动程序的类名</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>连接元数据存储的用户名</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>连接元数据存储的密码</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>hive workspace in hdfs</description>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>HiveServer2 使用的 Thrift 服务端口号</description>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>billsaifu</value>
<description>HiveServer2 绑定的主机名或 IP 地址</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://billsaifu:9083,thrift://hadoop2:9083</value>
</property>
<property>
<name>hive.server2.webui.enabled</name>
<value>true</value>
</property>
<property>
<name>hive.server2.webui.host</name>
<value>billsaifu</value>
</property>
<property>
<name>hive.server2.webui.port</name>
<value>10002</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
<description>Display the current database name in the Hive CLI prompt</description>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.zookeeper.quorum</name>
<value>billsaifu,hadoop1,hadoop2</value>
</property>
<property>
<name>hive.zookeeper.client.port</name>
<value>2181</value>
</property>
</configuration>
修改了hive.metastore.uris为两个高可用中两个namenode的主机
metastore也需要重新初始化
首先连接到原来的mysql数据库
mysql -u your_username -p
删除metastore下的所有表
drop database metastore
create database metastore
初始化元数据
schematool -dbType mysql -initSchema --verbose
成功之后,开启hive,此时hive就可以自动选中activate的namenode进行数据的储存了