1. 部署MySQL及创建hive用户(服务器已经装好mysql)
mysql> grant all privileges on *.* to hive@'%' identified by 'hadoop';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
2. 配置
hive配置官方文档
hive-site.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://hadoop000:3306/hadoop_hive?createDatabaseIfNotExist=true&useSSL=false</value>
<description>the URL of the MySQL database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>hadoop000</value>
</property>
</configuration>
core-site.xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://hadoop000:8020</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/app/tmp</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.hadoop.groups</name>
<value>*</value>
</property>
</configuration>
3. 启动metastore + hiveserver2服务(注意:环境变量已经配置好)
[hadoop@hadoop000 ~]$ nohup hive --service metastore &
[hadoop@hadoop000 ~]$ nohup hive --service hiveserver2 &
4. 测试hiveserver2服务(注意:需要进入到hive/bin 目录执行beeline)
[hadoop@hadoop000 hive]$ cd bin/
[hadoop@hadoop000 bin]$ ./beeline
Beeline version 1.1.0-cdh5.7.0 by Apache Hive
5. beeline 连接
beeline>!connect jdbc:hive2://hadoop000:10000/default
scan complete in 6ms
Connecting to jdbc:hive2://hadoop000:10000/default
Enter username for jdbc:hive2://hadoop000:10000/default: hadoop #输入hiveserver2进程启动的用户名称
Enter password for jdbc:hive2://hadoop000:10000/default: 无需输入密码
Connected to: Apache Hive (version 1.1.0-cdh5.7.0)
Driver: Hive JDBC (version 1.1.0-cdh5.7.0)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://hadoop000:10000/default> show databases;
beeline客服端工具可以用DBeaver工具,连接注意
- 驱动设置需要用服务器上的jar不要自带的(hadoop-common.jar;hive-jdbc-standalone.jar)
- 用户名称输入hiveserver2进程启动的用户名称