文章目录
安装前准备
1 净化MySQL环境
【ROOT用户】检查是否安装过mysql
[root@master ~]# rpm -qa | grep -i mysql
如果以前安装过,那么需要卸载MySQL相关文件。
- 分别卸载
删除mysql目录 - 删除MySQL相应文件
命令:find / -name mysql
2 系统、软件版本
老生常谈,对应好Linux系统、空间,mysql版本,hadoop版本。
linux版本 | Hadoop版本 | mysql版本 |
---|---|---|
centos7-x86_64 | hadoop-2.7.7.tar | mysql-5.7.19-linux-glibc2.12-x86_64 |
安装hive
1.上载安装包
rz命令从本地丢到虚拟机,或者sftp方式都可以(用安装用户丢进去)
两个包,一个hive包,一个mysql包
[tyhawk@slave ~]$ rz
rz waiting to receive.
开始 zmodem 传输。 按 Ctrl+C 取消。
100% 90659 KB 8241 KB/s 00:00:11 0 Errorss
[tyhawk@slave ~]$ ll
total 90660
-rw-r--r--. 1 tyhawk tyhawk 92834839 Mar 20 12:12 apache-hive-1.2.1-bin.tar.gz
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Desktop
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Documents
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Downloads
-rw-r--r--. 1 tyhawk tyhawk 990927 Mar 20 12:11 mysql-connector-java-5.1.40-bin.jar
drwxr-xr-x. 10 tyhawk tyhawk 161 Mar 17 23:11 hadoop-2.7.7
drwxrwxr-x. 4 tyhawk tyhawk 37 Mar 17 23:11 hadoopdata
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Music
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Pictures
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Public
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Templates
drwxr-xr-x. 2 tyhawk tyhawk 6 Mar 14 16:57 Videos
2.网络获取mysql的yum源
[tyhawk@slave ~]$ wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
3.查看下载源中包含的rpm包
[tyhawk@slave ~]$ rpm -qpl mysql57-community-release-el7-7.noarch.rpm
warning: mysql57-community-release-el7-7.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
/etc/yum.repos.d/mysql-community-source.repo
/etc/yum.repos.d/mysql-community.repo
4. 安装rpm包
【root用户】
4.1解压mysql包
[root@slave tyhawk]# rpm -ivh mysql57-community-release-el7-7.noarch.rpm
warning: mysql57-community-release-el7-7.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:mysql57-community-release-el7-7 ################################# [100%]
4.2安装mysql
[root@slave tyhawk]# yum install -y mysql-community-server
5.获取临时密码
【确认环境】
hadoop集群启动命令
[tyhawk@master ~]$ start-all.sh
mysqld服务启动命令
[root@master log]# /bin/systemctl start mysqld.service
查找初始密码
[root@slave tyhawk]# grep “password” /var/log/mysqld.log
2019-03-20T12:41:06.642690Z 1 [Note] A temporary password is generated for root@localhost: a/y4tcsa/0Rq
6.设置密码
1.登录
[root@slave tyhawk]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2.设置安全级别
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
3.设置密码长度
mysql> set global validate_password_length=8;
Query OK, 0 rows affected (0.01 sec)
4.设置密码
mysql> set password=password('rootroot');
Query OK, 0 rows affected, 1 warning (0.00 sec)
7.配置hive
1.创建数据库
mysql> create database hive;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hive |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
2.创建hadoop用户
mysql> grant all on *.* to hadoop@'%' identified by "rootroot";
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all on *.* to hadoop@'localhost' identified by 'rootroot';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> grant all on *.* to hadoop@'master' identified by 'rootroot';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
3.安装Hive
【切换到普通用户下】
解压Hive安装包
[tyhawk@master ~]$ tar -zxvf apache-hive-1.2.1-bin.tar.gz
4.配置参数文件
在conf目录下创建新文件hive-site.xml
[tyhawk@slave ~]$ cd apache-hive-1.2.1-bin/conf/
[tyhawk@slave ~]$ vi hive-site.xml
添加内容:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> //类型,默认的
<configuration>
<property>
<name>hive.metastore.local</name> //刚刚创建的数据库名称
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://master:3306/hive?characterEncoding=UTF-8</value> //要连接的节点的locolhost
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hadoop</value> //用户名
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop</value> //密码
</property>
</configuration>
5 添加依赖包
将驱动driver的jar包添加到hive里
[tyhawk@slave conf]$ cd ../lib
[tyhawk@slave lib]$ pwd
/home/tyhawk/apache-hive-1.2.1-bin/lib
[tyhawk@slave lib]$ cp ~/mysql-connector-java-5.1.40-bin.jar ./
6配置环境变量
[tyhawk@slave lib]$ cd
[tyhawk@slave ~]$ vi .bash_profile
添加以下内容
export HIVE_HOME=/home/tyhawk/apache-hive-1.2.1-bin
export PATH=
P
A
T
H
:
PATH:
PATH:HIVE_HOME/bin
[tyhawk@slave ~]$ source .bash_profile
启动并验证Hive
1.启动Hive
[tyhawk@slave ~]$ hive
19/03/20 21:09:34 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
Logging initialized using configuration in jar:file:/home/tyhawk/apache-hive-1.2.1-bin/lib/hive-common-1.2.1.jar!/hive-log4j.properties
Wed Mar 20 21:09:36 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:37 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:37 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:38 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:38 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:38 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:38 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Wed Mar 20 21:09:38 CST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
hive>