2016-11-17 43 views
1

のためのPOSを開始ビンログのmysql-のpython-レプリケータので、私はパラメータのみ、スキーマを持つBinglogStream作成することができます。私は特定のデータベース用のMySQLからデータをダンプするためのmysql-のpython-リプリケーターを使用している特定のスキーマ

stream = BinLogStreamReader(connection_settings=mysql_settings, 
          server_id=1,only_schemas='tpch', 
          log_file='mysql-bin.000001',log_pos=1 
          ) 

私はイベント位置の開始がわからないので、私はパラメータlog_file='mysql-bin.000001'log_pos=1を持っているので、mysql-binlogのデータベースの開始イベント位置を見つけるためのアイデアはありますか?

答えて

0

最初のbinlog位置を推測することはできません。このファイルと位置は、Mysqlがその構成に基づいて自動的に回転するため、サーバー上に存在しない可能性があります。

ライブラリは、最初からどのように起動するかを内部的に認識しています。再開に必要な3つのパラメータを除外するだけです(または、False/Noneを設定します)。

if binlog_filename is None or binlog_position is None: 
    # Connecting to MySQL binlog (from beginning)... 
    binlog_stream = BinLogStreamReader(
     connection_settings=mysql_settings, 
     server_id=1, 
     blocking=True 
    ) 
else: 
    # Continuing from binlog_filename and binlog_position 
    binlog_stream = BinLogStreamReader(
     connection_settings=mysql_settings, 
     server_id=1, 
     resume_stream=True, 
     blocking=True, 
     log_file=binlog_filename, 
     log_pos=binlog_position 
    ) 
関連する問題