{"id":15631263,"url":"https://github.com/mylxsw/remote-tail","last_synced_at":"2025-05-07T02:00:28.514Z","repository":{"id":57511149,"uuid":"68687559","full_name":"mylxsw/remote-tail","owner":"mylxsw","description":"RemoteTail用于同步监控多台服务器日志文件变更，一句话说就是多主机的远程tail。","archived":false,"fork":false,"pushed_at":"2021-10-22T08:56:31.000Z","size":5339,"stargazers_count":194,"open_issues_count":5,"forks_count":58,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-31T05:11:14.959Z","etag":null,"topics":["aggregation","logging","multi-tail","remote-tail","tail"],"latest_commit_sha":null,"homepage":"https://aicode.cc/remotetail","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mylxsw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-20T07:49:27.000Z","updated_at":"2025-03-26T08:43:20.000Z","dependencies_parsed_at":"2022-09-26T16:31:09.570Z","dependency_job_id":null,"html_url":"https://github.com/mylxsw/remote-tail","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mylxsw%2Fremote-tail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mylxsw%2Fremote-tail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mylxsw%2Fremote-tail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mylxsw%2Fremote-tail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mylxsw","download_url":"https://codeload.github.com/mylxsw/remote-tail/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798832,"owners_count":21805882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aggregation","logging","multi-tail","remote-tail","tail"],"created_at":"2024-10-03T10:39:44.720Z","updated_at":"2025-05-07T02:00:28.467Z","avatar_url":"https://github.com/mylxsw.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RemoteTail\n\nRemoteTail是一款支持同步显示多台远程服务器的日志文件内容更新的工具，使用它可以让你同时监控多台服务器中某个（某些）日志文件的变更，将多台服务器的`tail -f xxx.log`命令的输出合并展示。相比于其他流行的日志手机工具，RemoteTail去掉了在远程服务器安装agent的必要，减小了与远程服务器的耦合，但需要注意的是，由于日志收集使用的是远程执行`tail`命令，因此如果进程退出重启后会出现日志重复或者丢失部分日志的风险。\n\nRemoteTail只适应于简单的日志收集聚合，如果你不介意重启服务时日志丢失或者重复的问题，那么推荐你尝试一下。\n\n![logo](https://ssl.aicode.cc/remote-tail.jpg?20161011)\n\n## 使用场景\n\n假设公司有两台web服务器A和B，由于初期没有专业运维进行配置集中式的日志服务系统，两台服务器上分别部署了两套相同的代码提供web服务，使用nginx作为负载均衡，请求根据设定的策略转发的这两台web服务器上。\n\nAB两台服务器中的项目均将日志写到文件系统的`/home/data/logs/laravel.log`文件。这种情况下如果我们需要查看web日志是否正常，一般情况下就需要分别登陆两台服务器，然后分别执行`tail -f /home/data/logs/laravel.log`查看日志文件的最新内容，这在排查问题的时候是非常不方便的。RemoteTail就是为了解决这种问题的，开发人员可以使用它同步显示两台（多台）服务器的日志信息。\n\n## 安装\n\n在[release页面](https://github.com/mylxsw/remote-tail/releases)下载对应的`remote-tail-平台`可执行文件，将该文件加入到系统的`PATH`环境变量指定的目录中即可。\n\n比如，Centos下可以放到`/usr/local/bin`目录。\n\n    mv remote-tail-linux /usr/local/bin/remote-tail\n\n## 使用方法\n\n使用前需要宿主机建立与远程主机之间的[ssh公钥免密码登陆](https://aicode.cc/linux-mian-mi-ma-deng-lu.html)。\n\n    remote-tail -hosts 'watcher@192.168.1.226,watcher@192.168.1.225' \\\n    -file '/usr/local/openresty/nginx/logs/access.log'\n\n![demo](https://ssl.aicode.cc/remote-tail-demo.jpg?20161011)\n\n\u003e 如果服务器sshd监听的非默认端口22，可以使用`watcher@192.168.1.226:2222`这种方式指定其它端口。\n\n### 简单的日志收集\n\n日志聚合后作为单独文件存储，可以使用下面的方法\n\n    nohup remote-tail -hosts 'watcher@192.168.1.226,watcher@192.168.1.225' -file '/usr/local/openresthy/nginx/logs/access.log' -slient=true \u003e ./res.log \u0026\n\n\u003e `-slient=true`参数用于指定RemoteTail不输出欢迎信息和控制台彩色字符，只输出纯净整洁的日志。\n\n### 指定配置文件\n\n通过使用`-conf`参数可以为命令指定读取的配置文件，配置文件为TOML格式，请参考`example.toml`文件。\n\n配置文件`example.toml`：\n\n    # 全局配置,所有的servers中tail_file配置的默认值\n    tail_file=\"/data/logs/laravel.log\"\n    \n    # tail 命令的选项，一般Linux服务器不需要设置此项，采用默认值即可\n    # 如果是AIX等服务器，可能tail命令不支持下面这两个选项，可以修改该配置项为 \"-f\"\n    #tail_flags=\"--retry --follow=name\"\n\n    # 服务器配置,可以配置多个\n    # 如果不提供password, 则默认使用系统配置的 ssh-agent 设置，\n    # 你也可以通过指定 private_key_path 配置项来指定使用特定的私钥来登录 (private_key_path=/home/mylxsw/.ssh/id_rsa)\n    # 私钥如果有密码的话，需要指定 private_key_passphrase 配置项来指定私钥密码\n    # server_name, hostname, user 配置为必选,其它可选\n    [servers]\n\n    [servers.1]\n    server_name=\"测试服务器1\"\n    hostname=\"test1.server.aicode.cc\"\n    user=\"root\"\n    tail_file=\"/var/log/messages\"\n    # 指定ssh端口，不指定的情况下使用默认值22\n    port=2222\n\n    [servers.2]\n    server_name=\"测试服务器2\"\n    hostname=\"test2.server.aicode.cc\"\n    user=\"root\"\n    tail_file=\"/var/log/messages\"\n    tail_flags=\"-f\"\n\n    [servers.3]\n    server_name=\"测试服务器3\"\n    hostname=\"test2.server.aicode.cc\"\n    user=\"demo\"\n    password=\"123456\"\n\n执行命令：\n\n    remote-tail -conf=example.toml\n\n## 如何贡献\n\n欢迎贡献新的功能以及bug修复，**Fork**项目后修改代码，测试通过后提交**pull request**即可。\n\n## 问题反馈\n\n你可以在github的issue中提出你的bug或者其它需求。\n\n## Stargazers over time\n\n[![Stargazers over time](https://starchart.cc/mylxsw/remote-tail.svg)](https://starchart.cc/mylxsw/remote-tail)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmylxsw%2Fremote-tail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmylxsw%2Fremote-tail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmylxsw%2Fremote-tail/lists"}