hive仅仅是一个客户端工具,不存在集群概念,因此安装的时候无需每台机器安装,哪个节点需要使用,就安装在哪个节点上。多个节点安装的时候mysql的元数据库一定要相同(即要在同一个mysql同一个库上),否则各个客户端获取的数据不一致
hive安装步骤
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <!-- ########################### hive的 JDBC连接 ############################ --> <!-- mysql 连接用户名 --> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>caoxiaobo</value> </property> <!-- mysql 连接密码 --> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>Caoxiaobo0917!</value> </property> <!-- mysql 连接URL 如果hive和mysql在同一服务器上,使用localhost --> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/myhive</value> </property> <!-- mysql 连接驱动 --> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> </configuration>
备注:hive-default.xml用于保留默认配置,hive-site.xml用于个性化配置,可覆盖默认配置
$ ./schematool -dbType mysql -initSchema
....
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://localhost:3306/myhive
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: caoxiaobo
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Initialization script completed
schemaTool completed
6.配置hive环境变量
$ vim /etc/profile
末尾添加如下内容:
export HIVE_HOME=/usr/local/apache-hive-2.3.5-bin export PATH=$PATH:$HIVE_HOME/bin
使环境变量生效:
$ source /etc/profile
hive> create database test; # 创建test数据库 OK Time taken: 0.069 seconds hive> use test; # 进入test数据库 OK Time taken: 0.068 seconds hive> create table tt(id int); # 创建表 tt OK Time taken: 1.886 seconds hive> show tables; # 查看test库中所有的表 OK tt Time taken: 0.093 seconds, Fetched: 1 row(s)
原文:https://www.cnblogs.com/caoxb/p/11333741.html