Hive安装(基于mariaDB)
下载安装MariaDB
使用 rpm -ivh MariaDB-gssapi-server-10.4.7-1.el7.centos.x86_64.rpm --nodeps --force进行安装服务端
使用rpm -ivh MariaDB-client-10.4.7-1.el7.centos.x86_64.rpm --nodeps --force进行安装客户端
启动mariadb,启动命令 service mysql start
启动客户端,默认没有用户名和密码,使用mysqladmin -u root -p password ex设置用户名密码,输入命令后进行回车,再输入密码即可
配置MariaDB作为hive的元数据存储库
登陆mysql,将mysql.user表下的host改为通配ip
update mysql.user set host='%' where host='localhost';
flush privileges;
使用maven下载mysql连接器
mysql
mysql-connector-java
5.1.46
将mysql-connector-java-5.1.46.jar放入hive安装路径的lib目录下
更改hive-site.xml相关配置
javax.jdo.option.ConnectionURL
jdbc:mysql://master:3306/metastore?createDatabaseIfNotExist=true
JDBC connect string for a JDBC metastore.
To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
javax.jdo.option.ConnectionUserName
root
username to use against metastore database
javax.jdo.option.ConnectionPassword
123456
password to use against metastore database
初始化hive元数据库使用./schematool -dbType mysql -initSchema指定mariadb作为hive的元数据存储库
登陆mariadb进行验证,输入show databases;命令发现已经存在元数据库“metastore”,并且该库下已经存在元数据表了。
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| metastore |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.001 sec)
错误处理
错误原因
解决方案
该错误引起原因可能有两方面,连接方式和用户权限问题,解决步骤如下 (1): 将auth_socket连接方式改为mysql_native_password。重启mysql服务, 命令如下
update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root';
flush privileges;
service mysql restart
(2):mysql root用户权限问题,修改root权限即可
mysql> grant all privileges on *.* to root@'localhost' identified by '密码';
mysql> flush privileges;
参考文章