环境初始化
- 预先安装mysql
解压安装包
安装Hive
1.解压
tar -zxf apache-hive-3.1.0-bin.tar.gz
- Set the environment variable HIVE_HOME to point to the installation directory(配置环境变量)
#Set the environment variable HIVE_HOME
export HIVE_HOME="/usr/lib/hive-current"
if [[ -n $HIVE_HOME ]]; then
export PATH=$HIVE_HOME/bin:$PATH
fi
编辑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.ConnectionUserName</name>
<value>gggg</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://mysql_host/hive?createDatabaseIfNotExist=true&characterEncoding=UTF-8</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
<property>
<name>hive.server2.webui.host</name>
<value>192.168.0.50</value>
</property>
<property>
<name>hive.server2.webui.port</name>
<value>10002</value>
</property>
</configuration>
hive-site.xml (客户端)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.uris</name>
<value>thrift://master:9083</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
<description>this is local store</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
</property>
</configuration>
启动HIVE
#run metastore
hive --service metastore &
#run hiveserver2
hive --service hiveserver2 --hiveconf hive.root.logger=INFO,console &
客户端连接
键入 hive
或
beeline
bin/beeline -u jdbc:hive2://master:10000
用户名/密码:(hadoop/ )