Release Notes
Announcements
Security Announcements
/usr/local/service/ directory of the CVM instance for the EMR cluster.root, and the password is the one you set when creating the EMR cluster. Once the correct credentials are entered, you can enter the command line interface.[root@172 ~]# su hadoop[hadoop@172 ~]# cd /usr/local/service/sqoop
[hadoop@172 sqoop]$ mysql -h $mysqlIP –pEnter password:
mysql> use test;Database changedmysql> create table sqoop_test(id int not null primary key auto_increment, title varchar(64), time timestamp, content varchar(255));Query ok , 0 rows affected(0.00 sec)
mysql> insert into sqoop_test values(null, 'first', now(), 'hdfs');Query ok, 1 row affected(0.00 sec)mysql> insert into sqoop_test values(null, 'second', now(), 'mr');Query ok, 1 row affected (0.00 sec)mysql> insert into sqoop_test values(null, 'third', now(), 'yarn');Query ok, 1 row affected(0.00 sec)
Mysql> select * from sqoop_test;+----+--------+---------------------+---------+| id | title | time | content |+----+--------+---------------------+---------+| 1 | first | 2018-07-03 15:29:37 | hdfs || 2 | second | 2018-07-03 15:30:57 | mr || 3 | third | 2018-07-03 15:31:07 | yarn |+----+--------+---------------------+---------+3 rows in set (0.00 sec)
Mysql> exit;
[hadoop@172 sqoop]$ bin/sqoop-import --connect jdbc:mysql://$mysqlIP/test --username root-P --table sqoop_test --target-dir /sqoop
/sqoop folder does not exist before the command is run; otherwise, a failure will occur.[hadoop@172 sqoop]$ hadoop fs -cat /sqoop/*1, first, 2018-07-03 15:29:37.0,hdfs2, second, 2018-07-03 15:30:57.0,mr3, third, 2018-07-03 15:31:07.0,yarn
[hadoop@172 sqoop]$ mysql -h $mysqlIP –pEnter password:mysql> use test;Database changedmysql> create table sqoop_test_back(id int not null primary key auto_increment, title varchar(64), time timestamp, content varchar(255));Query ok , 0 rows affected(0.00 sec)
mysql> show tables;+-----------------+| Tables_in_test |+-----------------+| sqoop_test || sqoop_test_back |+-----------------+2 rows in set (0.00 sec)mysql> exit;
[hadoop@172 sqoop]$ bin/sqoop-export --connect jdbc:mysql://$mysqlIP/test --usernameroot -P --table sqoop_test_back --export-dir /sqoop
[hadoop@172 sqoop]$ mysql -h $mysqlIP –pEnter password:mysql> use test;Database changedmysql> select * from sqoop_test_back;+----+---------+---------------------+---------+| id | title | time | content |+----+---------+---------------------+---------+| 1 | first | 2018-07-03 15:29:37 | hdfs || 2 | second | 2018-07-03 15:30:57 | mr || 3 | third | 2018-07-03 15:31:07 | yarn |+----+---------+---------------------+---------+3 rows in set (0.00 sec)
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan