环境:
ubuntu 14.04
hadoop 1.0.1
5.5.46-0ubuntu0.14.04.2
hive 0.9.0
安装配置步骤:
安装mysql
sudo apt-get install mysql-serve
在安装过程中会让你配置root用户的密码,去设置的是root
2. 安装成功后确认mysql是否启动
jason@jason-ThinkPad-E450:~$ ps -ef|grep mysql
mysql 8874 1 0 20:52 ? 00:00:00 /usr/sbin/mysqld
jason 9072 3088 0 20:53 pts/0 00:00:00 grep --color=auto mysql
jason@jason-ThinkPad-E450:~$ sudo service mysql status
mysql start/running, process 8874
3. 登录mysql 以root用户身份登录
mysql -uroot -proot
4. 创建hive用户,数据库等
insert into mysql.user(Host,User,Password) values("localhost","hive",password("hive"));
create database hive;
grant all on hive.* to hive@'%' identified by 'hive';
grant all on hive.* to hive@'localhost' identified by 'hive';
flush privileges;
5. 退出mysql
exit
6. 验证hive用户
mysql -uhive -phive
show databases;
看到如下反馈信息,则说明创建成功
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hive |
+--------------------+
2 rows in set (0.00 sec)
7. 安装hive
从以下链接下载hive
http://archive.apache.org/dist/hive/hive-0.9.0/hive-0.9.0.tar.gz
解压安装包
tar -zxvf hive-0.9.0.tar.gz
建立软连接
ln -s hive-0.9.0 hive
添加环境变量
sudo vi /etc/profile/
导入下面的环境变量
export HIVE_HOME=/home/jason/hive/hive
export PATH=$PATH:$HIVE_HOME/bin
使其有效
source /etc/profile
进入到hive目录下的conf目录从模板文件中拷贝一份hive-site.xml文件,在此基础上修改
cp hive-default.xml.template hive-site.xml
主要修改以下配置:
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive</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.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>Username to use against metastore database</description> </property> <property> <name>hive.exec.scratchdir</name> <value>/home/jason/hive/hive/iotmp</value> <description>Local scratch space for Hive jobs</description> </property>
下载并安装mysql jdbc
http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.38.tar.gz
tar -zxvf mysql-connector-java-5.1.38.tar.gz
cp mysql-connector-java-5.1.38-bin.jar /home/jason/hive/hive/lib/
创建hive临时文件夹
mkdir /home/jason/hive/hive/iotmp个
最后输入命令hive启动hive
jason@jason-ThinkPad-E450:~/hadoop-1.0.1$ hive
Logging initialized using configuration in jar:file:/home/jason/hive/apache-hive-1.0.1-bin/lib/hive-common-1.0.1.jar!/hive-log4j.properties
hive>
输入show databases命令查看已经存在的数据库:
hive> show databases;
OK
default
Time taken: 0.139 seconds, Fetched: 1 row(s)