折腾:
【未解决】阿里云中二级域名转发中如何实现端口转发
期间,去用systemctl重启nginx出错:
[root@xxx nginx]# systemctl restart nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@xxx nginx]# systemctl status nginx.service ● nginx.service - LSB: starts the nginx web server Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2018-11-19 16:01:12 CST; 6s ago Docs: man:systemd-sysv-generator(8) Process: 4274 ExecStop=/etc/rc.d/init.d/nginx stop (code=exited, status=1/FAILURE) Process: 4260 ExecReload=/etc/rc.d/init.d/nginx reload (code=exited, status=0/SUCCESS) Process: 4327 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE) CGroup: /system.slice/nginx.service ├─1237 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf ├─1241 nginx: worker process ├─1243 nginx: worker process └─1244 nginx: cache manager process Nov 19 16:01:12 xxx systemd[1]: Starting LSB: starts the nginx web server... Nov 19 16:01:12 xxx nginx[4327]: Starting nginx... nginx (pid 1244 1243 1241 1237) already running. Nov 19 16:01:12 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:01:12 xxx systemd[1]: Failed to start LSB: starts the nginx web server. Nov 19 16:01:12 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:01:12 xxx systemd[1]: nginx.service failed.
好像已经正在运行,导致无法重启?
先去stop试试:
[root@xxx nginx]# systemctl stop nginx [root@xxx nginx]# systemctl start nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@xxx nginx]# systemctl status nginx.service ● nginx.service - LSB: starts the nginx web server Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2018-11-19 16:03:10 CST; 7s ago Docs: man:systemd-sysv-generator(8) Process: 4274 ExecStop=/etc/rc.d/init.d/nginx stop (code=exited, status=1/FAILURE) Process: 4260 ExecReload=/etc/rc.d/init.d/nginx reload (code=exited, status=0/SUCCESS) Process: 4354 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE) CGroup: /system.slice/nginx.service ├─1237 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf ├─1241 nginx: worker process ├─1243 nginx: worker process └─1244 nginx: cache manager process Nov 19 16:03:10 xxx systemd[1]: Starting LSB: starts the nginx web server... Nov 19 16:03:10 xxx nginx[4354]: Starting nginx... nginx (pid 1244 1243 1241 1237) already running. Nov 19 16:03:10 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:03:10 xxx systemd[1]: Failed to start LSB: starts the nginx web server. Nov 19 16:03:10 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:03:10 xxx systemd[1]: nginx.service failed. [root@xxx nginx]# journalctl -xe Nov 19 16:01:12 xxx polkitd[470]: Registered Authentication Agent for unix-process:4321:2047584220 (system bus name :1.80170 [/usr/bin/pkttyagent --notify-fd 5 --fallback], ob Nov 19 16:01:12 xxx systemd[1]: Starting LSB: starts the nginx web server... -- Subject: Unit nginx.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nginx.service has begun starting up. Nov 19 16:01:12 xxx nginx[4327]: Starting nginx... nginx (pid 1244 1243 1241 1237) already running. Nov 19 16:01:12 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:01:12 xxx systemd[1]: Failed to start LSB: starts the nginx web server. -- Subject: Unit nginx.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nginx.service has failed. -- -- The result is failed. Nov 19 16:01:12 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:01:12 xxx systemd[1]: nginx.service failed. Nov 19 16:01:12 xxx polkitd[470]: Unregistered Authentication Agent for unix-process:4321:2047584220 (system bus name :1.80170, object path /org/freedesktop/PolicyKit1/Authent Nov 19 16:03:06 xxx polkitd[470]: Registered Authentication Agent for unix-process:4342:2047595648 (system bus name :1.80171 [/usr/bin/pkttyagent --notify-fd 5 --fallback], ob Nov 19 16:03:06 xxx polkitd[470]: Unregistered Authentication Agent for unix-process:4342:2047595648 (system bus name :1.80171, object path /org/freedesktop/PolicyKit1/Authent Nov 19 16:03:10 xxx polkitd[470]: Registered Authentication Agent for unix-process:4348:2047596005 (system bus name :1.80172 [/usr/bin/pkttyagent --notify-fd 5 --fallback], ob Nov 19 16:03:10 xxx systemd[1]: Starting LSB: starts the nginx web server... -- Subject: Unit nginx.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nginx.service has begun starting up. Nov 19 16:03:10 xxx nginx[4354]: Starting nginx... nginx (pid 1244 1243 1241 1237) already running. Nov 19 16:03:10 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:03:10 xxx systemd[1]: Failed to start LSB: starts the nginx web server. -- Subject: Unit nginx.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit nginx.service has failed. -- -- The result is failed. Nov 19 16:03:10 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:03:10 xxx systemd[1]: nginx.service failed. Nov 19 16:03:10 xxx polkitd[470]: Unregistered Authentication Agent for unix-process:4348:2047596005 (system bus name :1.80172, object path /org/freedesktop/PolicyKit1/Authent -- Logs begin at Sat 2018-01-27 22:55:47 CST, end at Mon 2018-11-19 16:03:10 CST. -- Nov 18 03:01:01 xxx anacron[31333]: Will run job `cron.daily' in 12 min. Nov 18 03:01:01 xxx anacron[31333]: Jobs will be executed sequentially Nov 18 03:01:01 xxx run-parts(/etc/cron.hourly)[31335]: finished 0anacron Nov 18 03:10:01 xxx systemd[1]: Started Session 39813 of user root. -- Subject: Unit session-39813.scope has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit session-39813.scope has finished starting up. -- -- The start-up result is done. Nov 18 03:10:01 xxx CROND[31352]: (root) CMD (/usr/lib64/sa/sa1 1 1) Nov 18 03:10:01 xxx systemd[1]: Starting Session 39813 of user root. -- Subject: Unit session-39813.scope has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit session-39813.scope has begun starting up. Nov 18 03:13:01 xxx anacron[31333]: Job `cron.daily' started Nov 18 03:13:01 xxx run-parts(/etc/cron.daily)[31364]: starting logrotate Nov 18 03:13:01 xxx rsyslogd[477]: [origin software="rsyslogd" swVersion="8.24.0" x-pid="477" x-info=" http://www.rsyslog.com "] rsyslogd was HUPed Nov 18 03:13:01 xxx run-parts(/etc/cron.daily)[31373]: finished logrotate Nov 18 03:13:01 xxx run-parts(/etc/cron.daily)[31375]: starting man-db.cron Nov 18 03:13:01 xxx run-parts(/etc/cron.daily)[31384]: finished man-db.cron Nov 18 03:13:01 xxx anacron[31333]: Job `cron.daily' terminated Nov 18 03:13:01 xxx anacron[31333]: Normal exit (1 job run) Nov 18 03:20:01 xxx systemd[1]: Started Session 39814 of user root. -- Subject: Unit session-39814.scope has finished start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
还是出错。
原因好像是这几行:
Nov 19 16:01:12 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:01:12 xxx systemd[1]: nginx.service failed. Nov 19 16:01:12 xxx polkitd[470]: Unregistered Authentication Agent for unix-process:4321:2047584220 (system bus name :1.80170, object path /org/freedesktop/PolicyKit1/Authent Nov 19 16:03:06 xxx polkitd[470]: Registered Authentication Agent for unix-process:4342:2047595648 (system bus name :1.80171 [/usr/bin/pkttyagent --notify-fd 5 --fallback], ob Nov 19 16:03:06 xxx polkitd[470]: Unregistered Authentication Agent for unix-process:4342:2047595648 (system bus name :1.80171, object path /org/freedesktop/PolicyKit1/Authent Nov 19 16:03:10 xxx polkitd[470]: Registered Authentication Agent for unix-process:4348:2047596005 (system bus name :1.80172 [/usr/bin/pkttyagent --notify-fd 5 --fallback], ob
Unit nginx.service entered failed state Unregistered Authentication Agent for unix-process
[root@xxx nginx]# nginx -t nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok nginx: configuration file /www/server/nginx/conf/nginx.conf test is successful
配置没错。
[root@xxx nginx]# cat /www/wwwlogs/nginx_error.log 2018/03/27 11:39:50 [crit] 1228#0: *1 connect() to unix:/tmp/php-cgi-56.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /phpfpm_56_status HTTP/1.1", upstream: " fastcgi://unix:/tmp/php-cgi-56.sock :", host: "127.0.0.1" 2018/03/27 11:39:50 [crit] 1228#0: *3 connect() to unix:/tmp/php-cgi-56.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /phpfpm_56_status HTTP/1.1", upstream: " fastcgi://unix:/tmp/php-cgi-56.sock :", host: "127.0.0.1"
此处新加二级域名的
access的log都是空的:
[root@xxx nginx]# ll /www/wwwlogs/ total 10264 -rw-r--r-- 1 root root 0 Jan 27 2018 access.log -rw-r--r-- 1 root root 0 Nov 19 16:07 dev.xxx.log -rw-r--r-- 1 root root 588 Mar 27 2018 nginx_error.log drwxr--r-- 2 www www 4096 Jan 27 2018 waf -rw-r--r-- 1 root root 10494633 Nov 19 16:08 www.xxx.log
去强制关闭nginx的进程:
[root@xxx nginx]# ps -ef | grep nginx root 1237 1 0 Mar27 ? 00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf www 1241 1237 0 Mar27 ? 00:00:24 nginx: worker process www 1243 1237 0 Mar27 ? 00:00:47 nginx: worker process www 1244 1237 0 Mar27 ? 00:01:45 nginx: cache manager process root 4379 4043 0 16:09 pts/1 00:00:00 grep --color=auto nginx [root@xxx nginx]# kill -9 1241 [root@xxx nginx]# kill -9 1243 [root@xxx nginx]# kill -9 1244 [root@xxx nginx]# ps -ef | grep nginx root 1237 1 0 Mar27 ? 00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf www 4385 1237 0 16:10 ? 00:00:00 nginx: worker process www 4386 1237 0 16:10 ? 00:00:00 nginx: worker process www 4387 1237 0 16:10 ? 00:00:00 nginx: cache manager process root 4395 4043 0 16:10 pts/1 00:00:00 grep --color=auto nginx [root@xxx nginx]# kill -9 4385 [root@xxx nginx]# ps -ef | grep nginx root 1237 1 0 Mar27 ? 00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf www 4386 1237 0 16:10 ? 00:00:00 nginx: worker process www 4387 1237 0 16:10 ? 00:00:00 nginx: cache manager process www 4396 1237 0 16:10 ? 00:00:00 nginx: worker process root 4402 4043 0 16:10 pts/1 00:00:00 grep --color=auto nginx
发现不对,需要去关闭主进程:
[root@xxx nginx]# kill -9 1237 [root@xxx nginx]# ps -ef | grep nginx www 4386 1 0 16:10 ? 00:00:00 nginx: worker process www 4387 1 0 16:10 ? 00:00:00 nginx: cache manager process www 4396 1 0 16:10 ? 00:00:00 nginx: worker process root 4404 4043 0 16:11 pts/1 00:00:00 grep --color=auto nginx [root@xxx nginx]# kill -9 4386 4387 4396 [root@xxx nginx]# ps -ef | grep nginx root 4411 4043 0 16:11 pts/1 00:00:00 grep --color=auto nginx
然后再去启动
[root@xxx nginx]# service nginx start Starting nginx... nginx (pid 4428 4427 4426 4425 4424) already running. [root@xxx nginx]# service nginx status nginx (pid 4427 4426 4425 4424) already running.
貌似可以了?
[root@xxx nginx]# systemctl status nginx ● nginx.service - LSB: starts the nginx web server Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2018-11-19 16:03:10 CST; 9min ago Docs: man:systemd-sysv-generator(8) Process: 4274 ExecStop=/etc/rc.d/init.d/nginx stop (code=exited, status=1/FAILURE) Process: 4260 ExecReload=/etc/rc.d/init.d/nginx reload (code=exited, status=0/SUCCESS) Process: 4354 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE) Nov 19 16:03:10 xxx systemd[1]: Starting LSB: starts the nginx web server... Nov 19 16:03:10 xxx nginx[4354]: Starting nginx... nginx (pid 1244 1243 1241 1237) already running. Nov 19 16:03:10 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:03:10 xxx systemd[1]: Failed to start LSB: starts the nginx web server. Nov 19 16:03:10 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:03:10 xxx systemd[1]: nginx.service failed.
还是有问题啊
好像和防火墙firewalld firewall有关系?
[root@xxx nginx]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2018-03-27 16:17:14 CST; 7 months 23 days ago Docs: man:firewalld(1) Main PID: 500 (firewalld) CGroup: /system.slice/firewalld.service └─500 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid Mar 27 16:17:14 xxx systemd[1]: Starting firewalld - dynamic firewall daemon... Mar 27 16:17:14 xxx systemd[1]: Started firewalld - dynamic firewall daemon. Mar 27 16:17:15 xxx firewalld[500]: WARNING: ICMP type 'beyond-scope' is not supported by the kernel for ipv6. Mar 27 16:17:15 xxx firewalld[500]: WARNING: beyond-scope: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. Mar 27 16:17:15 xxx firewalld[500]: WARNING: ICMP type 'failed-policy' is not supported by the kernel for ipv6. Mar 27 16:17:15 xxx firewalld[500]: WARNING: failed-policy: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time. Mar 27 16:17:15 xxx firewalld[500]: WARNING: ICMP type 'reject-route' is not supported by the kernel for ipv6. Mar 27 16:17:15 xxx firewalld[500]: WARNING: reject-route: INVALID_ICMPTYPE: No supported ICMP type., ignoring for run-time.
此处是正常的。
难道是:
此处想要转发:
结果当前服务器不支持访问外部服务器xxx的33800端口?
但是此处删除刚刚加上的nginx的配置,结果还是出错:
[root@xxx nginx]# rm -f dev.xxx.conf [root@xxx nginx]# systemctl reload nginx Job for nginx.service invalid. [root@xxx nginx]# service reload nginx The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl. [root@xxx nginx]# service restart nginx The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl. [root@xxx nginx]# systemctl restart nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@xxx nginx]# systemctl start nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@xxx nginx]# systemctl nginx start Unknown operation 'nginx'. [root@xxx nginx]# systemctl nginx start^C
结果发现stop后,再去status,依旧是之前的错误:
[root@xxx nginx]# systemctl stop nginx [root@xxx nginx]# systemctl start nginx Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. [root@xxx nginx]# systemctl status nginx ● nginx.service - LSB: starts the nginx web server Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2018-11-19 16:25:02 CST; 4s ago Docs: man:systemd-sysv-generator(8) Process: 4274 ExecStop=/etc/rc.d/init.d/nginx stop (code=exited, status=1/FAILURE) Process: 4260 ExecReload=/etc/rc.d/init.d/nginx reload (code=exited, status=0/SUCCESS) Process: 4569 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE) Nov 19 16:25:02 xxx systemd[1]: Starting LSB: starts the nginx web server... Nov 19 16:25:02 xxx nginx[4569]: Starting nginx... nginx (pid 4427 4426 4425 4424) already running. Nov 19 16:25:02 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:25:02 xxx systemd[1]: Failed to start LSB: starts the nginx web server. Nov 19 16:25:02 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:25:02 xxx systemd[1]: nginx.service failed. [root@xxx nginx]# systemctl stop nginx [root@xxx nginx]# systemctl status nginx ● nginx.service - LSB: starts the nginx web server Loaded: loaded (/etc/rc.d/init.d/nginx; bad; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2018-11-19 16:25:02 CST; 9s ago Docs: man:systemd-sysv-generator(8) Process: 4274 ExecStop=/etc/rc.d/init.d/nginx stop (code=exited, status=1/FAILURE) Process: 4260 ExecReload=/etc/rc.d/init.d/nginx reload (code=exited, status=0/SUCCESS) Process: 4569 ExecStart=/etc/rc.d/init.d/nginx start (code=exited, status=1/FAILURE) Nov 19 16:25:02 xxx systemd[1]: Starting LSB: starts the nginx web server... Nov 19 16:25:02 xxx nginx[4569]: Starting nginx... nginx (pid 4427 4426 4425 4424) already running. Nov 19 16:25:02 xxx systemd[1]: nginx.service: control process exited, code=exited status=1 Nov 19 16:25:02 xxx systemd[1]: Failed to start LSB: starts the nginx web server. Nov 19 16:25:02 xxx systemd[1]: Unit nginx.service entered failed state. Nov 19 16:25:02 xxx systemd[1]: nginx.service failed.
好像此处reload,stop,start等,根本没生效
换成service是可以的:
[root@xxx nginx]# service nginx stop Stoping nginx... done [root@xxx nginx]# service nginx status nginx is stopped [root@xxx nginx]# service nginx start Starting nginx... done [root@xxx nginx]# service nginx status nginx (pid 4627 4626 4625 4624 4623) already running.
那或许是:
此处的systemct命令本身有问题?
那再去加上二级域名转发配置,然后再去用service启动试试:
[root@xxx nginx]# ll total 216 -rw------- 1 root root 1370 Mar 15 2018 phpfpm_status.conf -rw-r--r-- 1 root root 544 Mar 15 2018 phpinfo.conf -rw-r--r-- 1 root root 1206 Mar 15 2018 www.xxx.conf -rw-r--r-- 1 root root 207476 Nov 19 16:19 ystemctl status firewalld.service [root@xxx nginx]# rz rz waiting to receive. Starting zmodem transfer. Press Ctrl+C to cancel. Transferring dev.xxx.conf ... 100% 500 bytes 500 bytes/sec 00:00:01 0 Errors [root@xxx nginx]# ll total 220 -rw-r--r-- 1 root root 500 Nov 19 16:00 dev.xxx.conf -rw------- 1 root root 1370 Mar 15 2018 phpfpm_status.conf -rw-r--r-- 1 root root 544 Mar 15 2018 phpinfo.conf -rw-r--r-- 1 root root 1206 Mar 15 2018 www.xxx.conf -rw-r--r-- 1 root root 207476 Nov 19 16:19 ystemctl status firewalld.service [root@xxx nginx]# serice stop nginx -bash: serice: command not found [root@xxx nginx]# serice nginx stop -bash: serice: command not found [root@xxx nginx]# service nginx stop Stoping nginx... done [root@xxx nginx]# service nginx status nginx is stopped [root@xxx nginx]# service nginx start Starting nginx... done [root@xxx nginx]# service nginx status nginx (pid 4692 4691 4690 4689 4688) already running.
貌似没问题。
那先不去试试systemctl了。
【总结】
在此处用:
nginx -t
确定配置文件语法没问题。
以及用service:
service nginx stop service nginx start service nginx status
都可以正常控制nginx的前提下。
但是用systemctl:
systemctl stop nginx systemctl start nginx
却始终出错。然后找了半天也找不到原因。
暂时不去管了。先用service去操作nginx吧。
转载请注明:在路上 » 【不去解决】systemctl restart nginx出错:Unit nginx.service entered failed state Unregistered Authentication Agent for unix-process