Hive 部署
安装 mysql
在 node1 安装 mysql
yum install mysql-server
service mysqld start
修改权限
允许远程登陆。
mysql
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;
delete from user where host != '%';
flush privileges;
安装 hive
单用户模式
安装 hive(node2)
配置环境变量
# hive
export HIVE_HOME=/home/hdfs/env/apache-hive-2.3.8-bin
export PATH=${HIVE_HOME}/bin:$PATH
配置文件
hive-site.xml
mv hive-default.xml.template hive-site.xml
vim hive-site.xml
删除原有配置(vi编译器模式删除):.,$-1d
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123</value>
</property>
</configuration>
将 mysql 驱动包 放入 lib 目录中
运行 hive
hive
测试
create table test(id int);
insert into test value(1);
select * from test;
多用户模式
将 node2 的 hive 拷贝到 node3、node4
配置 node3、node4 的环境变量
# hive
export HIVE_HOME=/home/hdfs/env/apache-hive-2.3.8-bin
export PATH=${HIVE_HOME}/bin:$PATH
node3 配置文件修改
hive-site.xml
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://node1:3306/hive_remote?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123</value>
</property>
</configuration>
node4 配置文件修改
hive-site.xml
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive_remote/warehouse</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://node3:9083</value>
</property>
</configuration>
启动
node3
schematool --dbType mysql --initSchema
hive --service metastore
node4
hive
测试
create table test(id int, age int);
insert into test values(1, 2);
select * from test;