1、下载Hive2.3.0
wget http://mirror.bit.edu.cn/apache/hive/hive-2.3.0/apache-hive-2.3.0-bin.tar.gz
2、解压到指定安装目录
tar -zxvf apache-hive-2.3.0-bin.tar.gz
mv apache-hive-2.3.0-bin /usr/local/hive
cd /usr/local/hive
3、配置/etc/profile,在/etc/profile中添加如下语句
export HIVE_HOME=/usr/local/hive
export PATH=$HIVE_HOME/bin:$PATH
使之生效
source /etc/profile
4、安装MySQL数据库
参考 centos7下安装mysql
5、创建metastore数据库并为其授权
create database metastore;
grant all on metastore.* to hive@'%' identified by 'hive';
grant all on metastore.* to hive@'localhost' identified by 'hive';
flush privileges;
6、 下载jdbc connector
下载地址Connector/J 5.1.43
下载完成之后将其拷贝至$HIVE_HOME/lib目录下
mv mysql-connector-java-5.1.43.tar.gz $HIVE_HOME/lib
7、修改hive配置文件
cd /usr/local/hive/conf
7.1复制初始化文件并重改名
cp hive-env.sh.template hive-env.sh
cp hive-default.xml.template hive-site.xml
cp hive-log4j2.properties.template hive-log4j2.properties
cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties
7.2修改hive-env.sh
export JAVA_HOME=/usr/local/jdk1.7.0_80
export HADOOP_HOME=/usr/local/hadoop
export HIVE_HOME=/usr/local/hive
export HIVE_CONF_DIR=/usr/local/hive/conf
7.3在hdfs 中创建下面的目录 ,并且授权
hdfs dfs -mkdir -p /user/hive/warehouse
hdfs dfs -mkdir -p /user/hive/tmp
hdfs dfs -mkdir -p /user/hive/log
hdfs dfs -chmod -R 777 /user/hive/warehouse
hdfs dfs -chmod -R 777 /user/hive/tmp
hdfs dfs -chmod -R 777 /user/hive/log
7.4修改hive-site.xml
<property>
<name>hive.exec.scratchdir</name>
<value>/user/hive/tmp</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/user/hive/log</value>
</property>
## 配置 MySQL 数据库连接信息
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/metastore?createDatabaseIfNotExist=true&characterEncoding=UTF-8&useSSL=false</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>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
7.5 创建tmp文件
mkdir /home/hadoop/hive-2.1.1/tmp
并在hive-site.xml中修改:
把{system:java.io.tmpdir} 改成 /home/hadoop/hive-2.1.1/tmp/
把 {system:user.name} 改成 {user.name}
8、初始化hive
schematool -dbType mysql -initSchema hive hive