hadoop中类似于SQL高级语言,用于运行存储在Hadoop上的查询语句
1 [root@master hadoop]# yum install mysql
//安装客户端
2 [root@master hadoop]# yum install mysql-server //安装服务端
[root@master hadoop]# yum install mysql-devel //安装设置文件
3[root@localhost Desktop]# service mysqld status //查询mysql状态
mysqld is stopped
4[root@localhost Desktop]# service mysqld start //启动
5[root@localhost Desktop]# service mysqld stop //停止
6 [root@localhost Desktop]# mysql -u root -p
Enter password:
7 mysql> create database hive; //创建hive数据库
8mysql> grant all on hive.* to hadoop@'master' IDENTIFIED BY 'hivepwd';
Query OK, 0 rows affected (0.00 sec)
//让hadoop用户有权操作hive库的所有表
8 [root@localhost soft]# tar -zxvf hive-0.12.0.tar.gz
9[root@localhost hive]# cd conf
[root@localhost conf]# vi hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?createDatabaseIfNotExist=true</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.ConnectionUserName</name>
<value>hadoop</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hivepwd</value>
<description>password to use against metastore database</description>
</property>
</configuration>
10 [root@localhost bin]# vi hive-config
export JAVA_HOME=/soft/jdk1.7.0_79
export HADOOP_HOME=/soft/hadoop/etc/hadoop/
11 把mysql的jdbc驱动jar移到hive/lib下,然后配置环境变量,以root用户在/etc/profile文件末尾添加
export HIVE_HOME=/soft/hive
export PATH=$PATH:$HIVE_HOME/bin
12 [root@localhost bin]# source /etc/profile //立即生效
13保证mysql和hadoop正常运行
[root@localhost ~]# jps
3903 DataNode
35596 Jps
34630 NameNode
4204 ResourceManager
4291 NodeManager
[root@localhost ~]# service mysqld status
mysqld (pid 5627) is running...
14
[root@localhost ~]# hive --service metastore //启动hive服务
-->[root@localhost ~]# jps
[root@localhost bin]# jps
3903 DataNode
34630 NameNode
4204 ResourceManager
35820 RunJar
36477 Jps
4291 NodeManager
[root@localhost Desktop]# hive
后--->hive>
安装并配置Eclipse Hadoop插件
将上面的jar包用ssh上传到指定位置,将jar包放到eclipse下面的位置
接下来到system按如下操作: