hive安装需要使用mysql,mysql安装参考上一篇。
Mysql配置
-- 创建 hive 数据库 mysql> CREATE DATABASE hive; -- 创建 hive 用户,并赋予访问 hive 数据库的权限 grant select on 数据库.* to 用户名@登录主机 identified by “密码” (优先选择第三句) grant all privileges on *.* to 'hive'@'192.168.0.104' identified by 'hive' with grant option; grant all privileges on *.* to hive@'%' identified by 'hive' ; grant all privileges on *.* to 'hive'@'%' identified by 'hive' with grant option; mysql> FLUSH PRIVILEGES; (下面六句与配置无关) <--设置 binary log 的格式: mysql> set global binlog_format=MIXED; --查看mysql端口配置 show global variables like 'port'; 收回权限 REVOKE ALL PRIVILEGES ON *.* FROM hive; --> 1、进入目录 /usr/soft/hive 2、vi /etc/environment HIVE_HOME=/usr/soft/hive/apache-hive-1.2.2-bin path增加: :$HIVE_HOME/bin:$HIVE_HOME/hcatalog/bin:$HIVE_HOME/hcatalog/sbin 3、配置HIVE cd /usr/soft/hive/apache-hive-1.2.2-bin cp conf/hive-default.xml.template conf/hive-site.xml cp conf/hive-env.sh.template conf/hive-env.sh cp conf/hive-exec-log4j.properties.template conf/hive-exec-log4j.properties cp conf/hive-log4j.properties.template conf/hive-log4j.properties 修改hive-env.sh (1)添加参数(对应自己的JDK、HADOOP、HIVE的目录 export JAVA_HOME=/usr/soft/jdk1.8.0_121 export HADOOP_HOME=/usr/soft/hadoop-2.8.0 export HIVE_HOME=/usr/soft/hive/apache-hive-1.2.2-bin export HIVE_CONF_DIR=$HIVE_HOME/conf 修改: vi hive-log4j.properties hive.log.dir=/usr/soft/hive ---- vi hcat_server.sh HCAT_LOG_DIR=/usr/soft/hive/logs hive.metastore.warehouse.dir 使用的目录,启动hadoop,然后在hadoop上创建(自己设定,后续配置更改相应目录就行) hadoop fs -mkdir /tmp hadoop fs -mkdir -p /data/hive/warehouse hadoop fs -mkdir -p /data/hive/log hadoop fs -chmod g+w /data/hive/warehouse hadoop fs -chmod g+w /data/hive/log hadoop fs -chmod g+w /tmp 配置hive-site.xml 服务端和配置端区别: 服务端配置文件: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hive.metastore.warehouse.dir</name> <value>/data/hive/warehouse</value> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://127.0.0.1:3306/hive?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>hive</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> </property> </configuration> 2)、客户端配置文件 <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>hive.metastore.warehouse.dir</name> <value>/data/hive/warehouse</value> </property> <property> <name>hive.metastore.local</name> <value>false</value> </property> <property> <name>hive.metastore.uris</name> <value>thrift://ubuntu1:9083</value> </property> </configuration> 我配置的是当前环境变量/etc/environment,以后每次启动都需要运行下 source /etc/environment 初始化数据库 schematool -initSchema -dbType mysql 初始化成功后,以后可以直接使用和操作 hive