问题列表
- 问题一: 下载supervisor相关的tar.gz包速度太慢,经常丢失网络连接
- 问题二:执行echo_supervisord_conf > /etc/supervisord.conf 报错权限不足
- 问题三:执行echo_supervisord_conf > /etc/supervisord.conf 报错DistributionNotFound
- 问题四:因参考github里meld3解决方案导致pip不可用
- 问题五:执行supervisorctl status报错supervisord responded but did not recognize the supervisor namespace
- 问题六:执行supervisorctl status报错unix:///var/lock/supervisor.sock no such file
- 问题七: 执行supervisorctl status报错unix:///var/lock/supervisor.sock refused connection
- 问题八:配置一个java服务完毕后进行启动:supervisorctl start springboot-test,报错:springboot-test: ERROR (no such process)
- 问题九:supervisorctl start springboot-test,报错:ERROR (spawn error)
- 问题十: 外网通过ip+端口号无法访问springboot-test服务
问题一: 下载supervisor相关的tar.gz包速度太慢,经常丢失网络连接
解决方式:
方案1:
在windows环境下下载好,然后上传到linux的环境下,再执行相关命令进行安装。
方案2:
换个安装方式,例如:supervisor有多种安装方式,一种是setuptools安装,一种是python安装。python安装连接超时,就使用第一种方案安装。
问题二:执行echo_supervisord_conf > /etc/supervisord.conf 报错权限不足
这一步,出现了Permission denied,在命令前面加上sudo,仍然出现权限问题,使用su转到root用户
我配置了几次,都只有root用户可以执行.后来查了一下文档才发现,一定要有root权限才可以.
问题三:执行echo_supervisord_conf > /etc/supervisord.conf 报错DistributionNotFound
Traceback (most recent call last):
File "/bin/echo_supervisord_conf", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3007, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 728, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: meld3>=0.6.5
原因:pip安装的meld3不可用,手动安装。
wget https://pypi.python.org/packages/source/m/meld3/meld3-1.0.2.tar.gz
tar -zxf meld3-1.0.2.tar.gz
cd meld3-1.0.2
python setup.py install
感谢https://www.cnblogs.com/hubery/p/5653007.html 文章提供的方法!这个问题困扰了好久,github页面(https://github.com/Supervisor/meld3/issues/23)提供的解决方案都不可行,反而导致pip都不能用了。
问题四:因参考github里meld3解决方案导致pip不可用
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 957, in <module>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 961, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 188, in get_supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 391, in get_build_platform from sysconfig import get_platform
ImportError: No module named sysconfig
解决方案:删除/site-packages
下面的包,重新安装python-setuptools:
rm -rf /usr/lib/python2.6/site-packages/pkg_resources*
yum reinstall python-setuptools
问题五:执行supervisorctl status报错supervisord responded but did not recognize the supervisor namespace
修改/etc/supervisor/supervisord.conf配置文件,增加如下信息:
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
问题六:执行supervisorctl status报错unix:///var/lock/supervisor.sock no such file
到var/lock/目录下创建文件:supervisor.sock
vim /var/lock/supervisor.sock
问题七: 执行supervisorctl status报错unix:///var/lock/supervisor.sock refused connection
重启supervisor服务,由于不知道具体的重启方法,所以通过ps -ef |grep supervisor找到pid,通过进程号kill。
kill掉进程后通过如下命令启动服务。
service supervisord start
问题八:配置一个java服务完毕后进行启动:supervisorctl start springboot-test,报错:springboot-test: ERROR (no such process)
问题原因:配置java服务的conf文件错误。
[program:mohurd-search]
directory = /home/liu/java/websocket-demo ; 程序的启动目录
command = java -Xms256m -Xmx512m -Dserver.port=8081 -jar /home/liu/java/websocket-demo/spring-boot-websocket-demo-1.0.0.jar ; 启动命令,可以看出与手动在命令行启动的命令是一样的
autostart = true ; 在 supervisord 启动的时候也自动启动
startsecs = 30 ; 启动 30 秒后没有异常退出,就当作已经正常启动了
autorestart = true ; 程序异常退出后自动重启
startretries = 3 ; 启动失败自动重试次数,默认是 3
user = liu ; 用哪个用户启动
redirect_stderr = true ; 把 stderr 重定向到 stdout,默认 false
stdout_logfile_maxbytes = 20MB ; stdout 日志文件大小,默认 50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数
; stdout 日志文件,需要注意当指定目录不存在时无法正常启动,所以需要手动创建目录(supervisord 会自动创建日志文件)
stdout_logfile = /home/liu/log ;应用日志目录
第一行定义了program的名称,这就是要通过supervisor启动的服务的名称,而命令执行的是supervisorctl start springboot-test,即启动一个服务名为springboot-test的服务,显然是找不到此process的。
解决方案:修改springboot-test.conf中定义的program名。
修改完毕后重启supervisor,执行启动命令:
supervisorctl reload
supervisorctl start springboot-test
好像不需要重启也可以重新加载配置:
# 读取有更新(增加)的配置文件,不会启动新添加的程序 supervisorctl reread # 重启配置文件修改过的程序 supervisorctl update # 关闭程序 supervisorctl stop springboot-test # 启动程序 supervisorctl start springboot-test # 重启 supervisorctl restart springboot-test
问题九:supervisorctl start springboot-test,报错:ERROR (spawn error)
通过 supervisorctl status
,可以看到运行状态:
springboot-test FATAL unknown error making dispatchers for 'springboot-test': EISDIR
这里的信息太少,我们需要到具体的日志中查看到底出了什么问题。
tail -20 /var/log/supervisord.log
2020-01-02 21:20:13,830 INFO spawnerr: unknown error making dispatchers for 'mohurd-search': EISDIR
2020-01-02 21:20:16,837 INFO spawnerr: unknown error making dispatchers for 'mohurd-search': EISDIR
2020-01-02 21:20:16,837 INFO gave up: mohurd-search entered FATAL state, too many start retries too quickly
2020-01-02 21:24:18,912 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2020-01-02 21:24:18,913 INFO Included extra file "/etc/supervisor/conf.d/springboot-test.conf" during parsing
2020-01-02 21:24:18,917 INFO RPC interface 'supervisor' initialized
2020-01-02 21:24:18,917 CRIT Server 'inet_http_server' running without any HTTP authentication checking
2020-01-02 21:24:18,918 INFO RPC interface 'supervisor' initialized
2020-01-02 21:24:18,918 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-01-02 21:24:18,918 INFO supervisord started with pid 9687
2020-01-02 21:24:19,921 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:20,928 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:22,932 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:25,940 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:25,940 INFO gave up: springboot-test entered FATAL state, too many start retries too quickly
2020-01-02 21:24:28,200 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:29,210 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:31,216 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:34,229 INFO spawnerr: unknown error making dispatchers for 'springboot-test': EISDIR
2020-01-02 21:24:34,229 INFO gave up: springboot-test entered FATAL state, too many start retries too quickly
看最下面的几行,貌似也看不出太多的东西,最后在网上看到有人说是log文件配置错误,就去检查了一下springboot-test服务的配置文件,发现配置文件果然有问题:
stdout_logfile = /home/liu/log ;应用日志目录
只指定了目录并没有指定log文件,修改日志配置为:
stdout_logfile = /home/liu/log/springboot-test.log ;应用日志目录
这时候再使用supervisorctl status命令检查状态:
[root@localhost log]# supervisorctl status
springboot-test RUNNING pid 13177, uptime 0:25:36
问题十: 外网通过ip+端口号无法访问springboot-test服务
通过ps -ef |grep java
查看java进程,发现springboot-test已经启动了。
通过curl访问指定接口也有信息返回。
在虚拟机外通过ip+端口号的方式可以访问supervisor的管理页面。
但是在虚拟机外通过ip+端口号的方式仍无法访问springboot-test服务。
问题原因:防火墙没有对外暴露8081端口
解决方案:
#firewall-cmd --zone=public --add-port=8081/tcp --permanent
#firewall-cmd --reload
说明:
–zone 作用域
–add-port=8080/tcp 添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效