ubuntu16.04 安装hive及配置(mysql数据库)

1.下载hive

http://mirror.bit.edu.cn/apache/hive/

 

2.解压文件

tar -xvf apache-hive-3.1.2-bin.tar.gz

修改名称

mv apache-hive-3.1.2 hive

3.配置环境变量

1.修改~/.bashrc文件

vim ~/.bashrc

添加

复制代码

HADOOP_HOME=/home/suphowe/server/hadoop
export HADOOP_HOME
HBASE_HOME=/home/suphowe/server/hbase
export HBASE_HOME
HIVE_HOME=/home/suphowe/server/hive
export HIVE_HOME
PATH=$PATH:$HOME/bin
PATH=$PATH:$HBASE_HOME/bin
PATH=$PATH:$HIVE_HOME/bin
PATH=$PATH:$HADOOP_HOME/bin
export PATH

复制代码
//立即生效
source ~/.bashrc

4.配置环境

1.拷贝文件

/home/suphowe/server/hive/conf目录下执行

cp hive-env.sh.template hive-env.sh

cp hive-default.xml.template hive-site.xml cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties cp hive-log4j2.properties.template hive-log4j2.properties

2.修改hive-env.sh,添加

HADOOP_HOME=/home/suphowe/server/hadoop
export HIVE_CONF_DIR=/home/suphowe/server/hive/conf

3.修改log日志

${system:java.io.tmpdir}都修改成/home/suphowe/server/hive/logs

${system:user.name}都换成用户名

4.修改hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
  <!-- WARNING!!! This file is auto generated for documentation purposes ONLY! -->
  <!-- WARNING!!! Any changes you make to this file will be ignored by Hive.   -->
  <!-- WARNING!!! You must make your changes in hive-site.xml instead.         -->
  <!-- Hive Execution Parameters -->
    <property>
      <name>javax.jdo.option.ConnectionURL</name>
      <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=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>root</value>
      <description>username to use against metastore database</description>
    </property>

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

5.初始化hive数据库

/home/suphowe/server/hive/bin目录下

./schematool  -dbType mysql -initSchema

5.启动

5.1 本地启动

/home/suphowe/server/hive/bin目录下

./hive

5.2 服务启动

./hive --service metastore &
./hive --service hiveserver2 &

猜你喜欢

转载自www.cnblogs.com/suphowe/p/12169667.html