查看并发数
web服务器进程数
netstat -antp | grep 80 | grep ESTABLISHED -c
netstat -an | grep ESTABLISHED | wc -l
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
设你要限制端口8388的IP最大连接数为5
iptables -I INPUT -p tcp --dport 8388 -m connlimit --connlimit-above 15 -j DROP
iptables -I OUTPUT -p tcp --dport 8388 -m connlimit --connlimit-above 15 -j DROP
限制某个端口段 连接数
iptables -I INPUT -p tcp --dport 1024:10240 -m connlimit --connlimit-above 15 -j DROP
iptables -I OUTPUT -p tcp --dport 1024:10240 -m connlimit --connlimit-above 15 -j DROP
如何解决防火墙重启后失败的问题
iptables-save >/etc/sysconfig/iptables
echo 'iptables-restore /etc/sysconfig/iptables' >> /etc/rc.local
chmod +x /etc/rc.d/rc.local
先备份iptables
\# <!--cp /etc/sysconfig/iptables /var/tmp-->
**2.然后保存iptables**
\`# service iptables save`
**3.重启防火墙**
\`#service iptables restart`
查看Nginx运行进程数
ps -ef | grep nginx | wc -l返回的数字就是nginx的运行进程数,如果是apache则执行
ps -ef | grep httpd | wc -l
ps -axef | grep mysqld -c
一些说明
netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,"t",state[key]}'返回结果一般如下:
LAST_ACK 5 (正在等待处理的请求数)
SYN_RECV 30
ESTABLISHED 1597 (正常数据传输状态)
FIN_WAIT1 51
FIN_WAIT2 504
TIME_WAIT 1057 (处理完毕,等待超时结束的请求数)
其他参数说明:
CLOSED:无连接是活动的或正在进行
LISTEN:服务器在等待进入呼叫
SYN_RECV:一个连接请求已经到达,等待确认
SYN_SENT:应用已经开始,打开一个连接
ESTABLISHED:正常数据传输状态
FIN_WAIT1:应用说它已经完成
FIN_WAIT2:另一边已同意释放
ITMED_WAIT:等待所有分组死掉
CLOSING:两边同时尝试关闭
TIME_WAIT:另一边已初始化一个释放
LAST_ACK:等待所有分组死掉
cron 进程守护配置
[program:cron]
command=command=cron -f
autostart=true
autorestart=false
stderr_logfile=/var/log/cron.err.log
stdout_logfile=/var/log/cron.out.log
/root/.cache/composer/files/dragonmantank/cron-expression
./etc/pam.d/cron
./etc/cron.d
./etc/supervisor/conf.d/cron.conf
./etc/crontab
./etc/cron.weekly
./etc/cron.monthly
./etc/cron.daily
./etc/default/cron
./etc/cron.hourly
./etc/init.d/cron
./lib/systemd/system/cron.service
./var/spool/cron
./var/spool/cron/crontabs
./var/log/supervisor/cron-stdout---supervisor-wuVbwB.log
./var/log/supervisor/cron-stderr---supervisor-YRDrkD.log
./var/lib/dpkg/info/cron.preinst
./var/lib/dpkg/info/cron.postinst
./var/lib/dpkg/info/cron.md5sums
./var/lib/dpkg/info/cron.conffiles
./var/lib/dpkg/info/cron.prerm
./var/lib/dpkg/info/cron.list
./var/lib/dpkg/info/cron.postrm
./var/lib/lxcfs/cgroup/devices/system.slice/cron.service
./var/lib/lxcfs/cgroup/cpu,cpuacct/system.slice/cron.service
./var/lib/lxcfs/cgroup/blkio/system.slice/cron.service
./var/lib/lxcfs/cgroup/memory/system.slice/cron.service
./var/lib/lxcfs/cgroup/pids/system.slice/cron.service
./var/lib/lxcfs/cgroup/name=systemd/system.slice/cron.service
./var/lib/systemd/deb-systemd-helper-enabled/cron.service.dsh-also
./var/lib/systemd/deb-systemd-helper-enabled/multi-user.target.wants/cron.service
./run/crond.reboot
./run/crond.pid
./usr/sbin/cron
./usr/share/bash-completion/completions/crontab
./usr/share/man/man8/cron.8.gz
./usr/share/man/man1/crontab.1.gz
./usr/share/man/man5/crontab.5.gz
./usr/share/bug/cron
./usr/share/sosreport/sos/plugins/cron.py
./usr/share/sosreport/sos/plugins/__pycache__/cron.cpython-36.pyc
./usr/share/doc/sysstat/examples/crontab
查名字下的程序
ps aux | grep
/etc/supervisor/conf.d (配置目录)
supervisorctl
help # 查看帮助
status # 查看程序状态
stop program_name # 关闭 指定的程序
start program_name # 启动 指定的程序
restart program_name # 重启 指定的程序
tail -f program_name # 查看 该程序的日志
update # 重启配置文件修改过的程序(修改了配置,通过这个命令加载新的配置)
也可以直接通过 shell 命令操作:
supervisorctl status
supervisorctl update
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/supervisord
NAME=supervisord
DESC=supervisor
ss 配置参考
[program:ss]
command=ssserver -c /etc/shadowsocks.json
autorestart=true
user=nobody
/usr/lib/python2.7/socket.py
sudo service supervisor stop
sudo service supervisor start
server{
listen 9002;
server_name localhost;
charset utf-8;
location / {
proxy_redirect off;
proxy_set_header Host $host:2450; #注意:这里要加上ngnix要监听的端口号
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://50.116.10.243:2449;
}
}
supervisor 配置文件
/usr/local/nginx/conf/vhost/supervisor.conf
supervisord -c /etc/supervisor/supervisord.conf
/etc/init.d/nginx
/etc/supervisor/supervisord.conf
source /etc/profile
ps -ef | grep /usr/local/nginx/sbin/nginx |grep -v grep > /dev/null
if [ $? != 0 ];then
lnmp nginx restart > /dev/nullf
fi
/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/conf/vhost/
/etc/init.d
/etc/systemd/system
重启设置 生效
supervisord -c /etc/supervisord.conf
ps -ef | grep /supervisord |grep -v grep
/etc/supervisor/conf.d
/usr/bin/python /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf
版权属于:毒奶
联系我们:https://limbopro.com/6.html
毒奶搜索:https://limbopro.com/search.html
机场推荐:https://limbopro.com/865.html IEPL专线/100Gb/¥15/月起
毒奶导航:https://limbopro.com/daohang/index.html本文链接:https://limbopro.com/archives/325.html
本文采用 CC BY-NC-SA 4.0 许可协议,转载或引用本文时请遵守许可协议,注明出处、不得用于商业用途!