2016-08-06 8 views
1

私はmysqlに接続し、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はうまく動作しています。

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テーブルを作成しました。ここ

[[email protected] 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 

は私のログファイルです。

[[email protected] edureka]# mysql -u root -p 

パスワードを入力してください: MySQLモニタへようこそ。コマンドはで終わります。または\ g。 MySQL接続IDは3 サーバのバージョン:5.1.73ソースディストリビューション

Copyright(c)2000、2013、Oracleおよび/またはその関連会社です。全著作権所有。

Oracleは、Oracle Corporationおよび/またはその関連会社の の登録商標です。その他の名称は、それぞれの所有者の商標である可能性があります。

'help;'と入力してください。ヘルプは '\ h'を入力してください。現在の入力ステートメントをクリアするには '\ c'と入力します。

mysqlの>これはどのようにある

mysql> select * from employee; 
+--------+-------+ 
| ename | ecode | 
+--------+-------+ 
| neha | 101 | 
| yogesh | 102 | 
+--------+-------+ 
2 rows in set (0.00 sec) 

-A

データベースに迅速に起動を取得するためにあなたは、この機能をオフにすることができ テーブルとカラム名の完了をedureka 読書テーブル情報を使用して変更しました私のsqlのような 'ショーグラント'の外観:

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

答えて

2

でポート番号を使用する必要があります0接続文字列:

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

さらに、IPではなくホスト名を使用する必要があります。上記sqoopインポートで3306:ローカルホストを使用して

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


ので、コマンドhostname -fの出力はJDBC接続文字列でcomputer.name使用これである場合。私はEdurekaデータベースが存在しないというエラーが出ます。しかし、私はデータベースを作成しました – Powershel

+0

MySQL側からそのデータベースが存在することを確認できますか? –

+0

はい、上記のUPDATEに追加しました。 MySQLデータベースが存在します。 – Powershel