Sqoop 导入 mysql 错误 - 通信 link 失败
Sqoop import mysql error - communications link failure
我正在尝试连接到 mysql 并通过 sqoop 导入 mysql。
但是,获取通信 link 失败错误。
这是我的配置文件。
[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 table。
[root@localhost edureka]# mysql -u root -p
输入密码:
欢迎使用 MySQL 监视器。命令以 ; 结尾或\g。
您的 MySQL 连接 ID 是 3
服务器版本:5.1.73 源码分发
版权所有 (c) 2000、2013,Oracle and/or 其附属公司。保留所有权利。
Oracle 是 Oracle Corporation 的注册商标 and/or
分支机构。其他名称可能是其各自的商标
业主。
键入 'help;' 或“\h”寻求帮助。输入'\c'清除当前输入的语句。
mysql> 使用 edureka
读取 table 信息以完成 table 和列名
您可以使用 -A
关闭此功能以更快地启动
数据库已更改
mysql> select * from employee;
+--------+-------+
| ename | ecode |
+--------+-------+
| neha | 101 |
| yogesh | 102 |
+--------+-------+
2 rows in set (0.00 sec)
这就是 'show grants' 在我的 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;
此外,您还应该使用主机名代替 IP。
因此,如果命令 hostname -f
的输出是 computer.name
,请在 JDBC
连接字符串中使用它:
sqoop import --connect jdbc:mysql://computer.name:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;
我正在尝试连接到 mysql 并通过 sqoop 导入 mysql。
但是,获取通信 link 失败错误。
这是我的配置文件。
[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 table。
[root@localhost edureka]# mysql -u root -p
输入密码: 欢迎使用 MySQL 监视器。命令以 ; 结尾或\g。 您的 MySQL 连接 ID 是 3 服务器版本:5.1.73 源码分发
版权所有 (c) 2000、2013,Oracle and/or 其附属公司。保留所有权利。
Oracle 是 Oracle Corporation 的注册商标 and/or 分支机构。其他名称可能是其各自的商标 业主。
键入 'help;' 或“\h”寻求帮助。输入'\c'清除当前输入的语句。
mysql> 使用 edureka 读取 table 信息以完成 table 和列名 您可以使用 -A
关闭此功能以更快地启动数据库已更改
mysql> select * from employee;
+--------+-------+
| ename | ecode |
+--------+-------+
| neha | 101 |
| yogesh | 102 |
+--------+-------+
2 rows in set (0.00 sec)
这就是 'show grants' 在我的 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;
此外,您还应该使用主机名代替 IP。
因此,如果命令 hostname -f
的输出是 computer.name
,请在 JDBC
连接字符串中使用它:
sqoop import --connect jdbc:mysql://computer.name:3306/Edureka --table Employee --username root -P --target-dir /sqoopOut1 -m 1;