一脸懵逼学习Hive的元数据库Mysql方式安装配置

时间:2022-01-05 09:16:21

1:要想学习Hive必须将Hadoop启动起来,因为Hive本身没有自己的数据管理功能,全是依赖外部系统,包括分析也是依赖MapReduce;

2:七个节点跑HA集群模式的:

第一步:必须先将Zookeeper启动起来(HA里面好多组件都依赖Zookeeper):

  切换目录,启动Zookeeper(master节点,slaver1节点,slaver2节点):./zkServer.sh start

第二步:启动HDFS(千万不要格式化了,不然肯定报错给你):

  直接在slaver3节点启动:start-dfs.sh

第三步:启动yarn:

  直接在slaver4节点,slaver5节点启动:start-yarn.sh

第四步:使用hive:

  切换目录使用(slaver3节点):./hive

这启动过程和上篇博客启动集群的模式完全吻合,所以一定注意启动节点,以及启动节点的进程的步骤和过程哦;

 3:Hive配置Mysql方便对数据的管理(切换到hive目录下面的conf目录):

  注意:发现内置默认的metastore存在问题

    (1)换执行路径后,原来的表不存在了。

    (2)只能有一个用户访问同一个表。

    (3)配置mysql的metastore,上传两个mysql的rpm包

1)rpm -qa | grep mysql
  rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps
  rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm
  rpm -ivh MySQL-client-5.1.73-1.glibc23.i386.rpm

2)配置mysql
  /usr/bin/mysql_secure_installation
3)授权
  GRANT ALL PRIVILEGES ON test.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
  //刷新授权命令

  FLUSH PRIVILEGES;

4)安装hive和mysql完成后,将mysql的连接jar包拷贝到$HIVE_HOME/lib目录下
      如果出现没有权限的问题,在mysql授权(在安装mysql的机器上执行)
      mysql -uroot -p密码

  注意:(执行下面的语句  *.*代表所有库下的所有表   %:任何IP地址或主机都可以连接)
      GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
      FLUSH PRIVILEGES;

一脸懵逼学习Hive的元数据库Mysql方式安装配置

 然后将hive-default.xml.template复制一份为hive-site.xml

[root@slaver3 conf]# cp hive-default.xml.template hive-site.xml

一脸懵逼学习Hive的元数据库Mysql方式安装配置

 要想使用Mysql对Hive的元数据进行管理,需要在hive-site.xml配置一下(由于要修改hive-site.xml,里面内容比较多,可以将复制的删除了,新建一个空白的文件):

[root@slaver3 conf]# vim hive-site.xml
一脸懵逼学习Hive的元数据库Mysql方式安装配置

然后对内容进行编辑,编辑内容就是Mysql的驱动,账号,密码,路径,如下所示:

如果数据库不存在自动创建:?createDatabaseIfNotExist=true

如果hive数据库不存在就创建一个:hive?createDatabaseIfNotExist=true

<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://slaver3:3306/hive?createDatabaseIfNotExist=true</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>

 4:Centos安装mysql:

  如果安装好了,直接登陆mysql -u账号 -p密码;

  如果没安装先安装;

  如果不知道是否安装可以whereis mysql查看一下mysql是否安装(查看路径的);

  如果查找mysql路径登陆不了就先将mysql删除了,然后安装mysql;思路就是这个,百度方法也很多,我也是边学习边百度,大家都互相脑补吧。

 rpm方式安装mysql(包括安装mysql的客户端和服务器端),如下所示,首先将mysql的下载好客户端和服务器端上传到虚拟机上面:

一脸懵逼学习Hive的元数据库Mysql方式安装配置

使用rpm命令安装:
  rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm
注意:命令解释:i:install v:显示详情 h:显示进度条

下面分别安装服务器端和客户端:
一脸懵逼学习Hive的元数据库Mysql方式安装配置

如果遇到如下所示的错误:

解决方法如下所示,把之前的Mysql版本删除了:

1 [root@slaver1 package]# yum -y remove mysql-libs-5.1.66*

错误如下所示:

 1 [root@slaver1 package]# rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm 
