CentOS7下Hive的安装配置

2022-12-01 08:56:12 浏览数 (1)

0、安装前提

  • 安装配置jdk与hadoop
  • 安装配置好mysql

1、下载上传

  • 下载hive,地址:http://mirror.bit.edu.cn/apache/hive/
  • 上传到指定位置scp apache-hive-3.1.2-bin.tar.gz root@Carlota1:/usr/local/apps

2、解压安装

  • tar -zxvf apache-hive-3.1.2-bin.tar.gz
  • mv apache-hive-3.1.2-bin hive-3.1.2

3、修改环境变量/etc/profile:

  • vi /etc/profile
代码语言:javascript复制
#hive
export HIVE_HOME=/usr/local/apps/hive-3.1.2
export PATH=$PATH:$HIVE_HOME/bin
export HIVE_CONF_DIR=/usr/local/apps/hive-3.1.2/conf
  • sources /etc/profile

4、查看版本,验证安装成功

  • hive --version

5、配置

  • cd /usr/local/apps/hive-3.1.2/conf
  • vim hive-site.xml 添加以下内容
代码语言:javascript复制
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://Carlota1:3306/hive</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>
    <property>
        <name>hive.metastore.schema.verification</name>
        <value>false</value>
    </property>
</configuration>

6、驱动拷贝

  • 在官网下载mysql-connector-java-5.1.49.jar
  • 复制Mysql的程序驱动mysql-connector-java-5.1.49.jar到hive/lib下

7、创建Mysql下的hive数据库

  • create database hive;
代码语言:javascript复制
mysql> create database hive;
Query OK, 1 row affected (0.01 sec)
  • 在Mysql中hive的schema创建schematool -dbType mysql -initSchema
代码语言:javascript复制
schemaTool completed
  • 这里会出现guava jar包的版本问题,解决方法参考这里

8、测试

  • 键入hive
  • create database hive_1;
代码语言:javascript复制
hive> create database hive_test;
OK
Time taken: 0.156 seconds
hive> show databases;
OK
default
hive_test
Time taken: 0.064 seconds, Fetched: 2 row(s)

9、观察Mysql下hive数据库的变化:

代码语言:javascript复制
mysql> use hive;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from DBS;
 ------- ----------------------- ------------------------------------------------------- ----------- ------------ ------------ ----------- 
| DB_ID | DESC                  | DB_LOCATION_URI                                       | NAME      | OWNER_NAME | OWNER_TYPE | CTLG_NAME |
 ------- ----------------------- ------------------------------------------------------- ----------- ------------ ------------ ----------- 
|     1 | Default Hive database | hdfs://Carlota1:9000/user/hive/warehouse              | default   | public     | ROLE       | hive      |
|     2 | NULL                  | hdfs://Carlota1:9000/user/hive/warehouse/hive_test.db | hive_test | root       | USER       | hive      |
 ------- ----------------------- ------------------------------------------------------- ----------- ------------ ------------ ----------- 
2 rows in set (0.00 sec)

mysql> 

0 人点赞