大数据集群搭建—《hive篇》 --菜鸟小回
- 创建上传解压
- 安装好mysql,需要在mysql里面创建一个数据集hive
- vi /etc/profile
vi /etc/profile
//添加
export HIVE_HOME=/opt/hive/apache-hive-2.3.3-bin
export PATH=$PATH:$HIVE_HOME/bin
//刷新环境变量
source /etc/profile
4. 测试环境变量:hive --version
5. 创建并编辑配置hive-site.xml
cd /opt/hive/apache-hive-2.3.3-bin/conf/
vi hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.80.128: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>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>HBQ521521cf*</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>
- 把mysql的jar包放到hive/lib目录下
- 启动hive(先启动zookeeper和hadoop)
cd /opt/hive/apache-hive-2.3.3-bin/bin
//初始化
./schematool -initSchema -dbType mysql
./hive
- 附:
- 创建表:
create table t1(id int,name String,age int ) row format delimited fields terminated by ',';
- 创建分区表:
create table t3(id int,name String,age int) partitioned by(stuid int ) row format delimited fields terminated by ',';