2 Preparing... ########################################### [100%]
3 file /usr/share/mysql/charsets/README from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
4 file /usr/share/mysql/charsets/Index.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
5 file /usr/share/mysql/charsets/armscii8.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
6 file /usr/share/mysql/charsets/ascii.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
7 file /usr/share/mysql/charsets/cp1250.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
8 file /usr/share/mysql/charsets/cp1251.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
9 file /usr/share/mysql/charsets/cp1256.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
10 file /usr/share/mysql/charsets/cp1257.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
11 file /usr/share/mysql/charsets/cp850.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
12 file /usr/share/mysql/charsets/cp852.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
13 file /usr/share/mysql/charsets/cp866.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
14 file /usr/share/mysql/charsets/dec8.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
15 file /usr/share/mysql/charsets/geostd8.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
16 file /usr/share/mysql/charsets/greek.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
17 file /usr/share/mysql/charsets/hebrew.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
18 file /usr/share/mysql/charsets/hp8.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
19 file /usr/share/mysql/charsets/keybcs2.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
20 file /usr/share/mysql/charsets/koi8r.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
21 file /usr/share/mysql/charsets/koi8u.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
22 file /usr/share/mysql/charsets/latin1.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
23 file /usr/share/mysql/charsets/latin2.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
24 file /usr/share/mysql/charsets/latin5.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
25 file /usr/share/mysql/charsets/latin7.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
26 file /usr/share/mysql/charsets/macce.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
27 file /usr/share/mysql/charsets/macroman.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
28 file /usr/share/mysql/charsets/swe7.xml from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
29 file /usr/share/mysql/czech/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
30 file /usr/share/mysql/danish/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
31 file /usr/share/mysql/dutch/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
32 file /usr/share/mysql/english/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
33 file /usr/share/mysql/estonian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
34 file /usr/share/mysql/french/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
35 file /usr/share/mysql/german/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
36 file /usr/share/mysql/greek/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
37 file /usr/share/mysql/hungarian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
38 file /usr/share/mysql/italian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
39 file /usr/share/mysql/japanese/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
40 file /usr/share/mysql/korean/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
41 file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
42 file /usr/share/mysql/norwegian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
43 file /usr/share/mysql/polish/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
44 file /usr/share/mysql/portuguese/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
45 file /usr/share/mysql/romanian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
46 file /usr/share/mysql/russian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
47 file /usr/share/mysql/serbian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
48 file /usr/share/mysql/slovak/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
49 file /usr/share/mysql/spanish/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
50 file /usr/share/mysql/swedish/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686
51 file /usr/share/mysql/ukrainian/errmsg.sys from install of MySQL-server-5.1.73-1.glibc23.i386 conflicts with file from package mysql-libs-5.1.66-2.el6_3.i686

然后操作如下所示:

一脸懵逼学习Hive的元数据库Mysql方式安装配置

使用命令初始化mysql数据库(用户名和密码设置):

查看安装过程中提醒的信息,主要告诉我们如何初始化数据库:

[root@slaver3 hadoop]# rpm -ivh MySQL-server-5.1.73-1.glibc23.i386.rpm 
Preparing... ########################################### [
100%]
1:MySQL-server ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER
!
To
do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h slaver3 password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by
default. This is
strongly recommended
for production servers.

See the manual
for more instructions.

Please report any problems with the
/usr/bin/mysqlbug script!

Starting MySQL. SUCCESS
!
[root@slaver3 hadoop]# rpm
-ivh MySQL-client-5.1.73-1.glibc23.i386.rpm
Preparing... ########################################### [
100%]
1:MySQL-client ########################################### [100%]
[root@slaver3 hadoop]#

 输入如下命令初始化mysql:

Alternatively you can run:(翻译:或者你可以跑)
/usr/bin/mysql_secure_installation

按照提示安装:
Enter current password for root (enter for none):回车
Set root password? [Y/n]输入 Y
New password:输入新的密码
Re-enter new password:再输一遍密码
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

 我的操作如下所示:

[root@slaver3 hadoop]# /usr/bin/mysql_secure_installation




NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE
! PLEASE READ EACH STEP CAREFULLY!


In order to log into MySQL to secure it, we
'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password
for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password
? [Y/n] y
New password:
Re
-enter new password:
Password updated successfully
!
Reloading privilege tables..
... Success
!


By
default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created
for
them. This
is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users
? [Y/n] y
... Success
!

Normally, root should only be allowed to connect
from 'localhost'. This
ensures that someone cannot guess at the root password
from the network.

Disallow root login remotely
? [Y/n] n
... skipping.

By
default, MySQL comes with a database named 'test' that anyone can
access. This
is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it
? [Y/n] y
- Dropping test database...
... Success
!
- Removing privileges on test database...
... Success
!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now
? [Y/n] y
... Success
!

Cleaning up...



All done
! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks
for using MySQL!


[root@slaver3 hadoop]#

 下面使用客户端登录:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

5:mysql安装成功以后就可以继续学习Hive了,是不是很开心,反正我挺开心的:

在hive.site.xml里面写如下内容:

一脸懵逼学习Hive的元数据库Mysql方式安装配置

<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://slaver3:3306/hive?createDatabaseIfNotExist=true</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>
<!--自己mysql的密码哦--><value>123456</value>
</property>
</configuration>

一脸懵逼学习Hive的元数据库Mysql方式安装配置

 然后运行一下hive,如下所示:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

启动的时候如果出现下面的这个错误,都真是太不小心了:

 1 [root@slaver1 bin]# ./hive
