Use navicat to connect to the hive of the virtual machine

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_configdocument

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.xmldocument

(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.

insert image description here

Among them, ConnectionURLindicates the URL link of Hive data storage. It is stated in my file that it is under HiveDB;

ConnectionUserNameIndicates the logged-in user name. It is stated in my file that it is root;

ConnectionPasswordIndicates the login password. It is stated in my file that it is 123456;

metastore.warehouse.dirIndicates 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

  1. Enable the cluster in the virtual machine.

  2. Start Hive in the virtual machine.

  3. Open navicat installed on the local host, and follow the steps below to complete the connection.

File → New Connection → MySQL.

insert image description here

Then the window shown in the figure below appears.

insert image description here

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.

insert image description here

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.

insert image description here

Note: If the password here is wrong, you cannot connect to the SSH server, and the following window will pop up.
insert image description here
The following connection status will also be displayed in the tab.
insert image description here

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 ;

insert image description here

Then click "Test Connection" on the "General" tab, and the following window pops up, indicating that the connection is successful.

insert image description here

Note: If the password in this step is wrong, the following window will pop up.
insert image description here
The following connection status will also be displayed in the tab.

insert image description here
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?

The difference between sqlyog and navicat

When Navicat connects to the MySQL of the virtual machine, it prompts "Password authentication failed"

Navicat connects to Hive

Guess you like

Origin blog.csdn.net/Mocode/article/details/124958308