Ubuntu16.04 install apache-hive-2.3.0-bin.tar.gz
安装mysql-server
apt-get install mysql-server
下载hive
sudo wget http://mirrors.hust.edu.cn/apache/hive/hive-2.3.0/apache-hive-2.3.0-bin.tar.gz
解压hive
sudo tar zxvf apache-hive-2.3.0-bin.tar.gz
sudo mv apache-hive-2.3.0-bin.tar.gz /opt/hive
环境变量
sudo vim /etc/profile.d/hive-en.sh
export HIVE_HOME=/opt/hive
export HCAT_HOME=$HIVE_HOME/hcatalog
export HIVE_CONF=$HIVE_HOME/conf
export PATH=$PATH:$HIVE_HOME/bin
source /etc/profile.d/hive-en.sh
echo $HIVE_HOME
hive配置
cd /opt/hive/conf/
配置hive.site.xml
cp hive-default.xml.template hive.site.xml
sudo gedit hive-site.xml
配置:
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<name>hive.metastore.schema.verification</name>
<value>false</value>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
下面几个配置没有的复制到倒数第二行:
<property>
<name>datanucleus.schema.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.schema.autoCreateSchema</name>
<value>true</value>
</property>
<property>
<name>datanucleus.schema.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>datanucleus.schema.autoCreateColumns</name>
<value>true</value>
</property>
将${system:java.io.tmpdir}替换/tmp
将${system:user.name}替换root
检查jdbc包
cd /opt/hive/lib
https://dev.mysql.com/downloads/connector/j/
下载解压拷贝到
创建hive数据库
hive
show tables;
gedit /tmp/donny/hive.log 查看异常
mysql查看
新开窗口
mysql -uroot -p
show databases;
Hive实现WordCount
CREATE TABLE docs (line string);
show create table docs;
load data local inpath "/data/project/lesson-demo/assembly.xml" into table docs;
dfs -ls /user/hive/warehouse/docs;
select * from docs limit 1;
select * from docs limit 2;
select t.word, count(1) from (SELECT explode(split(line,'\s')) AS word from docs) t group by word
CREATE TABLE word_counts AS select t.word, count(1) from (SELECT explode(split(line,'\s')) AS word from docs) t group by word order by word;
posted on 2017-10-07 16:28 唐先生_DowneyJr 阅读(280) 评论(0) 编辑 收藏 举报