Hive
安装步骤:
JAVA实现读取文件
[外链图片转存失败(img-KVxtKKCX-1567241930110)(http://weishichun.gitee.io/picture/blog_pic/1566972280887.png)]
但是使用hive会更简单
[外链图片转存失败(img-HFM8LoNS-1567241930111)(http://weishichun.gitee.io/picture/blog_pic/1566973086046.png)]
hive能够把文件变成表,只保存表结构存在数据库mysql中,但是数据还是在文件中
文件----->database---->table
----->deby------>mysql(保存表结构信息)
安装
1.先解压完然后把数据库连接驱动放到hive110/lib中
tar zxvf hive-1.1.0-cdh5.14.2.tar.gz
mv hive-1.1.0-cdh5.14.2 /opt/bigdata/hive110
[外链图片转存失败(img-rDRWbE0d-1567241930111)(http://weishichun.gitee.io/picture/blog_pic/1566974239510.png)]
2.配置env文件
cd /opt/bigdata/hive110/conf
cp hive-env.sh.template hive-env.sh
vi hive-env.sh
[外链图片转存失败(img-ljOOpitP-1567241930112)(http://weishichun.gitee.io/picture/blog_pic/1566974635756.png)]
[外链图片转存失败(img-FgDCE9Gj-1567241930112)(http://weishichun.gitee.io/picture/blog_pic/1566974798217.png)]
3.配置site.xml
放到hive10/conf下
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://169.254.211.100:3306/hive?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
</configuration>
[外链图片转存失败(img-F5jjumPY-1567241930112)(http://weishichun.gitee.io/picture/blog_pic/1566995961516.png)]4.配置环境变量
vi /etc/proflie
source /etc/profile
[外链图片转存失败(img-7O5muTB2-1567241930112)(http://weishichun.gitee.io/picture/blog_pic/1566975855056.png)]
5.进入bin中运行hive
schematool -initSchema -dbType mysql
hive
create table userinfos(userid int);
[外链图片转存失败(img-zGIKOd24-1567241930112)(http://weishichun.gitee.io/picture/blog_pic/1566978603304.png)]
6.使用hive插数据
insert into userinfos values(1);
7.使用hadoop查看数据
hdfs dfs -text /user/hive/warehouse/userinfos/000000_0
s values(1);
7.使用hadoop查看数据
```shell
hdfs dfs -text /user/hive/warehouse/userinfos/000000_0