1. Software preparation
MySQL and Hive have been deployed in the virtual machine (operating system is Linux).
Download navicat (I use navicat premium 15) on the local host (the operating system is Windows).
PS: In fact, practical sqlyog can also connect to the Hive data of the virtual machine.
Before deciding to use navicat or sqlyog, you can consider these two questions:
①The difference between MySQL and hive;
②The difference between sqlyog and navicat.
For the first question, the most direct difference I understand is: MySQL data can be stored locally, but hive data must be stored on a distributed file system. Although hive's command syntax for manipulating data is very close to MySQL, hive is not MySQL.
For the second question, the most direct difference I understand is: sqlyog only supports MySQL database, and navicat supports various databases. But hive itself is related to MySQL (I don't understand this aspect very thoroughly, I just understand it from the perspective of query language, because the two are indeed very close), so the connection to hive is to establish a MySQL connection.
2. Connection steps
2.1 Configuration file
/etc/ssh/sshd_config
document
Edit the /etc/ssh/sshd_config file in the virtual machine, and set PasswordAuthentication to yes (if there is # in front of this line, just delete #). Then use the following command to restart the sshd service (note: not ssh, but sshd).
service sshd restart
hive-site.xml
document
(The location of this file varies according to the path where hive is installed on each virtual machine. Mine is /home/hive/conf/hive-site.xml)
Edit the hive-site.xml file in the virtual machine, pay attention to the following content.
Among them, ConnectionURL
indicates the URL link of Hive data storage. It is stated in my file that it is under HiveDB;
ConnectionUserName
Indicates the logged-in user name. It is stated in my file that it is root;
ConnectionPassword
Indicates the login password. It is stated in my file that it is 123456;
metastore.warehouse.dir
Indicates the path where metadata is stored in the distributed file system (not the file path in the virtual machine). It is stated in my file that it is in /user/hive/warehouse.
2.2 Software Operation
-
Enable the cluster in the virtual machine.
-
Start Hive in the virtual machine.
-
Open navicat installed on the local host, and follow the steps below to complete the connection.
File → New Connection → MySQL.
Then the window shown in the figure below appears.
First click the SSH tab, check "Use SSH channel", and then enter the IP address of the virtual machine in "Host", keep the default 22 for "Port"; enter the user name of the virtual machine (mine is root) for "Username", and enter the password for the user login of the virtual machine in " Password " .
Then click Test Connection. At this point, only the content of the SSH tab is filled in, and an error message as shown in the figure below will appear. Leave it alone for now.
After clicking "Confirm" of this error message, you can see that navicat can connect to the SSH server above the SSH tab, but the connection from the SSH server to the database is still not successful.
Note: If the password here is wrong, you cannot connect to the SSH server, and the following window will pop up.
The following connection status will also be displayed in the tab.
Switch back to the "General" tab, choose a random name in the "Connection Name", and describe the connection (for example, this connection is used to view the hive data of the virtual machine, so I will name it "Hive" here); fill in the IP address of the virtual machine in "Host"; keep the default 3306 in "Port"; "User Name" is the user name of the database ;
Then click "Test Connection" on the "General" tab, and the following window pops up, indicating that the connection is successful.
Note: If the password in this step is wrong, the following window will pop up.
The following connection status will also be displayed in the tab.
So make sure that the user name and password of the two tabs are filled in correctly.
reference
Why use the Hive database when there is a Mysql database?