安装mysql
(在slave2上安装mysql)
wget http:
//dev
.mysql
.com
/get
/mysql
-community
-release
-el7
-5
.noarch
.rpm
rpm
-ivh mysql
-community
-release
-el7
-5
.noarch
.rpm
yum
-y install mysql
-community
-server
/usr
/sbin
/mysqld
--initialize
-insecure
--user=mysql
systemctl daemon
-reload
/usr
/sbin
/mysql
--user=mysql &
systemctl enable mysqld
set password
for root@localhost = password
('123456');
create user
'root'@
'%' identified by
'123456';
grant all privileges on
*.* to
'root'@
'%' identified by
'123456' with grant option
;
flush privileges
;
create database hive
;
hive部署
下载解压:
mkdir
-p
/usr
/hive
tar
-zxvf
.....
修改master和slave1的环境变量(/etc/profile) 之后source /etc/profile
export HIVE_HOME=
/usr
/hive
/apache
-hive
-2
.1
.1
-bin
export PATH=
$PATH/sbin:
$HIVE_HOME/bin
hive-env.sh
cp hive
-env
.sh
.template hive
-env
.sh
HADOOP_HOME=
/usr
/hadoop
/hadoop
-2
.7
.3
export HIVE_CONF_DIR=
/usr
/hive
/apache
-hive
-2
.1
.1
-bin
/conf
export HIVE_AUX_JARS_PATH=
/usr
/hive
/apache
-hive
-2
.1
.1
-bin
/lib
元数据配置到MySql
拷贝驱动:mysql-connector-java是MySQL的JDBC驱动包 放到$HIVEHOME/lib目录下将hive的所有配置信息拷贝到客户端master机器服务器端配置hive-site.xml 在conf目录下新建hive-site.xml文件添加如下内容:
<configuration>
<property>
<name>hive
.metastore
.warehouse
.dir<
/name>
<value>
/user
/hive_remote
/warehouse<
/value>
<
/property>
<
!-
- 连接元数据库的连接信息
-->
<property>
<name>javax
.jdo
.option
.ConnectionURL<
/name>
<value>jdbc:mysql:
//slave2:3306
/hive?createDatabaseIfNotExist=true&
;useSSL=false&
;useUnicode=false<
/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>123456<
/value>
<
/property>
<property>
<name>hive
.cli.print
.header<
/name>
<value>true<
/value>
<description>Whether to print the names of the columns in query output
.<
/description>
<
/property>
<property>
<name>hive
.cli.print
.current
.db<
/name>
<value>true<
/value>
<description>Whether to include the current database in the Hive prompt
.<
/description>
<
/property>
<
/configuration>
客户端配置hive-site.xml 在conf目录下新建hive-site.xml文件添加如下内容:
<configuration>
<
!-
- hive产生的元数据存放位置
-->
<property>
<name>hive
.metastore
.warehouse
.dir<
/name>
<value>
/user
/hive_remote
/warehouse<
/value>
<
/property>
<
!-
- 使用本地服务连接hive,默认为true-
->
<property>
<name>hive
.metastore
.local<
/name>
<value>false<
/value>
<
/property>
<
!-
- 连接数据库驱动
-->
<property>
<name>hive
.metastore
.uris<
/name>
<value>thrift:
//slave1:9083<
/value>
<
/property>
<property>
<name>hive
.cli.print
.header<
/name>
<value>true<
/value>
<description>Whether to print the names of the columns in query output
.<
/description>
<
/property>
<property>
<name>hive
.cli.print
.current
.db<
/name>
<value>true<
/value>
<description>Whether to include the current database in the Hive prompt
.<
/description>
<
/property>
<
/configuration>
删除客户端中Hadoop中自带的低版本jline,具体路径为:$HADOOP_HOME/share/hadoop/yarn/lib/jline.x.jar
启动hive
初始化数据库,在slave1上执行以下命令格式化hive并在后台开启metastore服务schematool -dbType mysql -initSchema启动hive service hive --service metastore &在master上执行以下命令启动客户端:hive日志文件存放路径为:hive-log4j.properties.template