Hive远程模式
1下载并安装MySQL并启动服务(我的MySQL安装在宿主机Windows下)
2在MySQL中建立数据库用于存放Hive元数据,并为为数据库建立账号,并赋予需要的权限
3下载并解压Hive
4为Hive配置环境变量
5配置hive-config.sh文件
6配置hive-site.xml文件,并配置MySQL连接信息
7把mysql-connector-java-x.x.x.jar 复制到Hive的lib目录下
8启动Hive
9验证Hive是否启动成功
格式:grant all privileges on 数据库.* to 用户名@登录主机 identified by "密码"
给远程权限
grant all privileges on *.* to hive@'%' identified by "hive" ;
给本地权限
grant all privileges on*.* to hive@localhost identified by "hive";
验证hive用户权限:
bin/mysql -u hive
先复制默认的,然后再修改
cp /home/hadoop/hive/conf/hive-default.xml.template /home/hadoop/hive/conf/hive-site.xml
然后修改下列属性
<!-- 配置 metastore -->
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.metastore.local</name>
<value>false</value>
</property>
<!-- 配置mysql连接-->
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.80.100:3306/hive?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=UTF-8</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://127.0.0.1:9083</value>
</property>
<!-- 配置web UI服务-->
<property>
<name>hive.hwi.listen.host</name>
<value>master</value>
</property>
<property>
<name>hive.hwi.listen.port</name>
<value>9999</value>
</property>
<property> <name>hive.hwi.war.file</name> <value>/lib/hive-hwi-0.12.0.war</value>
</property>
<!--从这里开始下面的可以不要-->
<property>
<name>hive.stats.dbclass</name>
<value>jdbc:mysql</value>
<description>The default database that stores temporary hive statistics.</description>
</property>
<property>
<name>hive.stats.jdbcdriver</name>
<value>com.mysql.jdbc.Driver</value>
<description>The JDBC driver for the database that stores temporary hive statistics.</description>
</property>
<property>
<name>hive.stats.dbconnectionstring</name>
<value>jdbc:mysql://192.168.80.1:3306/hivestat?useUnicode=true&characterEncoding=utf-8$amp;user=hive&password=hive$amp;createDatabaseIfNotExist=true</value>
<description>The default connection string for the database that stores temporary hive statistics.</description>
</property>
bin/hive --service metastore &
远程服务启动方式:
bin/hive --service hiveserver &
命令行启动方式:
bin/hive -- service cli
web启动方式:
bin/hive -- service hwi
验证是否成功: http://master:9999/hwi/
然后启动hive
bin/hive