首页 > 代码库 > 【原】Centos6.5下cdh4.6 hive安装部署

【原】Centos6.5下cdh4.6 hive安装部署

1、前提条件:
     只需要选择一台服务器即可,这里选择安装在namenode上;安装用户为cloud-user
2、安装包:
     sudo yum install -y hive hive-metastore hive-server2
3、安装mysql:
     sudo yum install -y mysql-server
     sudo service mysqld start
    sudo yum install -y mysql-connector-java
     sudo ln -s /usr/share/java/mysql-connector-java.jar /usr/lib/hive/lib/mysql-connector-java.jar
    sudo /usr/bin/mysql_secure_installation (YYNYY)
     创建数据库:
     mysql -u root -p
     Enter password:
     mysql> CREATE DATABASE metastore;
     mysql> USE metastore;
     mysql> SOURCE /usr/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.10.0.mysql.sql;
 
     mysql> CREATE USER ‘hive‘@‘10.0.0.2‘ IDENTIFIED BY ‘mypassword‘;
     mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM ‘hive‘@‘10.0.0.2‘;
     mysql> GRANT SELECT,INSERT,UPDATE,DELETE,LOCK TABLES,EXECUTE ON metastore.* TO ‘hive‘@‘10.0.0.2‘;
     mysql> FLUSH PRIVILEGES;
     mysql> quit;
4、配置hive-site.xml:
 1 <property>
 2   <name>javax.jdo.option.ConnectionURL</name>
 3   <value>jdbc:mysql://10.0.0.2/metastore</value>
 4   <description>JDBC connect string for a JDBC metastore</description>
 5 </property>
 6 
 7 <property>
 8   <name>javax.jdo.option.ConnectionDriverName</name>
 9   <value>com.mysql.jdbc.Driver</value>
10   <description>Driver class name for a JDBC metastore</description>
11 </property>
12 <property>
13   <name>javax.jdo.option.ConnectionUserName</name>
14   <value>hive</value>
15 </property>
16 <property>
17   <name>javax.jdo.option.ConnectionPassword</name>
18   <value>mypassword</value>
19 </property>
20 <property>
21   <name>datanucleus.autoCreateSchema</name>
22   <value>false</value>
23 </property>
24 <property>
25   <name>datanucleus.fixedDatastore</name>
26   <value>true</value>
27 </property>
28 <property>
29   <name>datanucleus.autoStartMechanism</name>
30   <value>SchemaTable</value>
31 </property>
32 <property>
33   <name>hive.metastore.uris</name>
34   <value>thrift://10.0.0.2:9083</value>
35   <description>IP address (or fully-qualified domain name) and port of the metastore host</description>
36 </property>
37 <property>
38 <name>hive.support.concurrency</name>
39   <description>Enable Hive‘s Table Lock Manager Service</description>
40   <value>true</value>
41 </property>
42 <property>
43   <name>hive.zookeeper.quorum</name>
44   <description>Zookeeper quorum used by Hive‘s Table Lock Manager</description>
45   <value>10.0.0.4,10.0.0.6,10.0.0.11</value>
46 </property>
47 <property>
48   <name>hive.zookeeper.client.port</name>
49   <value>2181</value>
50   <description>The port at which the clients will connect.</description>
51 </property>
52 <property>
53   <name>hive.server2.thrift.port</name>
54   <value>10001</value>
55   <description>TCP port number to listen on, default 10000</description>
56 </property>
57 <property>
58   <name>hive.aux.jars.path</name>     
59  <value>file:////usr/lib/hbase/hbase.jar,file:///usr/lib/hive/lib/zookeeper.jar,file:///usr/lib/hive/lib/hive-hbase-handler-0.10.0-cdh4.6.0.jar,file:///usr/lib/hive/lib/guava-11.0.2.jar</value>
60 </property>
5、配置yarn:
     export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce
6、配置hdfs目录:
   sudo -u hdfs hadoop fs -chmod 777 /user
     sudo -u hdfs hadoop fs -mkdir /user/history
     sudo -u hdfs hadoop fs -chmod -R 1777 /user/history
     sudo -u hdfs hadoop fs -chown mapred:hadoop /user/history
     sudo -u hdfs hadoop fs -mkdir /var/log/hadoop-yarn
     sudo -u hdfs hadoop fs -chown yarn:mapred /var/log/hadoop-yarn
 
     sudo -u hdfs hadoop fs -mkdir /tmp
     sudo -u hdfs hadoop fs -chmod -R 1777 /tmp
     sudo -u hdfs hadoop fs -mkdir /user/hive
     sudo -u hdfs hadoop fs -mkdir /user/hive/warehouse
     sudo -u hdfs hadoop fs -chown -R hive /user/hive
     sudo -u hdfs hadoop fs -chmod -R 1777 /user/hive/warehouse
 
     sudo -u hdfs hadoop fs -mkdir /tmp/hadoop-mapred
     sudo -u hdfs hadoop fs -mkdir /tmp/hive-hive
 
     sudo -u hdfs hadoop fs -chmod -R 777 /tmp/hadoop-mapred
     sudo -u hdfs hadoop fs -chmod -R 777 /tmp/hive-hive
     sudo chown -R hive:hive /var/lib/hive/.hivehistory
 
     sudo -u hdfs hadoop fs -mkdir /user/cloud-user
     sudo -u hdfs hadoop fs -chown cloud-user:cloud-user /user/cloud-user
 
7、服务启动:
    sudo service hive-metastore start
     sudo service hive-server2 start
 
8、测试:
    sudo /usr/lib/hive/bin/beeline
beeline> !connect jdbc:hive2://10.0.0.2:10001 hive mypassword org.apache.hive.jdbc.HiveDriver
0: jdbc:hive2://10.0.0.2:10001> SHOW TABLES;
show tables;
+-----------+
| tab_name |
+-----------+
+-----------+
No rows selected (0.238 seconds)
0: jdbc:hive2://10.0.0.2:10001>!quit