hysteria icon indicating copy to clipboard operation
hysteria copied to clipboard

centos 7 无法使用systemctl start 启动hy2, 但是可以直接通过运行hysteria server启动

Open xiaosteven opened this issue 1 year ago • 8 comments

通过systemctl 启动后会报错如下: hysteria-server.service - Hysteria Server Service (config.yaml) Loaded: loaded (/etc/systemd/system/hysteria-server.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Wed 2023-11-01 13:53:19 CST; 2s ago Process: 5838 ExecStart=/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml (code=exited, status=1/FAILURE) Main PID: 5838 (code=exited, status=1/FAILURE)

Nov 01 13:53:19 80.251.215.138.16clouds.com systemd[1]: Started Hysteria Server Service (config.yaml). Nov 01 13:53:19 80.251.215.138.16clouds.com hysteria[5838]: 2023-11-01T13:53:19+08:00 INFO server mode Nov 01 13:53:19 80.251.215.138.16clouds.com systemd[1]: hysteria-server.service: main process exited, code=exited, status=1/FAILURE Nov 01 13:53:19 80.251.215.138.16clouds.com systemd[1]: Unit hysteria-server.service entered failed state. Nov 01 13:53:19 80.251.215.138.16clouds.com systemd[1]: hysteria-server.service failed.

如果修改/etc/systemd/system/hysteria-server.service 的用户和组成root,又会报没有geosite.dat和geoip.dat的权限错误

xiaosteven avatar Nov 01 '23 05:11 xiaosteven

手动执行一下/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml看看结果

yyu0378 avatar Nov 03 '23 02:11 yyu0378

手动执行没有问题,现在我只能把用户组改成root在用...不知道是哪个文件的权限不够

xiaosteven avatar Nov 03 '23 02:11 xiaosteven

我也遇到了同样的问题。但是改变用户组也没有用。

evencewang avatar Nov 07 '23 18:11 evencewang

试试在ExecStart=加上/bin/env/usr/bin/env /bin/env /usr/local/bin/hysteria server --config /etc/hysteria/config.yaml

you9you avatar Nov 09 '23 02:11 you9you

手动执行一下/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml看看结果

手动运行正常,systemctl status hysteria-server.service 服务无法启动。 还有一个问题就是,手动运行之后,只监听udp6 ,是正常的吗?

jxyk2007 avatar Nov 23 '23 01:11 jxyk2007

研究发现主要原因是 CentOS 7 的 systemd 太旧, 不支持下面这个语法

[Service]
WorkingDirectory=~

报错是这个

Nov 24 09:47:46 instance-1 systemd[1]: [/etc/systemd/system/hysteria-server.service:8] Not an absolute path, ignoring: ~

上述这个语法加入于 https://github.com/systemd/systemd/commit/5f5d8eab1f2f5f5e088bc301533b3e4636de96c7 , 随 systemd v227 于 2017 年发布。 而 CentOS 仍然在使用 systemd v219 。

要绕过这个问题, CentOS 7 用户可以选择手动修改 systemctl edit hysteria-server.service , 写入下面的内容并保存退出。

[Service]
WorkingDirectory=/var/lib/hysteria

我们或许会考虑修复这个。

haruue avatar Nov 24 '23 09:11 haruue

@jxyk2007

只监听udp6 ,是正常的吗?

只监听 IPv6 是正常的。 同时监听 IPv4 和 IPv6 在 netstat 会显示成监听 IPv6, 因为 所有 IPv4 地址都被映射为 IPv6 地址

haruue avatar Nov 24 '23 10:11 haruue

手动执行没有问题,现在我只能把用户组改成root在用...不知道是哪个文件的权限不够

Ubuntu 22.04遇到同样的问题。使用Linux 服务端部署脚本进行安装的。

直接运行/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml没有问题。

然而,使用服务启动systemctl start hysteria-server.service之后,显示服务正常启动,但是客户端无法连接,服务也并未有任何输出:

root@VM65202:~# systemctl start hysteria-server.service
root@VM65202:~# systemctl status hysteria-server.service
● hysteria-server.service - Hysteria Server Service (config.yaml)
     Loaded: loaded (/etc/systemd/system/hysteria-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-04-12 07:40:42 UTC; 4s ago
   Main PID: 130796 (hysteria)
      Tasks: 4 (limit: 710)
     Memory: 5.4M
        CPU: 52ms
     CGroup: /system.slice/hysteria-server.service
             └─130796 /usr/local/bin/hysteria server --config /etc/hysteria/config.yaml

Apr 12 07:40:42 VM65202 systemd[1]: Started Hysteria Server Service (config.yaml).
Apr 12 07:40:42 VM65202 hysteria[130796]: 2024-04-12T07:40:42Z        INFO        server mode
Apr 12 07:40:42 VM65202 hysteria[130796]: 2024-04-12T07:40:42Z        INFO        server up and running        {"listen":>
lines 1-13/13 (END)

在服务设置/etc/systemd/system/hysteria-server.service中,将用户和用户组修改为root之后,重新启动,问题解决。

[Unit]
Description=Hysteria Server Service (config.yaml)
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/hysteria server --config /etc/hysteria/config.yaml
WorkingDirectory=~
User=root
Group=root
Environment=HYSTERIA_LOG_LEVEL=info
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

46319943 avatar Apr 12 '24 07:04 46319943