v2ray-core icon indicating copy to clipboard operation
v2ray-core copied to clipboard

Debian V2ray无法启动日志功能

Open ttxs25830 opened this issue 3 years ago • 5 comments

你正在使用哪个版本的 V2Ray?

Client:

V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
A unified platform for anti-censorship.

你的使用场景是什么?

在内网Linux主机上架设可访问外网的Socks5代理

你看到的异常现象是什么?

V2ray客户端无法启动

你期待看到的正常表现是怎样的?

V2ray客户端正常启动

请附上你的配置

服务端配置: 本问题与服务端无关

客户端配置:

{
  "log": {
    "loglevel": "warning",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [
    {
      "listen": "0.0.0.0",
      "port": 1080,
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": true
      },
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ],
        "metadataOnly": false
      }
    }
  ],
  "outbounds": [
    {
      "sendThrough": "192.168.1.2",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "<Server IP>",
            "port": <Server Port>,
            "users": [
              {
                "id": "<UUID>",
                "alterId": 0
              }
            ]
          }
        ]
      }
    }
  ],
  "dns": {
    "servers": [
      "1.1.1.1",
      "8.8.8.8",
      "localhost"
    ]
  }
}

请附上出错时软件输出的错误日志

服务器端错误日志: 本问题与服务端无关

客户端错误日志: 问题导致v2ray无法产生日志

命令行服务日志

