安装配置
centos7 直接yum源安装
安装supervisor
yum -y install supervisor
设置开机自启
systemctl enable supervisord
配置Java环境(tomcat依赖)
使用xshell的话直接命令选择文件位置
rz -e
解压
tar -zxvf jdk-8u60-linux-x64.tar.gz -C /usr/local/
属主属组
chown -R root.root /usr/local/jdk1.8.0_60
追加配置文件环境
cat>>/etc/profile<<\EOF
###jdk环境###
export JAVA_HOME=/usr/local/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
EOF
使用cat 后面加EOF "/"是不解析变量
source /etc/profile
查看Java版本
Java -version
或者
Java -V
安装tomcat
上传包
rz -e
解压tar zxf tomcat包
创建目录
mkdir -p /opt/新的目录名
cp -a tomcat解压文件/* /op/新的目录名
创建supervisor管理tomcat的子配置文件:
vim /etc/supervisord.d/ 自定义.ini
[program:自定义]
command=/opt/新的目录名/bin/catalina.sh run
environment=JAVA_HOME="/usr/local/jdk1.8.0_60",JAVA_BIN="/usr/local/jdk1.8.0_60/bin"
directory=/opt/新的目录名/bin/
numprocs=1
user = root
autostart = true
autorestart=true
startsecs = 5
命令行模式:
supervisorctl status 查看状态
supervisorctl stop tomcat 宕掉tomcat
supervisorctl start tomcat 启动tomcat
supervisorctl restart tomcat 重启tomcat
supervisorctl reread 读取当前运行配置和program配置文件的差异
supervisorctl update 重载配置文件并重启受影响的program
交互模式
[root@ c7-41 tmp]# supervisorctl
app01 RUNNING pid 3227, uptime 0:13:49
supervisor> help
default commands (type help <topic>):
=====================================
add exit open reload restart start tail
avail fg pid remove shutdown status update
clear maintail quit reread signal stop version
supervisor> status
app01 RUNNING pid 3227, uptime 0:14:40
supervisor> stop app01
app01: stopped
自带管理界面
端口+9001
出于安全考虑,默认配置是没有开启web管理界面,需要修改supervisord.conf配置文件打开http访权限,
;[inet_http_server] ; inet (TCP) server disabled by default
;port=127.0.0.1:9001 ; (ip_address:port specifier, *:port for all iface)
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
修改成
[inet_http_server] ; inet (TCP) server disabled by default
port=10.0.0.41:9001 ; (ip_address:port specifier, *:port for all iface)
username=user ; (default is no username (open server))
password=123 ; (default is no password (open server))
port:绑定访问IP和端口,这里是绑定的是本地IP和9001端口
username:登录管理后台的用户名
password:登录管理后台的密码
常见的启动报错
[root@ sfaapp9 logs]# supervisorctl
dealer-update-38021-8055-99 FATAL Exited too quickly (process log may have details)
[root@ sfaapp9 conf.d]# killall java
[root@ sfaapp9 conf.d]# ps -ef|grep sup
root 16928 1 0 22:21 ? 00:00:00 /usr/bin/python /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
root 17109 15876 0 22:42 pts/3 00:00:00 grep sup
[root@ sfaapp9 conf.d]# kill -9 16928
[root@ sfaapp9 conf.d]# /etc/init.d/supervisord start
此报错,要关掉所有supervisor管理的进程和supervisor本身进程,然后重启启动supervisor。