Hive 安装手册

Hive 安装手册

 

  1. 解压缩hive安装包

tar zxvf apache-hive-2.1.1-bin.tar.gz

 

  1. 安装mysql

sudo yum install mysql-server

 

  1. 安装 mysql connector

sudo yum install mysql-connector-java

该命令会在/usr/share/java/下产生mysql-connector-java.jar

 

  1. 建立链接

ln -s /usr/share/java/mysql-connector-java.jar /home/bigdata/software/apache-hive-2.1.1-bin/lib/mysql-connector-java.jar

该命令在hive安装目录的lib目录下建立软链接,指向/usr/share/java/mysql-connector-java.jar

 

  1. 启动mysql

sudo service mysqld start

 

可通过以下命令验证mysql启动成功(显示mysql进程):

ps aux | grep mysql

 

 

  1. 修改mysql密码

修改mysql密码(改为newpass,请根据需要自行替换newpass)

mysql –uroot  -pzkpk

  mysql> use mysql;

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';

  mysql> FLUSH PRIVILEGES;

允许用户root通过任意机器访问mysql:

  mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'newpass' WITH GRANT OPTION;

  mysql> FLUSH PRIVILEGES;

 

 

  1. 配置环境变量

/home/bigdata/.bash_profile

export HIVE_HOME=/home/apache-hive-2.1.1-bin

export PATH=$HIVE_HOME/bin:$PATH

运行source生效:

source ~/.bash_profile

 

 

  1. 配置hive

/home/bigdata/software/apache-hive-2.1.1-bin/conf/hive-site.xml

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>

<!--

       Licensed under the Apache License, Version 2.0 (the "License");

         you may not use this file except in compliance with the License.

           You may obtain a copy of the License at

 

    http://www.apache.org/licenses/LICENSE-2.0

 

  Unless required by applicable law or agreed to in writing, software

    distributed under the License is distributed on an "AS IS" BASIS,

      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

        See the License for the specific language governing permissions and

          limitations under the License. See accompanying LICENSE file.

          -->

 

<!-- Put site-specific property overrides in this file. -->

<configuration>

    <property>

        <name>hive.metastore.uris</name>

        <value>thrift://bigdata:9083</value>

    </property>

    <property>

        <name>hive.server2.thrift.port</name>

        <value>10000</value>

    </property>

    <property>

        <name>javax.jdo.option.ConnectionURL</name>

        <value>jdbc:mysql://bigdata/metastore?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>root</value>

    </property>

    <property>

        <name>hive.metastore.schema.verification</name>

        <value>false</value>

    </property>

    <property>

        <name>hive.metastore.warehouse.dir</name>

        <value>/warehouse</value>

    </property>

    <property>

        <name>fs.defaultFS</name>

        <value>hdfs://bigdata:9000</value>

    </property>

    <property>

        <name>datanucleus.autoCreateSchema</name>

        <value>true</value>

    </property>

    <property>

        <name>datanucleus.autoStartMechanism</name>

        <value>SchemaTable</value>

    </property>

    <property>

        <name>datanucleus.schema.autoCreateTables</name>

        <value>true</value>

    </property>

 

    <property>

        <name>beeline.hs2.connection.user</name>

        <value>bigdata</value>

        </property>

     <property>

        <name>beeline.hs2.connection.password</name>

        <value>bigdata</value>

     </property>

</configuration>

注意(可跳过月度这部分):

  • hive.metastore.uris中的“bigdata“含义为metastore所在的机器(启动metastore的方法见下一节)
  • javax.jdo.option.ConnectionURL中的“bigdat”为mysql安装机器的hostname
  • javax.jdo.option.ConnectionUserName和javax.jdo.option.ConnectionPassword分别为mysql的访问用户和密码,可通过以下命令验证是否有效(期中bigdata为javax.jdo.option.ConnectionURL中配置的地址,xxx为mysql用户名):
    • mysql –h bigdata-u xxx –p
  • fs.defaultFS为HDFS的namenode启动的机器地址
  • beeline.hs2.connection.user和beeline.hs2.connection.password是beeline方式访问的用户名和密码,可任意指定,但在beeline访问时要写入你指定的这个(具体参考最后一部分)

 

  1. 启动metastore

nohup hive --service metastore >> apache-hive-2.1.1-bin/metastore.log 2>&1  &

 

  1. 启动hive server

nohup hive --service hiveserver2 >> apache-hive-2.1.1-bin/hiveserver.log 2>&1 &

 

 

ps aux | grep hive

 

  1. Hive常见两种访问方式

(1)

hive

 

(2)

beeline

 

!connect jdbc:hive2://bigdata:10000/default  bigdata bigdata

其中bigdata和bigdata分别是在hive-site.xml配置文件中由beeline.hs2.connection.user和beeline.hs2.connection.password设置的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值