参考资料:
hive安装手册。
Hadoop2.7实战v1.0之Hive-2.0.0+MySQL远程模式安装 http://m.blog.itpub.net/30089851/viewspace-2082805/
安装环境
Ubuntu 12.04 server
java 1.7.0_95
hadoop 2.6.4
步骤:
1、安装mysql
直接使用命令安装:
更新源
sudo apt-get update
安装
sudo apt-get install mysql-server mysql-client
2、Mysql创建新用户以及数据库并授权
mysql> create database hive_remote_meta; Query OK, 1 row affected (0.04 sec) mysql> create user ‘hive‘ identified by ‘hive‘; Query OK, 0 rows affected (0.05 sec) mysql> grant all privileges on hive_remote_meta.* to ‘hive‘@‘%‘; Query OK, 0 rows affected (0.03 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
查看Mysql监听地址
nestart -an | grep 3306tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
结果如上即修改Mysql监听IP地址
sudo vim /etc/mysql/my.cnf # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 #注释掉 # # * Fine Tuning
3、安装hive
官网下载hive2.0安装包
解压到指定文件夹
sudo tar -zxvf apache-hive-2.0.0-bin.tar.gz -C /you_hive_path
配置环境变量
sudo vim ~/.bashrcexport HIVE_HOME=/you_hive_path/apache-hive-2.0.0-binexport PATH=$PATH:$HIVE_HOME/bin
4、配置hive-size.xml文件,位于 HIVE_HOME下的conf中,新建。
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> #设置为本地仓库 <name>hive.metastore.local</name> <value>true</value> </property> <property> #设置仓库地址, value更换为你创建的mysql数据库 <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://Master:3306/hive_remote_meta?characterEncoding=UTF-8</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> #设置使用 JDBC <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>hive</value> <description>username to use against metastore database</description> </property> <property> #数据库密码 <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description> </property> </configuration>
5、初始化hive仓库
schematool -initSchema -dbType mysql SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/usr/local/hadoop/hive/apache-hive-2.0.0-bin/lib/hive-jdbc-2.0.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/hadoop/hive/apache-hive-2.0.0-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]Metastore connection URL: jdbc:mysql://Master:3306/hive_remote_meta?createDatabaseIfNotExist=trueMetastore Connection Driver : com.mysql.jdbc.DriverMetastore connection User: hiveStarting metastore schema initialization to 2.0.0Initialization script hive-schema-2.0.0.mysql.sqlInitialization script completedschemaTool completed
6、启动
hive hive>
若出现
Name node is in safe mode.
则关闭hdfs安全模式
hadoop dfsadmin -safemode leave
完。
时间: 2024-11-12 13:34:56