您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍Hive如何安装、配置及基础使用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
此主题介绍Hive的安装、配置及基础使用。
Hive基本信息
官网:http://hive.apache.org/
# 切换到工作空间 cd /opt/workspaces # 创建Hive数据目录 mkdir data/hive # 创建Hive日志目录 mkdir logs/hive
wget http://mirrors.cnnic.cn/apache/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz tar -zxf apache-hive-1.2.1-bin.tar.gz rm -rf apache-hive-1.2.1-bin.tar.gz mv apache-hive-1.2.1-bin ./frameworks/hive
vi ~/.profile
export HIVE_HOME=/opt/workspaces/frameworks/hive export PATH=$PATH:$HIVE_HOME/bin
source ~/.profile
配置Mysql
mysql -u root -p create database hive; grant all on *.* to'hive'@'%' identified by 'hive'; #账号hive,密码hive,所有IP都可以访问(%) flush privileges; exit;
创建HDFS目录
./frameworks/hadoop/bin/hadoop fs -mkdir /tmp ./frameworks/hadoop/bin/hadoop fs -mkdir -p /user/hive/warehouse ./frameworks/hadoop/bin/hadoop fs -chmod 777 /tmp ./frameworks/hadoop/bin/hadoop fs -chmod 777 /user/hive/warehouse
修改Hive配置
cat>./frameworks/hive/conf/hive-env.sh<<EOF export HADOOP_HEAPSIZE=1024 HADOOP_HOME=/opt/workspaces/frameworks/hadoop export HIVE_CONF_DIR=/opt/workspaces/frameworks/hive/conf export HIVE_AUX_JARS_PATH=/opt/workspaces/frameworks/hive/lib EOF cat>./frameworks/hive/conf/hive-site.xml<<EOF <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://`<Docker Host IP>`:3306/hive</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> </property> <property> <name>hive.metastore.uris</name> <value>thrift://bd:9083</value> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/opt/workspaces/data/hive</value> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/opt/workspaces/data/hive</value> </property> <property> <name>hive.querylog.location</name> <value>/opt/workspaces/data/hive</value> </property> <property> <name>hive.server2.logging.operation.log.location</name> <value>/opt/workspaces/data/hive</value> </property> <property> <name>hive.querylog.location</name> <value>/opt/workspaces/frameworks/logs/hive</value> </property> <property> <name>hive.metastore.schema.verification</name> <value>false</value> </property> </configuration> EOF
cp ./frameworks/hive/conf/hive-log4j.properties.template ./frameworks/hive/conf/hive-log4j.properties
vi ./frameworks/hive/conf/hive-log4j.properties
hive.log.dir=/opt/workspaces/frameworks/logs/hive
下载mysql驱动
wget -P ./frameworks/hive/lib http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.36/mysql-connector-java-5.1.36.jar
测试发现5.1.38 需要使用SSL连接,可设置jdbc://…&userSSL=false 禁用 |
nohup ./frameworks/hive/bin/hive --service metastore >/dev/null 2>&1 &
cat>test_person.txt<<EOF tom 20 jack 24 nestor 29 EOF ./frameworks/hadoop/bin/hdfs dfs -mkdir /tmp/hivetest/ ./frameworks/hadoop/bin/hdfs dfs -put ./test_person.txt /tmp/hivetest/ ./frameworks/hive/bin/hive CREATE EXTERNAL TABLE test_person(name STRING,age INT)ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LOCATION '/tmp/hivetest'; select * from test_person;
以上是“Hive如何安装、配置及基础使用”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。