Rootop 服务器运维与web架构

2019-08-13
发表者 Venus
docker swarm 清理非Up状态容器已关闭评论

docker swarm 清理非Up状态容器

[root@m ~]# docker service update ··· # 更新服务

更新服务镜像后,发现旧的容器没有删除,变为Exited(Exited、Shutdown等)状态,查资料也没有说多久会删除。
(放了两个周也没自动清理),可能旧容器会一直存在,有其它用处。
有文章称保留是为了服务回滚操作。反正看着没啥用,就找删除方法。
在docker版本1.13之后可以用命令清理。

# 查看相关清理命令

[root@m ~]# docker system --help

Usage:	docker system COMMAND

Manage Docker

Commands:
  df          Show docker disk usage
  events      Get real time events from the server
  info        Display system-wide information
  prune       Remove unused data

# 清理命令相关参数

[root@m ~]# docker system prune --help

Usage:	docker system prune [OPTIONS]

Remove unused data

Options:
  -a, --all             Remove all unused images not just dangling ones
      --filter filter   Provide filter values (e.g. 'label=<key>=<value>')
  -f, --force           Do not prompt for confirmation
      --volumes         Prune volumes

通过 -a 参数可以清理未使用的镜像,-f 强制删除,不提示确认。

# 清理旧容器及不用的镜像

[root@m ~]# docker system prune -a -f

可以添加到任务计划里定时清理,或者是更新完服务测试后没问题通过脚本批量清理。

2019-08-06
发表者 Venus
jenkins删除历史构建已关闭评论

jenkins删除历史构建

原文:https://www.cnblogs.com/shaobin0604/p/9680621.html
找到 系统管理 – 脚本命令行

def jobName = "Some_Job_Name"
def maxNumber = 64

Jenkins.instance.getItemByFullName(jobName).builds.findAll {
  it.number <= maxNumber
}.each {
  it.delete()
}

jobName 是项目名称
maxNumber 是删除多少个

2019-07-31
发表者 Venus
php提示File not found.已关闭评论

php提示File not found.

server {
    listen       80;
    server_name  localhost;

    access_log  /etc/nginx/conf.d/access.log  main;
    error_log   /etc/nginx/conf.d/error.log;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        root           /home/php;
        fastcgi_pass   php:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

当nginx匹配到扩展名是php后,交由php-fpm处理,fpm会去 root 定义的目录下执行相应的php脚本。

fastcgi_param 默认配置:

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name; 
默认是去 /scripts 目录下找对应的请求文件,就会报错提示:File not found.

改为:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

就会去读 root 参数定义的目录

nginx中多个location段中可以配置不同的 root 参数。

另外一次遇到这个错误是nginx运行用户和php-fpm运行用户不一致导致的,但是在后来搭建测试环境没有再复现这个问题,若遇到修改上面路径不生效,可以看一下两者用户是否一致。

注意浏览器报的错误信息很模糊,需要结合访问日志去排查问题。

注意:nginx是告诉php-fpm请求文件的路径,而不是把代码文件读出来交给php-fpm。

当nginx和php-fpm不在同一台机器(比如docker中),就需要同时建立相同的路径。

2019-07-24
发表者 Venus
xftp找不到匹配的outgoing encryption算法已关闭评论

xftp找不到匹配的outgoing encryption算法

xshell能连上服务器,但是xftp报错:找不到匹配的outgoing encryption算法。

解决:注意是修改xftp,不是改xshell。

再重新打开xftp就可以连接。