分类目录归档:未分类

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

K8s启动命令

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ccc.cccc.cn 
  labels:
    app: web-api
spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: api
    spec:
      restartPolicy: "Always"
      containers:
      - name: api-cccc-cn
        image: api:39
        imagePullPolicy: "IfNotPresent"
        command: ["/bin/sh","-c"," /usr/local/bin/composer dump-autoload ; crontab -e -u www-data ; crond ; /usr/bin/supervisord "]
        resources:
          limits:
            cpu: "1500m"
            memory: "1000Mi"
          requests:
            cpu: "200m"
            memory: "200Mi"
        ports:
        - containerPort: 80
          name: http
          protocol: TCP
        - containerPort: 443
          name: https
          protocol: TCP
        - containerPort: 9913
          name: nginx-vts
          protocol: TCP
        - containerPort: 9190
          name: php-fpm-export
          protocol: TCP
        - containerPort: 42323
          #hostPort: 42323
          name: php
          protocol: TCP
        - containerPort: 8080
          name: tcp-8080
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          periodSeconds: 5
          successThreshold: 1
          tcpSocket:
            port: 443
        volumeMounts:
        - name: nginx-configmap
          mountPath: /etc/nginx/conf.d
        - name: nginx-configmap-consul
          mountPath: /etc/nginx/sites-enabled
        - name: nginxcert-configmap
          mountPath: /var/www/cert
        - name: api-nginx-log
        #- name: nfs-pvc
          mountPath: /var/log/nginx/
        - name: nfs-php-logs
          mountPath: /var/www/html/k8s/storage/logs/
        - name: api-php-uploads
          mountPath: /var/www/html/k8s/public/uploads
        - name: api-php-vendor
          mountPath: /var/www/html/k8s/vendor/
      imagePullSecrets:
      - name: registry-secret-new
      volumes:
      - name: nginx-configmap
        configMap:
          name: nginxconf-api
      - name: nginx-configmap-consul
        configMap:
          name: nginxconf-consul.cccc.cn
      - name: nginxcert-configmap
        configMap:
          name: nginxcert-cccc.cn
      - name: api-nginx-log
      #- name: nfs-pvc
        hostPath:
      # persistentVolumeClaim:
          path: /data/logs/api-nginx
         # claimName: product-claim-api
      - name: nfs-php-logs
        persistentVolumeClaim:
          claimName: product-claim-api-php-logs
      - name: api-php-uploads
        persistentVolumeClaim:
          claimName: product-claim-api-upload
      - name: api-php-vendor
        persistentVolumeClaim:
          claimName: product-claim-api-vendor

GIT误删库如何恢复

转:
误操作删除服务器上git仓库的处理方法

说明:

git 服务器上仓库代码不小心被删除了,但是通过git clone下来的code存在

另外git 服务器上没有建立任何branch信息;

1.在之前clone过服务器代码的客户端机器上,找到clone下来的代码目录,

执行git remote -vv
查询原来git 仓库所在服务器的IP地址以及路径;

2.根据步骤1上查询的结果,在服务器上找到对应路径,创建git仓库;

git init –bare

3.在客户端之前clone 代码所在目录,强制push客户端的代码至服务器

git push origin master –force

这样原来clone下来的代码以及change log等信息,就会被强制clone到服务器上;

说明:此处必须加–force选项,否则会因服务器上仓库信息与客户端仓库信息不匹配导致push失败
——————————————————
免密模式中的.ssh目录必须是700权限,和authorized_keys必须是600权限

控制台应用静态库编译

cmake_minimum_required(VERSION 3.14)
project(CommaSdkActivator)

set(CMAKE_CXX_STANDARD 11)


# yum install glibc-static libstdc++-static
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")

if(WIN32)
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS,5.01")
endif()

if(MSVC)
    # Use the static C library for all build types
    foreach(var
        CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
        CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
      )
      if(${var} MATCHES "/MD")
        string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
      endif()
    endforeach()
endif(MSVC)

add_executable(CommaSdkActivator main.cpp)

指定ndk的库输出

defaultConfig {
applicationId “com.commaai.facesdkdemo”
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName “1.0”

testInstrumentationRunner “androidx.test.runner.AndroidJUnitRunner”

ndk {
abiFilters “armeabi-v7a”
}
}

VT102图形测试whiptail

#!/bin/bash

whiptail --title "K8s,  Vision @ 2019" --menu "Choose your option" 20 65 13 \
"1" "Single K8s One-click" \
"2" "Cluste K8s One-click" \
"3" "Cluste K8s add node" \
"4" "Single K8s add node" \
"5" "del node" \
"6" "Uninstall K8s" \
"7" "Quit"  3>&1 1>&2 2>&3
#!/bin/bash
whiptail --title "导入集群IP地址(包含本机ip默认第一个ip对应本机ip作为master)" --yes-button "YES" --no-button "NO"  --yesno "批量导入集群IP地址?" 10 60
#!/bin/bash
whiptail --title "#请输入本机Ip(master)并回车#" --inputbox "请检查IP是否一致,确定提交?" 10 60 "$IP" 3>&1 1>&2 2>&3
#!/bin/bash
#---
if ( whiptail --title "Title hylan:yesno" --yesno "Choose between Yes and No." 10 60 ) then
     echo "You chose Yes. Exit status was $?."
else
     echo "You chose No. Exit status was $?."
fi
#---
if (whiptail --title "Title hylan:yesno" --yes-button "Hylan" --no-button "Candy"  --yesno "Which do you like better?" 10 60) then  
   echo "You chose Hylan. Exit status was $?."; 
   echo "You Best!"
else    
   echo "You chose Candy. Exit status was $?.";
fi
#---
whiptail --title "Title hylan:msgbox" --msgbox "Create a message box with whiptail. Choose Ok to continue." 10 60
#---
whiptail --title "Title hylan:inputbox" --inputbox "What is your pet's name?" 10 60 hylancandy 3>&1 1>&2 2>&3
#---
whiptail --title "Title hylan:passwordbox" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3
#---
whiptail --title "Title hylan:menu" --menu "Choose your option" 15 60 4 \
"1" "Grilled Spicy Sausage" \
"2" "Grilled Halloumi Cheese" \
"3" "Charcoaled Chicken Wings" \
"4" "Fried Aubergine"  3>&1 1>&2 2>&3

#---
whiptail --title "Title hylan:checklist" --checklist "Choose preferred Linux distros" 15 60 4 "debian" "Venerable Debian" ON "ubuntu" "Popular Ubuntu" OFF "centos" "Stable CentOS" ON "mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3

{
     for (( i=0 ; i<=100 ; i+=20 )); do
         sleep 1
         echo $i
     done
} | whiptail --gauge "Please wait while installing" 6 60 0

#---
whiptail --title "Title hylan:checklist" --radiolist "Choose preferred Linux distros" 15 60 4 "debian" "Venerable Debian" ON "ubuntu" "Popular Ubuntu" OFF "centos" "Stable CentOS" ON "mint" "Rising Star Mint" OFF 3>&1 1>&2 2>&3

关闭WPS广告

“1.我们首先点击电脑左下角的开始。2.然后点击Wps Office文件夹。3.随后点击配置工具。4.我们在弹出的窗口中点击高级。5.再点击其他选项。6.最后取消勾选WPS热点及广告推送就可以了。