简介:
Hive 安装文档
https://mirrors.tuna.tsinghua.edu.cn/apache/hive/stable-2/apache-hive-2.1.1-bin.tar.gz
一、安装 MySQL
# http://www.cnblogs.com/wangxiaoqiangs/p/5336048.html
# 我是安装在了 master.hadoop 上,该数据库是为了保存 Hive 的元数据信息,可以随意安装在别处!
shell > mysql mysql> create database hive_meta; mysql> grant all on hive_meta.* to [email protected] identified by ‘hive‘ with grant option; mysql> flush privileges; # 为 hive 创建数据库、用户,并授权。
二、安装 Hive
shell > wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.41.tar.gz shell > wget https://mirrors.tuna.tsinghua.edu.cn/apache/hive/stable-2/apache-hive-2.1.1-bin.tar.gz shell > tar zxf apache-hive-2.1.1-bin.tar.gz -C /usr/local/ shell > tar zxf mysql-connector-java-5.1.41.tar.gz shell > cp mysql-connector-java-5.1.41/mysql-connector-java-5.1.41-bin.jar /usr/local/apache-hive-2.1.1-bin/lib/ # mysql 驱动包
shell > cd /usr/local shell > chown -R hadoop.hadoop apache-hive-2.1.1-bin/ shell > vim /etc/profile export PATH=$PATH:/usr/local/mysql/bin:/usr/local/hadoop-2.8.0/bin:/usr/local/apache-hive-2.1.1-bin/bin shell > source /etc/profile # 设置环境变量
shell > su - hadoop hadoop shell > cd /usr/local/apache-hive-2.1.1-bin # 编辑 hive-env.sh hadoop shell > cp conf/hive-env.sh.template conf/hive-env.sh hadoop shell > vim conf/hive-env.sh HADOOP_HOME=/usr/local/hadoop-2.8.0 # 指定 hadoop 安装目录
# 编辑 hive-site.xml hadoop shell > cp conf/hive-default.xml.template conf/hive-site.xml hadoop shell > vim conf/hive-site.xml <property> <name>hive.metastore.warehouse.dir</name> <value>/user/hive/warehouse</value> </property> <property> <name>hive.exec.scratchdir</name> <value>/tmp/hive</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive_meta</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> </property> # hive.metastore.warehouse.dir hive 数据存储目录 # hive.exec.scratchdir hive 临时文件目录 # javax.jdo.option.ConnectionDriverName 数据库驱动类型 # javax.jdo.option.ConnectionURL 数据库实例链接 # javax.jdo.option.ConnectionUserName 数据库连接用户 # javax.jdo.option.ConnectionPassword 数据库连接密码 hadoop shell > mkdir logs hadoop shell > sed -i ‘s#${system:java.io.tmpdir}#/usr/local/apache-hive-2.1.1-bin/logs#g‘ conf/hive-site.xml hadoop shell > sed -i ‘s#${system:user.name}#hive#g‘ conf/hive-site.xml
三、初始化数据表
hadoop shell > schematool -initSchema -dbType mysql # 初始化数据表 hadoop shell > mysql -A mysql> use hive_meta; mysql> show tables; +---------------------------+ | Tables_in_hive_meta | +---------------------------+ | AUX_TABLE | | BUCKETING_COLS | | CDS | | COLUMNS_V2 | | COMPACTION_QUEUE | | COMPLETED_COMPACTIONS | | COMPLETED_TXN_COMPONENTS | | DATABASE_PARAMS | | DBS | | DB_PRIVS | | DELEGATION_TOKENS | | FUNCS | ... # 可以看到生成了好多表
四、客户端访问 hive
hadoop shell > hive hive > show databases; OK default Time taken: 1.139 seconds, Fetched: 1 row(s) hive > quit;
时间: 2024-10-17 11:03:38