Database Reference
In-Depth Information
[hadoop@hc1nn sqoop]$ cat import.txt
1 import
2 --connect
3 jdbc:mysql://hc1nn/sqoop
4 --username
5 sqoop
6 --password
7 xxxxxxxxxx
8 --table
9 rawdata
The username and password options in the Sqoop options file provide account access to MySQL, while the table
option shows that the table to be accessed is called “rawdata.” Given that the Sqoop options file describes how to
connect to the relational database that has been set up, the database itself should now be checked.
For MySQL on the server hc1nn to be accessed from all data nodes, the access must be granted within
MySQL—otherwise, you will see errors like this:
14/07/19 20:20:28 ERROR manager.SqlManager: Error executing statement:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user
'sqoop'@'localhost' to database 'sqoop.rawdata'
To grant that access, you first log in as the root user. On the MySQL instance on the server hc1nn that contains the
example database “sqoop,” for instance, you log into the database as the root user with the line:
mysql -u root -p
Then you grant access to the database access user (in this case, called “sqoop”) on all servers, as follows:
GRANT ALL PRIVILEGES ON sqoop.rawdata to 'sqoop'@'hc1r1m1';
GRANT ALL PRIVILEGES ON sqoop.rawdata to 'sqoop'@'hc1r1m2';
GRANT ALL PRIVILEGES ON sqoop.rawdata to 'sqoop'@'hc1r1m3';
Also, you set password access for all the remote database users. (The actual passwords here have been crossed
out, but the syntax to use is shown.)
SET PASSWORD FOR 'sqoop'@'hc1nn' = PASSWORD('Xxxxxxxxxxxx');
SET PASSWORD FOR 'sqoop'@'hc1r1m1' = PASSWORD('Xxxxxxxxxxxx');
SET PASSWORD FOR 'sqoop'@'hc1r1m2' = PASSWORD('Xxxxxxxxxxxx');
SET PASSWORD FOR 'sqoop'@'hc1r1m3' = PASSWORD('Xxxxxxxxxxxx');
Finally, you flush the privileges in MySQL in order to make the changes take effect:
FLUSH PRIVILEGES;
Now that the options file has been created, and the MySQL database access has been checked, it is time to
attempt to use Sqoop. The Sqoop command that executes the import by using the options file is as follows:
sqoop --options-file ./import.txt --table sqoop.rawdata -m 1
Search WWH ::




Custom Search