How to install Hive on Hadoop and configure it with MySQL?
To install Hive on Hadoop and configure it with MySQL, you can follow the steps below:
Install Hive.
Download Hive and extract it to the desired directory.
Set the `HIVE_HOME` environment variable to point to the root directory of Hive.
Set the `PATH` environment variable to include `$HIVE_HOME/bin`.
2. Set up Hive:
Duplicate the configuration template file of Hive.
cp $HIVE_HOME/conf/hive-default.xml.template $HIVE_HOME/conf/hive-site.xml
Edit the `hive-site.xml` file and configure the following properties:
<!-- 设置 Hive 的数据库元数据存储位置 --><property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_metastore?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore.</description>
</property>
<!-- 设置使用的 JDBC 驱动程序 -->
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore.</description>
</property>
<!-- 设置连接 MySQL 数据库的用户名和密码 -->
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>your_mysql_username</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>your_mysql_password</value>
<description>Password to use against metastore database</description>
</property>
Installing and setting up MySQL:
Install MySQL database and make sure the database server is running.
Create a new database for metadata storage in Hive.
mysql -u your_mysql_username -p
CREATE DATABASE hive_metastore;
Create a new user for Hive and grant them the necessary permissions.
GRANT ALL PRIVILEGES ON hive_metastore.* TO 'your_mysql_username'@'localhost'IDENTIFIED BY '
your_mysql_password';
FLUSH PRIVILEGES;
Initialize Hive metadata.
Run the following command to initialize Hive’s metadata storage:
schematool -dbType mysql -initSchema
After completing the above steps, Hive will be successfully configured with the MySQL database. You can use Hive for data analysis and querying operations.