是否需要从没有 SUDO 权限的用户配置和启动 HAproxy。总的来说,结果是完成了。
/data/haproxy/haproxy -f /etc/haproxy/haproxy.cfg
标准输出:
[WARNING] 198/141606 (119143) : config : 'option forwardfor' ignored for frontend 'https-in' as it requires HTTP mode.
[WARNING] 198/141606 (119143) : config : 'option forwardfor' ignored for backend 'https-servers-basic' as it requires HTTP mode.
[WARNING] 198/141606 (119143) : config : 'option forwardfor' ignored for backend 'https-servers-redirect' as it requires HTTP mode.
[WARNING] 198/141606 (119143) : config : 'option forwardfor' ignored for backend 'https-servers-service' as it requires HTTP mode.
进程确实开始正常:
[test@ser-app-0001 haproxy]$ ps aux | grep haproxy
test 5109 0.3 0.0 49040 5224 ? Ss 15:37 0:00 /data/haproxy/haproxy -f /etc/haproxy/haproxy.cfg
我确实想提供服务。在 /etc/systemd/system 中创建 ha.service 文件
[Unit]
Description=ha.service
[Service]
Type=simple
User=test
WorkingDirectory=/data/haproxy/
ExecStart=/data/haproxy/haproxy -f /etc/haproxy/haproxy.cfg
SyslogIdentifier=ha.service-log
Restart=always
[Install]
WantedBy=multi-user.target
后:
systemctl daemon-reload && systemctl start ha.service && systemctl status ha.service
结果服务确实启动了,并且 1-2 秒前关闭了:
Jul 18 15:41:26 ser-app-0001 systemd[1]: ha.service holdoff time over, scheduling restart.
Jul 18 15:41:26 ser-app-0001 systemd[1]: Started ha.service.
Jul 18 15:41:26 ser-app-0001 systemd[1]: Starting ha.service...
Jul 18 15:41:26 ser-app-0001 ha.service-log[5871]: [WARNING] 198/154126 (5871) : config : 'option forwardfor' ignored for frontend 'https-in' as it requires HTTP mode.
Jul 18 15:41:26 ser-app-0001 ha.service-log[5871]: [WARNING] 198/154126 (5871) : config : 'option forwardfor' ignored for backend 'https-servers-basic' as it requires HTTP mode.
Jul 18 15:41:26 ser-app-0001 ha.service-log[5871]: [WARNING] 198/154126 (5871) : config : 'option forwardfor' ignored for backend 'https-servers-redirect' as it requires HTTP mode.
Jul 18 15:41:26 ser-app-0001 ha.service-log[5871]: [WARNING] 198/154126 (5871) : config : 'option forwardfor' ignored for backend 'https-servers-service' as it requires HTTP mode.
Jul 18 15:41:26 ser-app-0001 systemd[1]: ha.service holdoff time over, scheduling restart.
Jul 18 15:41:26 ser-app-0001 systemd[1]: start request repeated too quickly for ha.service
Jul 18 15:41:26 ser-app-0001 systemd[1]: Failed to start ha.service.
Jul 18 15:41:26 ser-app-0001 systemd[1]: Unit ha.service entered failed state.
Jul 18 15:41:26 ser-app-0001 systemd[1]: ha.service failed.
如何解决这个问题?