远程模式分为客户端与服务端两个部分,服务端的配置与本地模式相同,客户端需要单独配置
这里将centos01
节点作为Hive的服务端,centos02
节点作为Hive的客户端,在本地模式的基础上继续进行远程模式的配置
客户端配置Hive
在centos01
节点中执行以下命令,将Hive安装文件复制到centos02
节点:
scp -r /opt/modules/apache-hive-2.3.8-bin/ hadoop@centos02:/opt/modules/
修改centos02
节点的hive-site.xml
配置文件:
<configuration>
<!--hive数据库在HDFS中的存放地址-->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<!--是否启用本地服务器连接hive,false为非本地模式,即远程模式-->
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<!--hive服务端Metastore Server连接地址,默认监听端口9083-->
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.213.128:9083</value>
</property>
<!--在hive提示符中包含当前数据库-->
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
<!--在查询输出中打印列的名称-->
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
</configuration>
启动Metastore Server
在centos01
执行以下命令,启动Metastore Server并使其在后台运行:
hive --service metastore &
此时通过jps命令查看进程,会发现多了一个名为“RunJar”的进程,它就是Metastore Server的独立进程:
此时再在centos01
中启动Hive CLI,则会再次产生一个“RunJar”进程,该进程即为Hive CLI的服务进程:
测试Hive远程访问
启动YARN(HA)
start-yarn.sh
在centos01
和centos02
两个节点中分别启动Hive CLI
在centos01
中创建表student(默认建在default数据库中)
create table student(id INT,name STRING);
由图看出,在Hive客户端中成功查询到了服务端创建的表student,说明Hive远程模式配置成功