Hive安装(基于mariaDB)
下载安装MariaDB
下载地址为https://mariadb.com/downloads/,下载完压缩包后进行解压,如下列表
使用 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连接器
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.46</version> </dependency>
将mysql-connector-java-5.1.46.jar放入hive安装路径的lib目录下
更改hive-site.xml相关配置
<property> <name>javax.jdo.option.ConnectionURL</name> <!--jdbc:derby:;databaseName=metastore_db;create=true--> <value>jdbc:mysql://master:3306/metastore?createDatabaseIfNotExist=true</value> <description> 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. </description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>root</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>123456</value> <description>password to use against metastore database</description> </property>
初始化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;