安装和配置hive
1、上传hive、mysql、mysql driver到服务器/mnt目录下:
[root@chavin mnt]# ll mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz apache-hive-0.13.1-bin.tar.gz mysql-connector-java-5.1.22-bin.jar
-rw-r--r--. 1 root root 54246778 Mar 13 10:46 apache-hive-0.13.1-bin.tar.gz
-rw-r--r--. 1 root root 312043744 Mar 13 10:46 mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--. 1 root root 832960 Mar 13 10:46 mysql-connector-java-5.1.22-bin.jar
2、安装mysql数据库(mysql-5.6.24-linux-glibc2.5-x86_64.tar.gz)
3、安装hive
解压hive二进制包,并移动到相应安装目录下,我这里是/opt: #tar -zxvf apache-hive-0.13.1-bin.tar.gz #mv apache-hive-0.13.1-bin /opt/hive-0.13.1 拷贝/mnt下mysql驱动包到hive安装目录lib下: #cp mysql-connector-java-5.1.22-bin.jar /opt/hive-0.13.1/lib/ 进入hive conf/目录下,配置hive-env.sh及hive-site.xml文件: #vim hive-env.sh --修改以下两项: HADOOP_HOME=/opt/hadoop export HIVE_CONF_DIR=/opt/hive-0.13.1/conf --------------------------------------------------------------------------- #vim hive-site.xml 编辑内容如下: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://chavin.king:3306/metastore?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>root</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>mysql</value> <description>password to use against metastore database</description> </property> </configuration> --hive安装完成。 现在可以通过bin/hive命令登录hive shell进行相应操作了。 |
--配置hive命令行显示库及表信息:在配置文件(hive-site.xml)中加入以下信息,重启客户端即可。 <property> <name>hive.cli.print.header</name> <value>true</value> <description>Whether to print the names of the columns in query output.</description> </property> <property> <name>hive.cli.print.current.db</name> <value>true</value> <description>Whether to include the current database in the Hive prompt.</description> </property> --再次登录,hive shell头显示如下:hive (chavin)> |
--hive log日志配置: [hadoop@db01 conf]$ cd /opt/hive-0.13.1/conf/ [hadoop@db01 conf]$ cp hive-log4j.properties.template hive-log4j.properties [hadoop@db01 conf]$ vim hive-log4j.properties 修改内容相应log配置内容。 --启动时设置日志: [hadoop@db01 hive-0.13.1]$ bin/hive --hiveconf hive.root.logger=info,console |