步骤一:清理 yum 的缓存
# yum clean all
步骤二:安装 package-cleanup
# yum -y install yum-utils
步骤三:使用 package-cleanup 更新仓库
# package-cleanup --cleandupes
# yum clean all
# yum -y install yum-utils
# package-cleanup --cleandupes
服务器系统要配置好可用的软件源
# yum grouplist
或者:
# dnf group list
如果是 Rocky Linux & RHEL:
# yum groupinstall "Server with GUI"
或者:
# dnf group install -y "Server with GUI"
如果是 Fedora:
# dnf install @gnome
或者:
# yum groupinstall "GNOME"
或者:
# dnf group install -y "GNOME"
# systemctl set-default graphical.target
# startx
或者:
# init 5
noexec 让挂载目录下的所有程序都不能被执行,主要是预防病毒、木马、蠕虫等
# vim /etc/fstab
将部分内容修改如下:
/dev/vda2 /boot xfs defaults,noexec 0 0
注意:此模板只用于参考
# 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 创建一个虚拟机模板为例)
作者:朱明宇
名称:统计 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 个"