root@Server:~# service v2ray status
● v2ray.service - V2Ray Service
     Loaded: loaded (/lib/systemd/system/v2ray.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2022-07-26 20:45:20 CST; 2s ago
       Docs: https://www.v2ray.com/
             https://www.v2fly.org/
    Process: 6943 ExecStart=/usr/bin/v2ray -config /etc/v2ray/config.json (code=exited, status=23)
   Main PID: 6943 (code=exited, status=23)
        CPU: 9ms

7月 26 20:45:20 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 5.
7月 26 20:45:20 Server systemd[1]: Stopped V2Ray Service.
7月 26 20:45:20 Server systemd[1]: v2ray.service: Start request repeated too quickly.
7月 26 20:45:20 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 20:45:20 Server systemd[1]: Failed to start V2Ray Service.

请附上访问日志

问题导致v2ray无法产生日志

其它相关的配置文件(如 Nginx)和相关日志

如果 V2Ray 无法启动,请附上 --test 命令的输出

root@Server:~# /usr/bin/v2ray -config /etc/v2ray/config.json -test
V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
A unified platform for anti-censorship.
2022/07/26 20:51:35 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
Configuration OK.

如果 V2Ray 服务运行异常,请附上 journal 日志

root@Server:~# journalctl -u v2ray 
-- Journal begins at Tue 2022-07-26 21:06:19 CST, ends at Tue 2022-07-26 21:06:20 CST. --
7月 26 21:06:19 Server systemd[1]: Started V2Ray Service.
7月 26 21:06:19 Server v2ray[858]: V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
7月 26 21:06:19 Server v2ray[858]: A unified platform for anti-censorship.
7月 26 21:06:19 Server v2ray[858]: 2022/07/26 21:06:19 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
7月 26 21:06:19 Server v2ray[858]: main: failed to create server > v2ray.com/core/app/log: failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system
7月 26 21:06:19 Server systemd[1]: v2ray.service: Main process exited, code=exited, status=23/n/a
7月 26 21:06:19 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:19 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 1.
7月 26 21:06:19 Server systemd[1]: Stopped V2Ray Service.
7月 26 21:06:19 Server systemd[1]: Started V2Ray Service.
7月 26 21:06:19 Server v2ray[868]: V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
7月 26 21:06:19 Server v2ray[868]: A unified platform for anti-censorship.
7月 26 21:06:19 Server v2ray[868]: 2022/07/26 21:06:19 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
7月 26 21:06:19 Server v2ray[868]: main: failed to create server > v2ray.com/core/app/log: failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system
7月 26 21:06:19 Server systemd[1]: v2ray.service: Main process exited, code=exited, status=23/n/a
7月 26 21:06:19 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:19 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 2.
7月 26 21:06:19 Server systemd[1]: Stopped V2Ray Service.
7月 26 21:06:19 Server systemd[1]: Started V2Ray Service.
7月 26 21:06:19 Server v2ray[876]: V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
7月 26 21:06:19 Server v2ray[876]: A unified platform for anti-censorship.
7月 26 21:06:19 Server v2ray[876]: 2022/07/26 21:06:19 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
7月 26 21:06:19 Server v2ray[876]: main: failed to create server > v2ray.com/core/app/log: failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system
7月 26 21:06:19 Server systemd[1]: v2ray.service: Main process exited, code=exited, status=23/n/a
7月 26 21:06:19 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:20 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 3.
7月 26 21:06:20 Server systemd[1]: Stopped V2Ray Service.
7月 26 21:06:20 Server systemd[1]: Started V2Ray Service.
7月 26 21:06:20 Server v2ray[885]: V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
7月 26 21:06:20 Server v2ray[885]: A unified platform for anti-censorship.
7月 26 21:06:20 Server v2ray[885]: 2022/07/26 21:06:20 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
7月 26 21:06:20 Server v2ray[885]: main: failed to create server > v2ray.com/core/app/log: failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system
7月 26 21:06:20 Server systemd[1]: v2ray.service: Main process exited, code=exited, status=23/n/a
7月 26 21:06:20 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:20 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 4.
7月 26 21:06:20 Server systemd[1]: Stopped V2Ray Service.
7月 26 21:06:20 Server systemd[1]: Started V2Ray Service.
7月 26 21:06:20 Server v2ray[893]: V2Ray 4.34.0 (user) 20210718-110034 (go1.15.9 linux/amd64)
7月 26 21:06:20 Server v2ray[893]: A unified platform for anti-censorship.
7月 26 21:06:20 Server v2ray[893]: 2022/07/26 21:06:20 [Info] v2ray.com/core/main/jsonem: Reading config: /etc/v2ray/config.json
7月 26 21:06:20 Server v2ray[893]: main: failed to create server > v2ray.com/core/app/log: failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system
7月 26 21:06:20 Server systemd[1]: v2ray.service: Main process exited, code=exited, status=23/n/a
7月 26 21:06:20 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:20 Server systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 5.
7月 26 21:06:20 Server systemd[1]: Stopped V2Ray Service.
7月 26 21:06:20 Server systemd[1]: v2ray.service: Start request repeated too quickly.
7月 26 21:06:20 Server systemd[1]: v2ray.service: Failed with result 'exit-code'.
7月 26 21:06:20 Server systemd[1]: Failed to start V2Ray Service.

尝试的解决办法

手动使用命令启动v2ray

成功启动,能够正常运行

将/var/log/v2ray权限从755调整为777

依然无法启动服务

尝试运行其他文件修改操作

其他有关文件修改命令程序均可正常运行

尝试删除配置文件中的log字段来禁用日志行为

成功,服务正常运行

ttxs25830 avatar Jul 26 '22 13:07 ttxs25830

failed to initialize access logger > open /var/log/v2ray/access.log: read-only file system

内核有其他错误信息吗

kslr avatar Jul 27 '22 08:07 kslr

使用 v2ray -test 测试配置文件有效性,我有几次好像问题跟你差不多,打开v2ray就出现闪退

lijin-tao avatar Jul 27 '22 08:07 lijin-tao

使用 v2ray -test 测试配置文件有效性,我有几次好像问题跟你差不多,打开v2ray就出现闪退

我上面放了-test测试结果的,是ok

ttxs25830 avatar Jul 27 '22 08:07 ttxs25830

没有权限写入/var/log/v2ray/access.log , 你试试 /var/log 这个目录下手动新建v2ray目录,然后把这个v2ray目录的权限改成你启动v2ray进程用户能够写入的权限。或者你手工可以启动的话,那你检查一下v2ray.service里面启动用户是不是nobody,可以改为 用你用户名来启动。

Remonli avatar Jul 31 '22 19:07 Remonli

你是通过 apt 安装的吗?apt 源里的 v2ray 默认使用 DynamicUser,日志目录需要同时在 systemd 里面设置。

尝试使用 root 用户依次运行以下命令:

mkdir /lib/systemd/system/v2ray.service.d
echo '[Service]' > /lib/systemd/system/v2ray.service.d/50-logs-directory.conf
echo 'LogsDirectory=v2ray' >> /lib/systemd/system/v2ray.service.d/50-logs-directory.conf
systemctl daemon-reload
systemctl restart v2ray
systemctl status v2ray

第三行命令里LogsDirectory=对应的值是/var/log/下的目录名称,例如LogsDirectory=v2ray对应目录/var/log/v2ray,你可以根据需要自行修改。

IRN-Kawakaze avatar Aug 23 '22 18:08 IRN-Kawakaze