以下操作在hdpsrc3 节点上操作
一,下载安装包
1,下载hive http://mirrors.hust.edu.cn/apache/ 得到apache-hive-1.1.0.tar.gz ,放到该目录下 /home/hdpsrc/
2,下载mysql
http://dev.mysql.com/downloads/mysql/5.5.html#downloads
得到
mysql-client-5.5.39-2.linux2.6.x86_64.rpm
mysql-devel-5.5.39-2.linux2.6.x86_64.rpm
mysql-server-5.5.39-2.linux2.6.x86_64.rpm
mysql-shared-5.5.39-2.linux2.6.x86_64.rpm
mysql-shared-compat-5.5.39-2.linux2.6.x86_64.rpm
拷贝到该目录下 /home/hdpsrc/Desktop/mysql/
二,安装mysql
1,卸载系统自带的mysql相关安装包,
仅卸载
mysql
开头的包
rpm -qa|grep mysql
sudo rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
2,安装
cd /home/hdpsrc/Desktop/mysql/
sudo rpm -ivh mysql-*
sudo cp /usr/share/mysql/my-large.cnf /etc/my.cnf
3,启动设置mysql
启动mysql服务
sudo service mysql start
设置为开机自启动
sudo chkconfig mysql on
设置root用户登录密码
sudo /usr/bin/mysqladmin -u root password 'wu123'
登录mysql 以root用户身份登录
mysql -uroot -pwu123
创建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;
退出mysql
exit
验证hive用户
mysql -uhive -phive
show databases;
看到如下反馈信息,则说明创建成功
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hive |
| test |
+--------------------+
3 rows in set (0.00 sec)
退出mysql
exit
三,安装hive
1,解压安装包
cd ~
tar -zxvf apache-hive-1.1.0-bin.tar.gz
2,建立软连接
ln -s apache-hive-1.1.0-bin hive
3,添加环境变量
vi .bash_profile
导入下面的环境变量
export HIVE_HOME=/home/hdpsrc/hive
export PATH=$PATH:$HIVE_HOME/bin
使其有效
source .bash_profile
4,
修改
hive-site.xml
<name>javax.jdo.option.ConnectionURL </name>
<value>jdbc:mysql://localhost:3306/hive </value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName </name>
<value>com.mysql.jdbc.Driver </value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword </name>
<value>hive </value>
</property>
<property>
<name>hive.hwi.listen.port </name>
<value>9999 </value>
<description>This is the port the Hive Web Interface will listen on </descript ion>
</property>
<property>
<name>datanucleus.autoCreateSchema </name>
<value>true</value>
</property>
<property>
<name>datanucleus.fixedDatastore </name>
<value>false</value>
</property>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>hive.exec.local.scratchdir</name>
<value>/home/hdpsrc/hive/iotmp</value>
<description>Local scratch space for Hive jobs</description>
</property>
<property>
<name>hive.downloaded.resources.dir</name>
<value>/home/hdpsrc/hive/iotmp</value>
<description>Temporary local directory for added resources in the remote file system.</description>
</property>
<property>
<name>hive.querylog.location</name>
<value>/home/hdpsrc/hive/iotmp</value>
<description>Location of Hive run time structured log file</description>
</property>
cp hive/conf/hive-default.xml.template hive/conf/hive-site.xml
编辑hive-site.xml
5,拷贝mysql-connector-java-5.1.6-bin.jar 到hive 的lib下面
mv /home/hdpsrc/Desktop/mysql-connector-java-5.1.6-bin.jar /home/hdpsrc/hive/lib/
6,把jline-2.12.jar拷贝到hadoop相应的目录下,替代jline-0.9.94.jar,否则启动会报错
cp /home/hdpsrc/hive/lib/jline-2.12.jar /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/
mv /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar /home/hdpsrc/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar.bak /
7,穿件hive临时文件夹
mkdir /home/hdpsrc/hive/iotmp
四,启动测试hive
启动hadoop后,执行hive命令
hive
测试输入 show database;
hive> show databases;
OK
default
Time taken: 0.907 seconds, Fetched: 1 row(s)
到此hive已经安装完成
参考文档: http://www.mamicode.com/info-detail-516526.html
http://blog.csdn.net/blueheart20/article/details/38460541
备注:
1,遇到的问题: http://www.mamicode.com/info-detail-516526.html