[模板] KVM 虚拟机的 XML 模板

注意:

此模板只用于参考

# vi /etc/libvirt/qemu/template_centos_7_10g.xml

创建以下内容:

<domain type='kvm'>
  <name>node</name>
  <memory unit='KB'>1524000</memory>
  <currentMemory unit='KB'>1524000</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='template_centos_7_10g'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='yes'/>
    <bios useserial='yes'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-passthrough'>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/template_centos_7_10g.img'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <interface type='bridge'>
      <source bridge='vlan001'/>
      <model type='virtio'/>
    </interface>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
    </channel>
    <serial type='pty'></serial>
    <console type='pty'>
      <target type='serial'/>
    </console>
    <memballoon model='virtio'></memballoon>
  </devices>
</domain>

(补充:这里以给 template_centos_7_10g 创建一个虚拟机模板为例)

[工具] Shell 统计 LNMP 本月与上月的网站点击量和 IP 访问数

介绍

基本信息

作者:朱明宇
名称:统计 LNMP 本月与上月的网站点击量和 IP 访问数
作用:统计 LNMP 本月与上月的网站点击量和 IP 访问数

使用方法

1. 在此脚本的分割线内写入相应的内容
2. 给此脚本添加执行权限
3. 执行此脚本

脚本分割线里的变量

1. user=”root” #登录 Web 服务器的用户,请确保这个用户有创建缓存备份目录的权限
2. ip=”8.8.8.8″ #Web 服务器的 IP 地址

注意

此脚本执行前必须要先保证执行脚本的主机能无秘钥远程这台 Web 服务器

脚本

#!/bin/bash

####################### Separator ########################

user="root"
ip="8.8.8.8"

####################### Separator ########################

monthcache1=$(date +%m)
case $monthcache1 in
01)
month=Jan
lmonth=Dec;;
02)
month=Feb
lmonth=Jan;;
03)
month=Mar
lmonth=Feb;;
04)
month=Apr
lmonth=Mar;;
05)
month=May
lmonth=Apr;;
06)
month=June
lmonth=May;;
07)
month=July
lmonth=June;;
08)
month=Aug
lmonth=July;;
09)
month=Sept
lmonth=Aug;;
10)
month=Oct
lmonth=Sept;;
11)
month=Nov
lmonth=Oct;;
12)
month=Dec
lmonth=Nov
esac

cmonth=`ssh $user@$ip "grep $month /usr/local/nginx/logs/access.log | wc -l"`
clmonth=`ssh $user@$ip "grep $lmonth  /usr/local/nginx/logs/access.log | wc -l"`
cipmonth=`ssh $user@$ip "grep $month /usr/local/nginx/logs/access.log" | awk '{a[$1]++}END{for(i in a){print i}}' | wc -l `
ciplmonth=`ssh $user@$ip "grep $lmonth /usr/local/nginx/logs/access.log" | awk '{a[$1]++}END{for(i in a){print i}}' | wc -l`

echo "The count of month's hits:$cmonth 次"
echo "The count of month's IP address:$cipmonth 个"
echo "The count of last month's hits:$clmonth 次"
echo "The count of last month's IP address:$ciplmonth 个"

[工具] Shell 统计 LNMP 今天与昨天的网站点击量和 IP 访问数

介绍

基本信息

作者:朱明宇
名称:统计 LNMP 今天与昨天的网站点击量和 IP 访问数
作用:统计 LNMP 今天与昨天的网站点击量和 IP 访问数

使用方法

1. 在此脚本的分割线内写入相应的内容
2. 给此脚本添加执行权限
3. 执行此脚本

脚本分割线里的变量

1. user=”root” #登录 Web 服务器的用户,请确保这个用户有创建缓存备份目录的权限
2. ip=”8.8.8.8″ #Web 服务器的 IP

注意

此脚本执行前必须要先保证执行脚本的主机能无秘钥远程这台 Web 服务器

脚本

#!/bin/bash

####################### Separator ########################

user="root"
ip="8.8.8.8"

####################### Separator ########################

tday=`date +%d`

sys=`uname -a | awk '{print $1}'`

if [ $sys == 'Linux' ];then
        yday=`date +%d -d "-1 day"`
else
        yday=`date -v-1d +%d`
fi

cday=`ssh $user@$ip "grep $tday/$month  /usr/local/nginx/logs/access.log | wc -l"`
cyday=`ssh $user@$ip "grep $yday/$month  /usr/local/nginx/logs/access.log | wc -l"`
cipday=`ssh $user@$ip "grep $tday/$month  /usr/local/nginx/logs/access.log" |awk '{a[$1]++}END{for(i in a){print i}}' | wc -l`
cipyday=`ssh $user@$ip "grep $yday/$month  /usr/local/nginx/logs/access.log" |awk '{a[$1]++}END{for(i in a){print i}}' | wc -l`

echo "The count of today's hits:$cday 次"
echo "The count of today's IP address:$cipday 个"
echo "The count of yesterday's hits:$cyday 次"
echo "The count of yesterday's IP address:$cipyday 个"

[模板] Nginx 配置模板 (nginx.conf) (LNMP+SSL 版)

worker_processes  1;

events {
    worker_connections  65536;
}

http {
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        limit_req zone=one burst=5;
        server_name www.eternalcenter.com eternalcenter.com;

        rewrite ^/(.*)$ https://eternalcenter.com/$1 permanent;
      
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        }

    server {
        listen       443 ssl;
        server_name www.eternalcenter.com eternalcenter.com;

        if ($request_method !~ ^(GET|POST)$){
        return 444;
        }

        ssl_certificate      /root/ssl/eternalcenter.com.crt;
        ssl_certificate_key  /root/ssl/eternalcenter.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi.conf;
        }

        location / {
        root html;
        index index.php index.html index.htm;
        }

        location ~ ^/\.user\.ini {
        deny all;
        }
    
        location ~* \.(jpd|jpeg|gif|png|css|js|ico|xml)$ {
        expires 30d;
        }

        error_page  404              /404.html;

        }

        gzip on;
	gzip_min_length 1000;
	gzip_comp_level 4;
	gzip_types text/plain test/css application/json application/x-javascript text/xml application/xml
	application/xml+rss text/javascripts;

	client_header_buffer_size 1k;
	large_client_header_buffers 4 4k;

	open_file_cache max=2000 inactive=20s;
	open_file_cache_valid  60s;
	open_file_cache_min_uses 5;
	open_file_cache_errors off;

}