hive 安装配置

来源:互联网 发布:二次元图片制作软件 编辑:程序博客网 时间:2024/05/01 19:10
[root@master bin]# wget http://mirrors.hust.edu.cn/apache/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz[root@master bin]# tar -zxvf apache-hive-1.2.1-bin.tar.gz [root@master bin]# cd conf/[root@master conf]# cp hive-default.xml.template hive-default.xml[root@master conf]# cp hive-default.xml.template hive-site.xml[root@master conf]# cp hive-exec-log4j.properties.template hive-exec-log4j.properties[root@master conf]# cp hive-log4j.properties.template hive-log4j.properties[root@master conf]# cp hive-env.sh.template hive-env.sh[root@master conf]# vi /etc/profile#添加以下内容export HIVE_HOME=/root/hiveexport PATH=$PATH:$HIVE_HOME/bin[root@master conf]# vi hive-env.sh#打开以下export#export HADOOP_HEAPSIZE=1024export HADOOP_HOME=/root/hadoop-2.6.0export HIVE_CONF_DIR=/root/hive/confexport HIVE_AUX_JARS_PATH=/root/hive/lib[root@master conf]# vi hive-site.sh#修改以下参数     <property>         <name>hive.metastore.uris</name>         <value>thrift://127.0.0.1:9083</value>     </property>    <property>         <name>javax.jdo.option.ConnectionURL</name>         <value>jdbc:mysql://127.0.0.1:3306/hive?createDatabaseIfNotExist=true</value>     </property>     <property>         <name>javax.jdo.option.ConnectionDriverName</name>         <value>com.mysql.jdbc.Driver</value>     </property>     <property>         <name>javax.jdo.option.ConnectionUserName</name>         <value>root</value>     </property>     <property>         <name>javax.jdo.option.ConnectionPassword</name>         <value>mysql</value>     </property>  <property>    <name>hive.metastore.warehouse.dir</name>    <value>/root/hive/log</value>    <description>location of default database for the warehouse</description>  </property>  <property>    <name>hive.exec.local.scratchdir</name>    <value>/root/hive/log</value>    <description>Local scratch space for Hive jobs</description>  </property>  <property>    <name>hive.downloaded.resources.dir</name>    <value>/root/hive/log</value>    <description>Temporary local directory for added resources in the remote file system.</description>  </property>  <property>    <name>hive.querylog.location</name>    <value>/root/hive/log</value>    <description>Location of Hive run time structured log file</description>  </property>[root@master conf]# mkdir /root/hive/log/#拷贝mysql-connector-java-5.1.6-bin.jar 到hive 的lib下面[root@master conf]#mv /home/mysql-connector-java-5.1.6-bin.jar /root/hive/lib/#把jline-2.12.jar拷贝到hadoop相应的目录下,替代jline-0.9.94.jar[root@master conf]#cp /root/hive/lib/jline-2.12.jar /root/hadoop-2.6.0/share/hadoop/yarn/lib/#启动测试hive 启动hadoop后,执行hive命令[root@master conf]#cd ../bin[root@master bin]# hiveLogging initialized using configuration in file:/root/apache-hive-1.2.1-bin/conf/hive-log4j.propertieshive> show databases;OKdefaultTime taken: 0.907 seconds, Fetched: 1 row(s)

启动服务:

hive --service  metastore &

hive -service hiveserver2 &

hive> create table sopdm(id int,name string,age int,tel string) row format delimited fields terminated by ',' stored as textfile;FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:javax.jdo.JDODataStoreException: An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytescom.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes[root@master bin]# mysql -uroot -p123456mysql> use sync;Database changedmysql> show variables like '%char%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | utf8                       || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | utf8                       || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.05 sec)mysql> alter database sync character set latin1;Query OK, 1 row affected (0.16 sec)mysql> show variables like '%char%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | latin1                     || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | utf8                       || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)[root@master bin]# hiveLogging initialized using configuration in file:/root/apache-hive-1.2.1-bin/conf/hive-log4j.propertieshive> use test;OKTime taken: 0.813 secondshive> create table sopdm(id int,name string,age int,tel string) row format delimited fields terminated by ',' stored as textfile;OKTime taken: 1.163 secondshive> show tables;OKsopdmTime taken: 0.361 seconds, Fetched: 1 row(s)
hive> load data local inpath '/tmp/test.dat' into table sopdm;hive> select * from sopdm;OK1       wyp     25      131888888882       test    30      138999999993       zs      34      89931412


0 0