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;
