Hadoop Hive安装手记
hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库表,并提供完整的sql查询功能,可以将sql语句转换为 MapReduce任务进行运行。 其优点是学习成本低,可以通过类SQL语句快速实现简单的MapReduce统计,不必开发专门的MapReduce应用,十分适合数据仓库的统计分析。
[网络环境设置] vim /etc/hosts
192.168.100.52 hadoop1
192.168.99.34 hadoop2
192.168.103.135 hadoop3
分别到对应机器执行:
hostname hadoop1
hostname hadoop2
hostname hadoop3
[打通机器]
hadoop1# ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
hadoop1# scp ~/.ssh/id_dsa.pub hadoop2:/root/
hadoop1# scp ~/.ssh/id_dsa.pub hadoop3:/root/
hadoop2# cat id_dsa.pub » ~/.ssh/authorized_keys
hadoop3# cat id_dsa.pub » ~/.ssh/authorized_keys
验证:从hadoop1登录到hadoop2和hadoop3,不再需要密码。
[安装hadoop] 确保所有机器有 ssh rsync jdk
确保设置了:
export JAVA_HOME=/opt/soft/jdk
hive在0.20.x的hadoop做了大量的测试,因此选择0.20
cd /opt/soft/
wget http://mirror.bjtu.edu.cn/apache/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz
tar -zxvf hadoop-0.20.2.tar.gz
cd hadoop-0.20.2/
vim .bashrc
export HADOOP_HOME=/opt/soft/hadoop-0.20.2
(重复以上作到另外两机器)
[配置hadoop] vim conf/core-site.xml
修改:
vim conf/hdfs-site.xml
修改:
vim conf/mapred-site.xml
修改:
vim masters
hadoop1
vim slaves
hadoop2
hadoop3
scp conf/* hadoop2:/opt/soft/hadoop-0.20.2/conf/
scp conf/* hadoop3:/opt/soft/hadoop-0.20.2/conf/
[初始化]
cd $HADOOP_HOME/bin
./hadoop namenode -format
启动
./start-all.sh
[验证] $HADOOP_HOME/bin/hadoop dfs -ls /
打开 http://192.168.100.52:50030
http://192.168.100.52:50070
[搭建hive集群] 下载
只需要在hadoop1机器上安装
cd /opt/soft/hadoop-0.20.2
wget http://mirror.bjtu.edu.cn/apache/hive/hive-0.7.0/hive-0.7.0.tar.gz
tar zxvf hive-0.7.0.tar.gz
cd hive-0.7.0
vim ~/.bashrc
export HIVE_HOME=/opt/soft/hadoop-0.20.2/hive-0.7.0
$HIVE_HOME/bin/hive
>create table tt(id int,name string) row format delimited fields terminated by ‘,’ collection items terminated by “\n” stored as textfile;
>select * from tt;
>drop table tt;
试玩结束。
[配置hive] 准备mysql:hadoop1 user:hadoop pwd:hadoop
>create database hive
>GRANT all ON hive.* TO hadoop@% IDENTIFIED BY ‘hadoop’;
>FLUSH PRIVILEGES ;
vim $HIVE_HOME/conf/hive-site.xml
[启动] 复制一个mysql-connector-java-5.1.10.jar到hive/lib下后:
$HIVE_HOME/bin/hive
>create table tt(id int,name string) row format delimited fields terminated by ‘,’ collection items terminated by “\n” stored as textfile;
如果报如下错:
FAILED: Error in metadata: javax.jdo.JDOException: Couldnt obtain a new sequence (unique id) : Binary logging not possible. Message: Transaction level ‘READ-COMMITTED’ in InnoDB is not safe for binlog mode ‘STATEMENT’
退出hive后,以root进入mysql执行:
>set global binlog_format=‘MIXED’;
这是mysql的一个bug。
安装结束。
原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com]
Posted by 54chen 架构研究