该脚本由香打小伙伴整理。
首先保证HDFS和HiveServer2正常运行,集群运行在debugo01,debugo02,debugo03三台主机上。
1. 准备mysql数据
在debugo03的MySQL中新建一个测试数据库,并建测试表employee_salary。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
mysql -uroot -p mysql> create database test_sqoop; Query OK, 1 row affected (0.00 sec) mysql> use test_sqoop; SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `employee_salary`; CREATE TABLE `employee_salary` ( `name` text, `id` int(8) NOT NULL AUTO_INCREMENT, `salary` int(8) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; INSERT INTO `employee_salary` VALUES ('zhangsan', '1', '5000'); INSERT INTO `employee_salary` VALUES ('lisi', '2', '5500'); commit; CREATE USER 'test'@'%' IDENTIFIED BY 'test'; GRANT ALL PRIVILEGES ON test_sqoop.* TO 'test'@'%'; |