前のエントリの続き。
192.168.56.12は新マスター。
Exec_Master_Log_Pos=`mysql -e 'show slave status \G' | awk '/Exec_Master_Log_Pos/{print $2}'` q=$(mysqlbinlog `ls /var/lib/mysql/mysqld-relay-bin.* | grep -v index | tail -n 1` | fgrep -A 256 "end_log_pos $Exec_Master_Log_Pos" | awk '/\/\*!\*\//,/^\/\*!\*\//') for i in `mysql -h 192.168.56.12 -u scott -ptiger -e "show master logs" -B -N | awk '{print $1}' | sort -r`; do echo "[ $i ]"; mysqlbinlog -u scott -ptiger -h 192.168.56.12 -R $i | fgrep -B 2 -x "$q" | cut -b-64 | tail -n 10 ; done
[ mysql-bin.000001 ] /*!*/; -- SET TIMESTAMP=1291565568/*!*/; create table foo (id int) /*!*/; # at 168381080 #101206 2:19:28 server id 1 end_log_pos 168381173 Query threa SET TIMESTAMP=1291569568/*!*/; create table bar (id int) /*!*/;
という感じで新マスターにCHANGE MASTERするときのポジションはmysql-bin.000001:168381080になる。
だれか複数行を検索する方法を教えてください。。。