hive官网:hive.apache.org
1.在官网上下载安装包如图:
然后上传到Linux一个目录下(用第三方软件)
#上传/software/下,解压
tar -zxvf ./apache-hive-3.0.0-bin.tar.gz -C /software/
rm -rf ./apache-hive-3.0.0-bin.tar.gz
#创建Hive软连接
ln -sf ./apache-hive-3.0.0-bin/ hive
#发送到客户端节点,在客户端中也创建软连接
scp -r ./apache-hive-3.0.0-bin/ c7node3:`pwd`
【在客户端中/software/下】ln -sf ./apache-hive-3.0.0-bin/ hive
配置Hive的环境变量:
#分别在两台节点中配置Hive的环境变量
vim /etc/profile
export HIVE_HOME=/software/hive
export PATH=$PATH:$HIVE_HOME/bin
#每台节点中使配置生效:
source /etc/profile
在hive服务器节点中创建/software/hive/conf/hive-site.xml,写入:
#创建hive-site.xml
cp ./hive-default.xml.template hive-site.xml
#配置
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://c7node2: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>123456</value>
</property>
</configuration>
在hive客户节点中创建/software/hive/conf/hive-site.xml,写入:
#创建hive-site.xml
cp ./hive-default.xml.template hive-site.xml
#配置
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://c7node1:9083</value>
</property>
</configuration>
在hive服务器节点中初始化hive
#需要将mysql-connector-java-8.0.12.jar 包上传到c7node1节点的/software/hive/lib下
#初始化hive,hive2.x版本后都需要初始化
schematool -dbType mysql -initSchema
#在c7node1节点中启动hive 测试
hive
#创建表test
create table if not exists test (name string comment ‘String Column’,age int comment ‘Integer Column’) row format delimited fields terminated by ‘\t’;
#插入一条数据
insert into test values (“zhangsan”,18);
#查询
select * from test;
问题:启动hive之后,一大串的警告:Establishing SSL connection without server’s identity verification is not recommended… …
这是由于MySQL库的原因,解决:使用JDBC连接MySQL服务器时设置useSSL参数:设置useSSL=false即可。
这里注意,一般在连接数据库路径后面加上&useSSL=false即可:
jdbc:mysql://c7node2:3306/hive?createDatabaseIfNotExist=true&useSSL=false
但是在hive中 & 符号使用 & 来表示,即在hive-site.xml中修改配置即可
在客户端使用Hive:
#需要在服务端启动Metastore 服务,在c7node1节点中:
hive --service metastore &
#在c7node3节点中使用hive,查询到的表和c7node1中一样:
hive
注意:在Hive服务端安装路径下的lib下要放有连接Mysql的包:mysql-connector-java-8.0.12.jar