2 [Fatal Error] hive-site.xml:5:2: The markup in the document following the root element must be well-formed.
3 18/01/20 05:52:01 FATAL conf.Configuration: error parsing conf file:/home/hadoop/soft/hive-0.13.1-cdh5.3.6/conf/hive-site.xml
4 org.xml.sax.SAXParseException; systemId: file:/home/hadoop/soft/hive-0.13.1-cdh5.3.6/conf/hive-site.xml; lineNumber: 5; columnNumber: 2; The markup in the document following the root element must be well-formed.
5 at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
6 at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
7 at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
8 at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2432)
9 at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2420)
10 at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2488)
11 at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2454)
12 at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2361)
13 at org.apache.hadoop.conf.Configuration.get(Configuration.java:1188)
14 at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:1526)
15 at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1471)
16 at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:74)
17 at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:58)
18 at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:649)
19 at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:633)
20 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
22 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
23 at java.lang.reflect.Method.invoke(Method.java:606)
24 at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
25 at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
26 Exception in thread "main" java.lang.RuntimeException: org.xml.sax.SAXParseException; systemId: file:/home/hadoop/soft/hive-0.13.1-cdh5.3.6/conf/hive-site.xml; lineNumber: 5; columnNumber: 2; The markup in the document following the root element must be well-formed.
27 at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2597)
28 at org.apache.hadoop.conf.Configuration.loadResources(Configuration.java:2454)
29 at org.apache.hadoop.conf.Configuration.getProps(Configuration.java:2361)
30 at org.apache.hadoop.conf.Configuration.get(Configuration.java:1188)
31 at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:1526)
32 at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1471)
33 at org.apache.hadoop.hive.common.LogUtils.initHiveLog4jCommon(LogUtils.java:74)
34 at org.apache.hadoop.hive.common.LogUtils.initHiveLog4j(LogUtils.java:58)
35 at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:649)
36 at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:633)
37 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
38 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
39 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
40 at java.lang.reflect.Method.invoke(Method.java:606)
41 at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
42 at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
43 Caused by: org.xml.sax.SAXParseException; systemId: file:/home/hadoop/soft/hive-0.13.1-cdh5.3.6/conf/hive-site.xml; lineNumber: 5; columnNumber: 2; The markup in the document following the root element must be well-formed.
44 at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
45 at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
46 at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:150)
47 at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2432)
48 at org.apache.hadoop.conf.Configuration.parse(Configuration.java:2420)
49 at org.apache.hadoop.conf.Configuration.loadResource(Configuration.java:2488)
50 ... 15 more
51 [root@slaver1 bin]#

记得加上第一行和最后一行哦:

一脸懵逼学习Hive的元数据库Mysql方式安装配置

将mysql的驱动包加到hive的lib里面:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

然后再试hive查看数据表是否成功:

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

然后还报这个错误,可是我明明将mysql驱动包上传到hive的lib目录下面了:

 百度一下呗,瞄到可能是hive-site.xml的配置出错,想想自己刚才安装的mysql,看了一下,是自己讲密码123456写成了root了,修改即可:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

 然后创建数据表,自己明明知道一些节点的进程没有启动,还去创建数据表,然后就卡着不动了,然后ctrl+c结束,然后启动节点的进程,然后再创建数据表:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

启动节点的进程,根据自己那个节点没启动,来启动你节点的进程,注意启动顺序,如果你的nodeManager没有启动,先将yarn关闭,stop-yarn-sh,如果你的slaver3的namenode没有启动,先将dfs关闭了,stop-dfs.sh,然后再启动dfs进程,start-dfs.sh,然后启动yarn,start-yarn.sh,总之根据你的节点进程的启动情况来决定你如何启动你的节点的进程:

hive> create table tb_user(id int,name string);
FAILED: Execution Error,
return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Got exception: org.apache.hadoop.ipc.RemoteException org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /user/hive/warehouse/tb_user. Name node is in safe mode.
The reported blocks
0 needs additional 27 blocks to reach the threshold 0.9990 of total blocks 27.
The number of live datanodes
0 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkNameNodeSafeMode(FSNamesystem.java:
1211)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInt(FSNamesystem.java:
3590)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:
3566)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.mkdirs(NameNodeRpcServer.java:
754)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.mkdirs(ClientNamenodeProtocolServerSideTranslatorPB.java:
558)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$
2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:
585)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:
928)
at org.apache.hadoop.ipc.Server$Handler$
1.run(Server.java:2013)
at org.apache.hadoop.ipc.Server$Handler$
1.run(Server.java:2009)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:
415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:
1556)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:
2007)
Caused by: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory
/user/hive/warehouse/tb_user. Name node is in safe mode.
The reported blocks
0 needs additional 27 blocks to reach the threshold 0.9990 of total blocks 27.
The number of live datanodes
0 has reached the minimum number 0. Safe mode will be turned off automatically once the thresholds have been reached.
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkNameNodeSafeMode(FSNamesystem.java:
1207)
...
13 more
)
hive
>

然后一想,上篇博客自己记录过,哈哈哈哈,防火墙的原因,先关防火墙,先从这种解决问题的方向为入口,不然都是大问题了,然后七台机器的防火墙都关了:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

防火墙一关闭,执行创建数据表命令一点也不卡了,哈哈哈哈,然后验证自己的mysql是否安装成功,退出hive,去其他目录运行hive,验证自己创建的数据表永久存在了:

 一脸懵逼学习Hive的元数据库Mysql方式安装配置

OK,大功告成了;开森不开森,加油吧,骚年,努力的人还在努力。