Hive(一):Hive的安装部署

一.首先安装MYSQL。

    在安装Hive前,先安装MySQL,以MySQL作为元数据库,默认的元数据库是内嵌的Derby,但因其有单会话限制,所以选用MySQL。

1.首先检查系统中是否已经安装了MySQL。

    在终端输入:sudo netstat -tap | grep mysql  

    如果有反映,则表名已经安装,若没有,则显示没有。(我的这里是已经安装好的。。)

hadoop@master:~$ sudo netstat -tap | grep mysql
tcp        0      0 *:mysql                 *:*                     LISTEN      1357/mysqld     
tcp        0      0 master:mysql            192.168.226.1:53663     ESTABLISHED 1357/mysqld     
tcp        0      0 master:mysql            192.168.226.1:52512     ESTABLISHED 1357/mysqld     
hadoop@master:~$ 

2.若没有安装,则开始安装MySql,

    在终端输入:

    sudo apt-get update

    sudo apt-get install mysql-server mysql-client

    注意: 在此安装过程中会让你输入root用户密码,按照要求输入即可。(输入密码)

3. 可在终端如步骤1那样检测mysql的安装,也可在终端输入:

    mysql -u root -p  然后输入正确密码。

4.在创建一个hive用户,如下:

    create user 'hive'@'%' identified by 'xujun';

5. 然后在mysql>这里输入:(赋予权限)

    grant all on *.* to username@'%' identified by 'password;

    注意:username是用户名,password是要自己填写的一个名字,例如:

    grant all on *.* to hive@'%' identified by 'xujun';

    flush privileges; 

 

二:安装Hive,如下:

1.官网下载Hive,地址链接:http://mirrors.hust.edu.cn/apache/hive/ (hive-2.0.0)

2.下载完成后,将该压缩包解压在 /mysoftware (Ubuntu)目录下:

hadoop@master:/mysoftware$ ls
apache-hive-2.0.0-bin  hadoop-2.6.4  hbase-1.2.1  jdk1.7.0_80  zookeeper-3.4.8
hadoop@master:/mysoftware$ mv apache-hive-2.0.0-bin/ hive-2.0.0
hadoop@master:/mysoftware$ ls
hadoop-2.6.4  hbase-1.2.1  hive-2.0.0  jdk1.7.0_80  zookeeper-3.4.8

3.进入hive-2.0.0/bin目录下,

hadoop@master:/mysoftware/hive-2.0.0$ ls
bin   examples  lib      NOTICE      RELEASE_NOTES.txt
conf  hcatalog  LICENSE  README.txt  scripts
hadoop@master:/mysoftware/hive-2.0.0$ cd bin/
hadoop@master:/mysoftware/hive-2.0.0/bin$ ls
beeline      ext   hive.cmd         hive-config.sh  hplsql      metatool
beeline.cmd  hive  hive-config.cmd  hiveserver2     hplsql.cmd  schematool
hadoop@master:/mysoftware/hive-2.0.0/bin$ sudo gedit hive-config.sh 

修改hive-config.sh文件中内容,即在末尾添加如下内容:

export JAVA_HOME=/mysoftware/jdk1.7.0_80
export HIVE_HOME=/mysoftware/hive-2.0.0
export HADOOP_HOME=/mysoftware/hadoop-2.6.4

4. 添加环境变量etc/profile,在末尾添加如下内容:

export HIVE_HOME=/mysoftware/hive-2.0.0
export PATH=$HIVE_HOME/bin:$PATH

5. 修改hive-site.xml文件,操作如下:

hadoop@master:/mysoftware/hive-2.0.0/bin$ ls
beeline      hive             hive-config.sh   hplsql      schematool
beeline.cmd  hive.cmd         hive-config.sh~  hplsql.cmd
ext          hive-config.cmd  hiveserver2      metatool
hadoop@master:/mysoftware/hive-2.0.0/bin$ cd ..
hadoop@master:/mysoftware/hive-2.0.0$ cd conf/
hadoop@master:/mysoftware/hive-2.0.0/conf$ ls
beeline-log4j2.properties.template    hive-log4j2.properties.template
hive-default.xml.template             ivysettings.xml
hive-env.sh.template                  llap-daemon-log4j2.properties.template
hive-exec-log4j2.properties.template
hadoop@master:/mysoftware/hive-2.0.0/conf$ cp hive-default.xml.template  hive-site.xml
hadoop@master:/mysoftware/hive-2.0.0/conf$ ls
beeline-log4j2.properties.template    hive-log4j2.properties.template
hive-default.xml.template             hive-site.xml
hive-env.sh.template                  ivysettings.xml
hive-exec-log4j2.properties.template  llap-daemon-log4j2.properties.template
hadoop@master:/mysoftware/hive-2.0.0/conf$ sudo gedit hive-site.xml 

操作完毕后会发现多了一个hive-site.xml,里面的<configuration></configuration>中配置了很多很多很多属性值。我直接然后修改成了如下的内容即:

<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://master:3306/hive?createDatabaseInfoNotExist=true</value> 
            <description>JDBC connect string for a JDBC metastore</description>
      </property>


     <property>
            <name>javax.jdo.option.ConnectionDriverName</name>
            <value>com.mysql.jdbc.Driver</value>
            <description>Driver class name for a JDBC metastore</description>
      </property>


    <property>
            <name>javax.jdo.option.ConnectionUserName</name>
            <value>hive</value>
            <description>Username to use against metastore database</description>
      </property>


    <property>
            <name>javax.jdo.option.ConnectionPassword</name>
            <value>xujun</value>
            <description>password to use against metastore database</description>
      </property>


</configuration>
    

 

6.下载mysql-connector-java-5.5-bin.jar文件驱动包,并放到$HIVE_HOME/lib目录下

7.启动Hive: (注意:在启动HIve服务前,需要先开启Hadoop服务)

hadoop@master:/mysoftware/hive-2.0.0$ bin/hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/mysoftware/hive-2.0.0/lib/hive-jdbc-2.0.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/mysoftware/hive-2.0.0/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/mysoftware/hadoop-2.6.4/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/mysoftware/hive-2.0.0/lib/hive-common-2.0.0.jar!/hive-log4j2.properties
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X releases.
hive> show tables;
OK
testhive
Time taken: 1.041 seconds, Fetched: 1 row(s)
hive> 

 

注意:如果出现以下Error:

[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:158)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.getConsoleReader(CliDriver.java:773)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:715)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)


 
 如果报错了,解决办法:进入到hadoop安装目录下的share/hadoop/yarn/lib 下删除 jline的jar文件。再启动hive即可

我的是已经删除了的,所以启动无误。

 

转载于:https://my.oschina.net/gently/blog/683580

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值