Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqoop导入mysql错误-通信链路故障_Mysql_Hadoop_Hdfs_Sqoop - Fatal编程技术网

Sqoop导入mysql错误-通信链路故障

Sqoop导入mysql错误-通信链路故障,mysql,hadoop,hdfs,sqoop,Mysql,Hadoop,Hdfs,Sqoop,我正在尝试连接到mysql并通过sqoop导入mysql 但是,获取通信链路失败错误 这是我的配置文件 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid b) mysql运行良好 [root@loca

我正在尝试连接到mysql并通过sqoop导入mysql

但是,获取通信链路失败错误

这是我的配置文件

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
b) mysql运行良好

[root@localhost edureka]# sqoop import --connect jdbc:mysql://192.168.56.1/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;

Warning: /usr/lib/hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Enter password: 
16/08/06 23:34:48 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.
16/08/06 23:34:48 INFO tool.CodeGenTool: Beginning code generation
16/08/06 23:34:48 ERROR manager.SqlManager: Error executing statement: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
这是我的日志文件:

    60806 12:33:42 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160806 12:33:43  InnoDB: Initializing buffer pool, size = 8.0M
160806 12:33:43  InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
160806 12:33:43  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
160806 12:33:44  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
160806 12:33:44  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
160806 12:33:45  InnoDB: Started; log sequence number 0 0
160806 12:33:45 [Note] Event Scheduler: Loaded 0 events
160806 12:33:45 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
160806 23:05:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160806 23:05:06  InnoDB: Initializing buffer pool, size = 8.0M
160806 23:05:06  InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
160806 23:05:06  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
160806 23:05:07  InnoDB: Started; log sequence number 0 44233
160806 23:05:07 [Note] Event Scheduler: Loaded 0 events
160806 23:05:07 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.73'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution
更新:我已经创建了Edureka数据库和Employee表

[root@localhost edureka]# mysql -u root -p
输入密码: 欢迎使用MySQL监视器。命令以结束;或\g。 您的MySQL连接id是3 服务器版本:5.1.73源发行版

版权所有(c)20002013,Oracle和/或其附属公司。版权所有

Oracle是Oracle公司和/或其子公司的注册商标 附属公司。其他名称可能是其各自的商标 所有者

键入“帮助;”或“\h”以获取帮助。键入“\c”以清除当前输入语句

mysql>使用edureka 读取表信息以完成表和列名 您可以关闭此功能,以便使用-a快速启动

数据库已更改

mysql> select * from employee;
+--------+-------+
| ename  | ecode |
+--------+-------+
| neha   | 101   |
| yogesh | 102   |
+--------+-------+
2 rows in set (0.00 sec)
这是我的sql上“显示授权”的样子:

    mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

您应该在
JDBC
连接字符串中使用端口号:

sqoop import --connect jdbc:mysql://192.168.56.1:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;
sqoop import --connect jdbc:mysql://computer.name:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;
此外,您还应该使用主机名来代替IP。
因此,如果命令
hostname-f
的输出是
computer.name
则在
JDBC
连接字符串中使用此命令:

sqoop import --connect jdbc:mysql://192.168.56.1:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;
sqoop import --connect jdbc:mysql://computer.name:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;

在上面的sqoop导入中使用localhost:3306。我得到的错误是Edureka数据库不存在。但是,我已经创建了数据库,您可以从MySQL端验证数据库是否存在吗?是的,我在上面的更新中添加了。Mysql数据库已存在。是否可以尝试使用
hostname-f
命令的输出而不是
localhost
sqoop
命令具有Edureka(大写E),并且您的数据库名为Edureka(小写E)-(UNIX中的Mysql数据库名区分大小写)()