Footsteps on my way !
perl/linux/测序分析

frp服务器端程序frps自启动出错

在centos8上部署frps设置自启动报错:

[root@server]#tar -zxvf frp_0.36.2_linux_amd64.tar.gz
[root@server]#mv frp_0.36.2_linux_amd64 frp
[root@server]#ln -s '/root/soft/frp/systemd/frps.service' '/etc/systemd/system/multi-[root@server]#user.target.wants/frps.service'
[root@server]#systemctl daemon-reload
[root@server]#systemctl start frps.service
[root@server]#systemctl status frps.service #报错如下:
● frps.service - Frp Server Service
   Loaded: loaded (/root/soft/frp/systemd/frps.service; bad; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2021-04-27 06:29:02 EDT; 4s ago
   Process: 7802 ExecStart=/root/soft/frp/frps -c /root/soft/frp/frps.ini (code=exited, status=203/EXEC)
   Main PID: 7802 (code=exited, status=203/EXEC)

Apr 27 06:29:02 racknerd-d123c3 systemd[1]: frps.service: Main process exited, code=exited, status=203/EXEC
Apr 27 06:29:02 racknerd-d123c3 systemd[1]: frps.service: Failed with result 'exit-code'.

不是由于路径错误或者是没有执行权限,或者是由于是shell脚本没有在脚本路径之前添加/bin/bash如ExecStart=/bin/bash /scripts/path/script.sh;
因为ExecStart=后的命令直接运行时完全没问题的:

[root@server]# /root/soft/frp/frps -c /root/soft/frp/frps.ini
2021/04/27 06:29:21 [I] [root.go:200] frps uses config file: /root/soft/frp/frps.ini
2021/04/27 06:29:21 [I] [service.go:192] frps tcp listen on 0.0.0.0:7000
2021/04/27 06:29:21 [I] [root.go:209] frps started successfully
2021/04/27 06:29:22 [I] [service.go:449] [0c4fbb5294a23bbd] client login info: ip [111.0.11.111:48544] version [0.36.2] hostname [] os [linux] arch [amd64]
2021/04/27 06:29:22 [I] [tcp.go:63] [0c4fbb5294a23bbd] [ssh] tcp proxy listen port [6666]
2021/04/27 06:29:22 [I] [control.go:446] [0c4fbb5294a23bbd] new proxy [ssh] success
^C

试了多种方法无果,最后修改了官方的frps.service文件【将User=nobody 改为 User=root】后systemctl daemon-reload;systemctl start frps.service;完美解决:

[root@server frp]# systemctl start frps.service
[root@server frp]# systemctl status frps.service
● frps.service - Frp Server Service
   Loaded: loaded (/root/soft/frp/systemd/frps.service; bad; vendor preset: disabled)
   Active: active (running) since Tue 2021-04-27 06:45:28 EDT; 3s ago
 Main PID: 8265 (frps)
    Tasks: 3 (limit: 6706)
   Memory: 13.0M
   CGroup: /system.slice/frps.service
           └─8265 /root/soft/frp/frps -c /root/soft/frp/frps.ini
Apr 27 06:45:28 server systemd[1]: Started Frp Server Service.
Apr 27 06:45:28 server frps[8265]: 2021/04/27 06:45:28 [I] [root.go:200] frps uses config file: /root/soft/frp/frps.ini
Apr 27 06:45:28 server frps[8265]: 2021/04/27 06:45:28 [I] [service.go:192] frps tcp listen on 0.0.0.0:7000
Apr 27 06:45:28 server frps[8265]: 2021/04/27 06:45:28 [I] [root.go:209] frps started successfully
Apr 27 06:45:29 server frps[8265]: 2021/04/27 06:45:29 [I] [service.go:44x] [0c4fbb5294a23bbx] client login info: ip [111.0.16.111:49402] version [0.36.2] hostname [] os [linux] arch [amd64]
Apr 27 06:45:29 server frps[8265]: 2021/04/27 06:45:29 [I] [tcp.go:63] [0c4fbb5294a23bbx] [ssh] tcp proxy listen port [6868]
Apr 27 06:45:29 server frps[8265]: 2021/04/27 06:45:29 [I] [control.go:446] [0c4fbb5294a23bbx] new proxy [ssh] success

具体原因未知:我的客户端软件fprc运行在有除添加了root外其他用户的centos8  上,在frpc.server文件中使用User=nobody可正常运行,但我的服务器上是只有root一个用户,运行服务器端软件fprs时使用User=nobody就会报错,须将nobody改为root,方可正常,猜测可能是由于只有一个root用户时导致的未知权限bug。(未做交叉测试:即未在成功运行User=nobody的客服端软件的机器上运行User=nobody的服务器端软件,看其出不出错,从而确认我的猜想)

尊重他人劳动成果,转载请注明出处:Bluesky's blog » frp服务器端程序frps自启动出错

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址