大数据

Hive2.3.4安装[hadoop完全分布式中]

2018-11-26  本文已影响0人  57山本无忧

一、安装Hadoop

Hive运行在Hadoop环境之上,因此需要hadoop环境,本次在安装在hadoop完全分布式模式的namennode节点上

请参考:hadoop搭建[完全分布式]

二、安装Hive

[hadoop@s101 /home/hadoop]$cd /app/
[hadoop@s101 /app]$wget http://archive.apache.org/dist/hive/stable-2/apache-hive-2.3.4-bin.tar.gz
[hadoop@s101 /app]$cd /app
[hadoop@s101 /app]$ln -s apache-hive-2.3.4-bin hive
[hadoop@s101 /app]$tar zxvf apache-hive-2.3.4-bin.tar.gz

echo -e '##################HIVE环境变量配置#############\nexport HIVE_HOME=/app/hive\nexport PATH=$HIVE_HOME/bin:$PATH' >> ~/.bash_profile&& source ~/.bash_profile&&tail -3 ~/.bash_profile

三、配置hive

3.1 拷贝出hive-site.xml和hive-env.sh配置文件

[hadoop@s101 /app/hive/conf]$cd /app/hive/conf/
[hadoop@s101 /app/hive/conf]$cp hive-default.xml.template hive-site.xml
[hadoop@s101 /app]$cp hive-env.sh.template hive-env.sh

3.2 修改hive-site.xm中系统无法识别的变量${system:java.io.tmpdir}${system:user.name}

[hadoop@s101 /app/hive/conf]$sed -n 's#${system:java.io.tmpdir}#/app/hive.java.io.tmpdir#pg' hive-site.xml 
    <value>/app/hive.java.io.tmpdir/${system:user.name}</value>
    <value>/app/hive.java.io.tmpdir/${hive.session.id}_resources</value>
    <value>/app/hive.java.io.tmpdir/${system:user.name}</value>
    <value>/app/hive.java.io.tmpdir/${system:user.name}/operation_logs</value>
[hadoop@s101 /app/hive/conf]$sed -n 's#${system:user.name}#hadoop#pg' hive-site.xml 
    <value>/app/hive.java.io.tmpdir/hadoop</value>
    <value>/app/hive.java.io.tmpdir/hadoop</value>
    <value>/app/hive.java.io.tmpdir/hadoop/operation_logs</value>

[hadoop@s101 /app/hive/conf]$sed -i 's#${system:java.io.tmpdir}#/app/hive.java.io.tmpdir#g' hive-site.xml 
[hadoop@s101 /app/hive/conf]$sed -i 's#${system:user.name}#hadoop#g' hive-site.xml
[hadoop@s101 /app/hive/conf]$grep 'hive.java.io.tmpdir' hive-site.xml 
    <value>/app/hive.java.io.tmpdir/${system:user.name}</value>
    <value>/app/hive.java.io.tmpdir/${hive.session.id}_resources</value>
    <value>/app/hive.java.io.tmpdir/${system:user.name}</value>
    <value>/app/hive.java.io.tmpdir/${system:user.name}/operation_logs</value>
[hadoop@s101 /app/hive/conf]$grep 'hive.java.io.tmpdir/hadoop' hive-site.xml 
    <value>/app/hive.java.io.tmpdir/hadoop</value>
    <value>/app/hive.java.io.tmpdir/hadoop</value>
    <value>/app/hive.java.io.tmpdir/hadoop/operation_logs</value>
[hadoop@s101 /app]$mkdir -p /app/hive.java.io.tmpdir/hadoop

3.3 初始化默认derby数据库

[hadoop@s101 /home/hadoop]$schematool -initSchema -dbType derby

.......
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User: APP
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.derby.sql
Initialization script completed
schemaTool completed

[hadoop@s101 /home/hadoop]$ll /home/hadoop/metastore_db/
[hadoop@s101 /home/hadoop]$hdfs dfs -ls  /tmp
Found 2 items
drwx-wx-wx   - hadoop supergroup          0 2018-11-26 19:12 /tmp/hive

四、进入hive命令行

[hadoop@s101 /home/hadoop]start-dfs.sh
[hadoop@s101 /home/hadoop]start-yarn.sh
[hadoop@s101 /home/hadoop]$hive
...
hive> 

五、配置MySQL数据库存储元数据

5.1 修改URL、drivername、username、password等配置信息

[hadoop@s101 /home/hadoop]$vim /app/hive/conf/hive-site.xml

<property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.200.9: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>hive</value>
</property>
<property>
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>123456</value>
</property>

请参考:mysql安装

5.2 mysql的相关设置

binlog_format=ROW

否则在后续初始化时会出现一下问题


图片.png
create database hive;
GRANT ALL PRIVILEGES ON hive.* TO 'hive'@'192.168.%.%' IDENTIFIED BY '123456' WITH GRANT OPTION;
flush privileges;
[hadoop@s101 /home/hadoop]$ls /app/hive/lib/mysql-connector-java-5.1.38.jar 
/app/hive/lib/mysql-connector-java-5.1.38.jar
[hadoop@s101 /home/hadoop]$schematool -initSchema -dbType mysql
....
Metastore connection URL:    jdbc:mysql://192.168.200.9:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :    com.mysql.jdbc.Driver
Metastore connection User:   hive
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed
mysql> use hive;
Database changed
mysql> show tables;
图片.png
[hadoop@s101 /home/hadoop]$hive
...
...
hive> exit;
上一篇下一篇

猜你喜欢

热点阅读