作者归档:xinlu

xdebug的nginx配置

修改请求的Cookie信息。如下:
proxy_set_header Cookie “$http_cookie; XDEBUG_SESSION=PHPSTROM”;

完整的一份配置

server {
     listen 80;  #from https port to http port .
     location / {
         proxy_pass   http://127.0.0.1:8080/;
         proxy_set_header Cookie "$http_cookie; XDEBUG_SESSION=PHPSTROM";
         proxy_set_header Host $host;
     }
}

server {
    listen 8080;
    location ~ \.php$ {     
        fastcgi_pass   127.0.0.1:9090;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

Jetbrain的安装包带JBR与不带JBR的区别

以GoLang2019.3.4为例。

带JBR是指该JBR使用的版本为jetbrain公司自家的运行时库。因为该运行时库不是OpenJDK的认证版本,故可能在某个平台上如Centos7.5的平台上,某些时候可能会运行故障。
故应该使用不带JBR标识别的版本,该版本才真正的与openJDK认证的高兼容性的版本。
在centos环境下,建议使用不带JBR的版本

以下是其安装包解压后的差异对比。

gitlab的部署方式

version: '3'

services:
  gitlab:
    image: gitlab/gitlab-ce:11.9.12-ce.0
    restart: always
    container_name: gitlab
    hostname: gitlab.pointsmart.cn
    privileged: true
    user: root
    ports:
      - "80:80"
      - "443:443"
      - "222:22"
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
        gitlab_rails['gitlab_shell_ssh_port'] = 222
        gitlab_rails['gitlab_shell_git_timeout'] = 800
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /data/gitlab/config:/etc/gitlab
      - /data/gitlab/logs:/var/log/gitlab
      - /data/gitlab/data:/var/opt/gitlab

通过进程ID查找容器

for i in  `docker ps -q`;do docker top $i; done
 for i in $(docker ps -q); do docker top $i; done
或
for i in  `docker ps |grep Up|awk '{print $1}'`;do docker top $i; done

nginx的stream模块转发配置

upstream xaio443 {
  server 172.16.0.103:443;
  server 172.16.0.104:443;
}

upstream xaio80 {
  server 172.16.0.103:80;
  server 172.16.0.104:80;
}

log_format proxy '$proxy_protocol_addr $remote_addr [$time_local] '
    '$protocol $status $bytes_sent $bytes_received '
    '$session_time "$upstream_addr" '
    '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

server {
  listen 443;
  ssl_preread on;
  proxy_connect_timeout 1s;
  proxy_timeout 3s;
  proxy_pass xaio443;


  access_log /data/logs/access443.log proxy;
  error_log /data/logs/error443.log info;
}

server {
  listen 80;
  proxy_connect_timeout 1s;
  proxy_timeout 3s;
  proxy_pass xaio80;


  access_log /data/logs/access80.log proxy;
  error_log /data/logs/error80.log info;
}

sh和api服务冲突的解决方案脚本

#!/bin/bash
path_current=`pwd`
path_script=$(cd "$(dirname "$0")"; pwd)

cd ${path_script}
echo "$(date)" >> ./check.txt
podnamspace="-n test"
shpods=$(kubectl describe pods "sh-" ${podnamspace}|grep "^Name:"|awk '{print $2}')
echo ${shpods}
sh_tm_max=0
for sh in ${shpods[@]}
do
  mytime=$(kubectl describe pod ${sh} ${podnamspace}|grep "^Start Time:")&& mytime=$(echo ${mytime:11}) && mytime=$(date -d "$mytime" +%s)
  elapse=$(expr ${sh_tm_max} - ${mytime})
  if [ $? == 0 ] && [ ${elapse} -lt 0 ]; then
     sh_tm_max=${mytime}
  fi
done
echo "sh pods start time: $sh_tm_max"
apipods=$(kubectl describe pods "api-" ${podnamspace}|grep "^Name:"|awk '{print $2}')
echo ${apipods}
for api in ${apipods[@]}
do
  mytime=$(kubectl describe pod ${api} ${podnamspace}|grep "^Start Time:")&& mytime=$(echo ${mytime:11}) && mytime=$(date -d "$mytime" +%s)
  elapse=$(expr ${sh_tm_max} - ${mytime})
  howMinute=$(expr $elapse / 60)
  output="${api} pod start time: $mytime, ${sh_tm_max} - ${mytime}=[${elapse}s, ${howMinute}m]"
  echo "$output" &&  echo "$output" >> ./check.txt
  if [ $? == 0 ] && [ $howMinute -ge 0 ]; then
     echo "delete this pod $api"
     kubectl delete pod $api ${podnamspace} && echo "success to delete $api" >> ./check.txt
  fi
done

kvm虚拟机常用操作

1、修改虚拟机配置如CPU核数或内存等

virsh edit aiodev

2、启动虚拟机

virsh start aiodev

3、停止虚拟机

virsh stop aiodev

4、显示所有运行的虚拟机

virsh list

5、快照创建

virsh snapshot-create-as aiodev ospure

6、显示快照列表

virsh snapshot-list aiodev

7、快照回滚

virsh snapshot-revert aiodev ospure