{"id":112896,"date":"2018-08-02T08:11:48","date_gmt":"2018-08-02T00:11:48","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=112896"},"modified":"2018-07-26T11:17:28","modified_gmt":"2018-07-26T03:17:28","slug":"tlog-linux","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/tlog-linux.html","title":{"rendered":"Linux \u4e2d\u7ec8\u7aef I\/O \u5f55\u5236\u548c\u56de\u653e\u8f6f\u4ef6\u5305\uff1aTlog"},"content":{"rendered":"
Tlog \u662f Linux \u4e2d\u7ec8\u7aef I\/O \u5f55\u5236\u548c\u56de\u653e\u8f6f\u4ef6\u5305\u3002\u5b83\u7528\u4e8e\u5b9e\u73b0\u4e00\u4e2a\u96c6\u4e2d\u5f0f\u7528\u6237\u4f1a\u8bdd\u5f55\u5236\u3002\u5b83\u5c06\u6240\u6709\u7ecf\u8fc7\u7684\u6d88\u606f\u5f55\u5236\u4e3a JSON \u6d88\u606f\u3002\u5f55\u5236\u4e3a JSON \u683c\u5f0f\u7684\u4e3b\u8981\u76ee\u7684\u662f\u5c06\u6570\u636e\u4f20\u9001\u5230 ElasticSearch \u4e4b\u7c7b\u7684\u5b58\u50a8\u670d\u52a1\uff0c\u53ef\u4ee5\u4ece\u4e2d\u641c\u7d22\u548c\u67e5\u8be2\uff0c\u4ee5\u53ca\u56de\u653e\u3002\u540c\u65f6\uff0c\u5b83\u4eec\u4fdd\u7559\u6240\u6709\u901a\u8fc7\u7684\u6570\u636e\u548c\u65f6\u5e8f\u3002
\nTlog \u5305\u542b\u4e09\u4e2a\u5de5\u5177\uff0c\u5206\u522b\u662f tlog-rec\u3001tlog-rec-session\u548ctlog-play`\u3002
\n\u25c8 tlog-rec \u5de5\u5177\u4e00\u822c\u7528\u4e8e\u5f55\u5236\u7ec8\u7aef\u3001\u7a0b\u5e8f\u6216 shell \u7684\u8f93\u5165\u6216\u8f93\u51fa\u3002
\n\u25c8 tlog-rec-session \u5de5\u5177\u7528\u4e8e\u5f55\u5236\u6574\u4e2a\u7ec8\u7aef\u4f1a\u8bdd\u7684 I\/O\uff0c\u5305\u62ec\u5f55\u5236\u7684\u7528\u6237\u3002
\n\u25c8 tlog-play \u5de5\u5177\u7528\u4e8e\u56de\u653e\u5f55\u5236\u3002
\n\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u89e3\u91ca\u5982\u4f55\u5728 CentOS 7.4 \u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Tlog\u3002<\/p>\n
\u5728\u5b89\u88c5\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u6211\u4eec\u7684\u7cfb\u7edf\u6ee1\u8db3\u7f16\u8bd1\u548c\u5b89\u88c5\u7a0b\u5e8f\u7684\u6240\u6709\u8f6f\u4ef6\u8981\u6c42\u3002\u5728\u7b2c\u4e00\u6b65\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\u7cfb\u7edf\u4ed3\u5e93\u548c\u8f6f\u4ef6\u5305\u3002<\/p>\n
# yum update<\/pre>\n\u6211\u4eec\u9700\u8981\u5b89\u88c5\u6b64\u8f6f\u4ef6\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u9879\u3002\u5728\u5b89\u88c5\u4e4b\u524d\uff0c\u6211\u5df2\u7ecf\u4f7f\u7528\u8fd9\u4e9b\u547d\u4ee4\u5b89\u88c5\u4e86\u6240\u6709\u4f9d\u8d56\u5305\u3002<\/p>\n
# yum install wget gcc\r\n# yum install systemd-devel json-c-devel libcurl-devel m4<\/pre>\n\u5b8c\u6210\u8fd9\u4e9b\u5b89\u88c5\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4e0b\u8f7d\u8be5\u5de5\u5177\u7684\u6e90\u7801\u5305\u5e76\u6839\u636e\u9700\u8981\u5c06\u5176\u89e3\u538b\u5230\u670d\u52a1\u5668\u4e0a\uff1a<\/p>\n
# wget https:\/\/github.com\/Scribery\/tlog\/releases\/download\/v3\/tlog-3.tar.gz\r\n# tar -xvf tlog-3.tar.gz\r\n# cd tlog-3<\/pre>\n\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u6211\u4eec\u901a\u5e38\u7684\u914d\u7f6e\u548c\u7f16\u8bd1\u65b9\u6cd5\u5f00\u59cb\u6784\u5efa\u6b64\u5de5\u5177\u3002<\/p>\n
# .\/configure --prefix=\/usr --sysconfdir=\/etc && make\r\n# make install\r\n# ldconfig<\/pre>\n\u6700\u540e\uff0c\u4f60\u9700\u8981\u8fd0\u884c ldconfig\u3002\u5b83\u5bf9\u547d\u4ee4\u884c\u4e2d\u6307\u5b9a\u76ee\u5f55\u3001\/etc\/ld.so.conf \u6587\u4ef6\uff0c\u4ee5\u53ca\u4fe1\u4efb\u7684\u76ee\u5f55\uff08 \/lib \u548c \/usr\/lib\uff09\u4e2d\u6700\u8fd1\u7684\u5171\u4eab\u5e93\u521b\u5efa\u5fc5\u8981\u7684\u94fe\u63a5\u548c\u7f13\u5b58\u3002
\nTlog \u5de5\u4f5c\u6d41\u7a0b\u56fe<\/p>\nTlog working process
\n\u9996\u5148\uff0c\u7528\u6237\u901a\u8fc7 PAM \u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u767b\u5f55\u3002\u540d\u79f0\u670d\u52a1\u4ea4\u6362\u5668\uff08NSS\uff09\u63d0\u4f9b\u7684 tlog \u4fe1\u606f\u662f\u7528\u6237\u7684 shell\u3002\u8fd9\u521d\u59cb\u5316\u4e86 tlog \u90e8\u5206\uff0c\u5e76\u4ece\u73af\u5883\u53d8\u91cf\/\u914d\u7f6e\u6587\u4ef6\u6536\u96c6\u5173\u4e8e\u5b9e\u9645 shell \u7684\u4fe1\u606f\uff0c\u5e76\u5728 PTY \u4e2d\u542f\u52a8\u5b9e\u9645\u7684 shell\u3002\u7136\u540e\u901a\u8fc7 syslog \u6216 sd-journal \u5f00\u59cb\u5f55\u5236\u5728\u7ec8\u7aef\u548c PTY \u4e4b\u95f4\u4f20\u9012\u7684\u6240\u6709\u5185\u5bb9\u3002
\n\u7528\u6cd5
\n\u4f60\u53ef\u4ee5\u4f7f\u7528 tlog-rec \u5f55\u5236\u4e00\u4e2a\u4f1a\u8bdd\u5e76\u4f7f\u7528 tlog-play \u56de\u653e\u5b83\uff0c\u4ee5\u6d4b\u8bd5\u65b0\u5b89\u88c5\u7684 tlog \u662f\u5426\u80fd\u591f\u6b63\u5e38\u5f55\u5236\u548c\u56de\u653e\u4f1a\u8bdd\u3002<\/p>\n\u5f55\u5236\u5230\u6587\u4ef6\u4e2d<\/strong><\/div>\n\u8981\u5c06\u4f1a\u8bdd\u5f55\u5236\u5230\u6587\u4ef6\u4e2d\uff0c\u8bf7\u5728\u547d\u4ee4\u884c\u4e2d\u6267\u884c tlog-rec\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n
tlog-rec --writer=file --file-path=tlog.log<\/pre>\n\u8be5\u547d\u4ee4\u4f1a\u5c06\u6211\u4eec\u7684\u7ec8\u7aef\u4f1a\u8bdd\u5f55\u5236\u5230\u540d\u4e3a tlog.log \u7684\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u5728\u547d\u4ee4\u4e2d\u6307\u5b9a\u7684\u8def\u5f84\u4e2d\u3002<\/p>\n
\u4ece\u6587\u4ef6\u4e2d\u56de\u653e<\/strong><\/div>\n\u4f60\u53ef\u4ee5\u5728\u5f55\u5236\u8fc7\u7a0b\u4e2d\u6216\u5f55\u5236\u540e\u4f7f\u7528 tlog-play \u547d\u4ee4\u56de\u653e\u5f55\u5236\u7684\u4f1a\u8bdd\u3002<\/p>\n
tlog-play --reader=file --file-path=tlog.log<\/pre>\n\u8be5\u547d\u4ee4\u4ece\u6307\u5b9a\u7684\u8def\u5f84\u8bfb\u53d6\u5148\u524d\u5f55\u5236\u7684\u6587\u4ef6 tlog.log\u3002<\/p>\n
\u603b\u7ed3<\/strong><\/div>\nTlog \u662f\u4e00\u4e2a\u5f00\u6e90\u8f6f\u4ef6\u5305\uff0c\u53ef\u7528\u4e8e\u5b9e\u73b0\u96c6\u4e2d\u5f0f\u7528\u6237\u4f1a\u8bdd\u5f55\u5236\u3002\u5b83\u4e3b\u8981\u662f\u4f5c\u4e3a\u4e00\u4e2a\u66f4\u5927\u7684\u7528\u6237\u4f1a\u8bdd\u5f55\u5236\u89e3\u51b3\u65b9\u6848\u7684\u4e00\u90e8\u5206\u4f7f\u7528\uff0c\u4f46\u5b83\u88ab\u8bbe\u8ba1\u4e3a\u72ec\u7acb\u4e14\u53ef\u91cd\u7528\u7684\u3002\u8be5\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u5f55\u5236\u7528\u6237\u6240\u505a\u7684\u4e00\u5207\uff0c\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u670d\u52a1\u5668\u7684\u67d0\u4e2a\u4f4d\u7f6e\uff0c\u4ee5\u5907\u5c06\u6765\u53c2\u8003\u3002\u4f60\u53ef\u4ee5\u4ece\u8fd9\u4e2a\u6587\u6863\u4e2d\u83b7\u5f97\u5173\u4e8e\u8fd9\u4e2a\u8f6f\u4ef6\u5305\u4f7f\u7528\u7684\u66f4\u591a\u7ec6\u8282\u3002\u6211\u5e0c\u671b\u8fd9\u7bc7\u6587\u7ae0\u5bf9\u4f60\u6709\u7528\u3002\u8bf7\u5728\u4e0b\u9762\u7559\u4e0b\u4f60\u7684\u5b9d\u8d35\u5efa\u8bae\u548c\u610f\u89c1\u3002<\/p>\n
\n\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.linux-ren.org\/portal.php?mod=view&aid=2490<\/a><\/p>\n