前提环境:
环境,hadoop2.6.0+zookeeper3.4.5+hbase1.0.3, jdk1.7
以上环境已安装好,启动成功,hadoop的hdfs-site.xml部分配置如下:
<configuration>
<property>
<name>dfs.nameservices</name>
<value>ns1</value>
</property>
<property>
<name>dfs.ha.namenodes.ns1</name>
<value>nn1,nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.ns1.nn1</name>
<value>yun01-nn-01:9000</value>
</property>
<property>
<name>dfs.namenode.http-address.ns1.nn1</name>
<value>yun01-nn-01:50070</value>
</property>
mysql 5.7.9 安装在192.168.56.110上,用root用户进入:
/usr/local/mysql/bin/mysql -uroot -p123456
mysql> select user, host from mysql.user;
+-----------+--------------+
| user | host |
+-----------+--------------+
| hive | % |
| mysql | % |
| root | % |
| repl | 192.168.56.% |
| mysql | localhost |
| mysql.sys | localhost |
| root | localhost |
+-----------+--------------+
root % 表示任意远程电脑都可以用root用户登录本机。
准备环境已完成,开始安装hive2.0:
1.将hive2.0拷贝到/application/hadoop下,解压:
tar -zxvf apache-hive-2.0.0-bin.tar.gz
重命名:
mv apache-hive-2.0.0 hive
2.环境变量
vi /etc/profile.d/java.sh
export JAVA_HOME=/application/hadoop/jdk
export HADOOP_HOME=/application/hadoop/hadoop
export HADOOP_PREFIX=/application/hadoop/hadoop
export ZOOKEEPER_HOME=/application/hadoop/zookeeper
export HIVE_HOME=/application/hadoop/hive
export PATH=$JAVA_HOME/bin:$HAOOP_HOME/bin:$ZOOKEEPER_HOME/bin:$HIVE_HOME/bin:$PATH
3. 检查下zookeeper和protobuf的jar包是否和hbase保持一致,如果不一致,
拷贝protobuf.**.jar和zookeeper-3.4.6.jar到hive/lib下。
经检查,hbase和hive下的这两个包是一样的,都为:protobuf-java-2.5.0.jar,zookeeper-3.4.6.jar
4.配置hive-env.sh文件
cp hive-env.sh.template hive-env.sh
vi hive-env.sh
HADOOP_HOME=/application/hadoop/hadoop
export HIVE_CONF_DIR=/application/hadoop/hive/conf
5.拷贝mysql驱动到hive/lib下
cp mysql-connector-java-5.1.38-bin.jar /application/hadoop/hive/lib
授权777:
cd /application/hadoop/hive/lib/
chmod 777 mysql-connector-java-5.1.38-bin.jar
查看hbase与hive的通信包是否存在:
find ./ -name hive-hbase-handler*
./hive-hbase-handler-2.0.0.jar
6.hdfs新建文件并授权:
hadoop fs -mkdir -p /hive/warehouse
hadoop fs -mkdir -p /hive/scratchdir
hadoop fs -chmod g+w /hive/warehouse
hadoop fs -chmod g+w /hive/scratchdir
7.配置hive-site.xml
hive-site.xml配置,服务端与客户端要分别配置,服务端配置为:
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>hdfs://ns1/hive/warehouse</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>hdfs://ns1/hive/scratchdir</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.56.110:3306/hive?createData baseIfNotExist=true&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>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateColumns</name>
<value>true</value>
</property>
</configuration>
客户端配置:
<configuration>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>hdfs://ns1/hive/warehouse</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>hdfs://ns1/hive/scratchdir</value>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.56.11:9083,thrift://192.168.56.12:9083</value>
</property>
</configuration>
8.修改hive-env.sh
cd /application/hadoop/hive/conf/
cp hive-env.sh.template hive-env.sh
vi hive-env.sh
export HADOOP_HOME=/application/hadoop/hadoop
export HIVE_CONF_DIR=/application/hadoop/hive/conf
export HIVE_AUX_JARS_PATH=/application/hadoop/hive/lib
9.修改$HIVE_HOME/bin的hive-config.sh,增加以下三行:
#
# processes --config option from command line
#
export JAVA_HOME=/application/hadoop/jdk
export HIVE_HOME=/application/hadoop/hive
export HADOOP_HOME=/application/hadoop/hadoop
10.同步hive和hadoop的jline版本
cd /application/hadoop/hive/lib/
cp jline-2.12.jar /application/hadoop/hadoop/share/hadoop/yarn/lib
删除低版本的jline-0.9.94.jar
11.复制jdk的tools.jar到hive/lib下
cp $JAVA_HOME/lib/tools.jar /application/hadoop/hive/lib
12.同步到其它服务器
scp -r /application/hadoop/hive hadoop@yun01-nn-02:/application/hadoop/
scp -r /application/hadoop/hive hadoop@yun01-dn-01:/application/hadoop/
scp -r /application/hadoop/hive hadoop@yun01-dn-02:/application/hadoop/
12.服务端启动元数据库
hive --service metastore
13.登录客户端
输入命令:
hive
即可进行操作。
|
|