Sublime 正则表达式应用:日志信息过滤

工具:Sublime

需求:生产环境由于程序BUG导致业务数据错乱,需要找出受影响的表及所有关联表并对数据恢复。由于日志文件50MB几十几百万行,所以迫切需要筛选出所有相关日志。

日志文件:system.log

1. 过滤出包含指定业务数据【1541403331278483474】的日志行

    逆向思维:使用下面的正则表达式,找出不包含【1541403331278483474】的行,删除掉(正则替换为空字符串)。

^(?!.*1541403331278483474).*$

2. 正则替换空白行:

^(\t)*$\n

3. 留下的行就是受影响的表

    update act_hi_actinst set ASSIGNEE_=1541403331270094858 where ASSIGNEE_=1527160608832921603;

    update act_hi_comment set USER_ID_=1541403331270094858 where USER_ID_=1527160608832921603;

    update act_hi_identitylink set USER_ID_=1541403331270094858 where USER_ID_=1527160608832921603;

    update act_hi_procinst set START_USER_ID_=1541403331270094858 where START_USER_ID_=1527160608832921603;

    update act_hi_varinst set LONG_=1541403331270094858 where LONG_=1527160608832921603;

    update act_ru_actinst set ASSIGNEE_=1541403331270094858 where ASSIGNEE_=1527160608832921603;

    update act_ru_execution set START_USER_ID_=1541403331270094858 where START_USER_ID_=1527160608832921603;

    update act_ru_identitylink set USER_ID_=1541403331270094858 where USER_ID_=1527160608832921603;

    update act_ru_task set ASSIGNEE_=1541403331270094858 where ASSIGNEE_=1527160608832921603;

    update act_ru_variable set LONG_=1541403331270094858 where LONG_=1527160608832921603;

    update bus_station_message set receive_user_id=1541403331270094858 where receive_user_id=1527160608832921603;

    update ACT_HI_VARINST set TEXT_=1541403331270094858 where NAME_ = 'applyUser' AND TEXT_=1527160608832921603;

    update bus_extended_file_storage set create_user=1541403331270094858, create_dept=1479048614675632139 where create_user=1527160608832921603;

    update bus_extended_file_storage set update_user=1541403331270094858 where update_user=1527160608832921603;

    update bus_product_low set create_user=1541403331270094858, create_dept=1479048614675632139 where create_user=1527160608832921603;

    update bus_product_low set update_user=1541403331270094858 where update_user=1527160608832921603;

你可能感兴趣的:(生产运维,mysql,生产环境)