海运的博客

XenServer下查找占用硬盘IO较高的虚拟机

发布时间:April 12, 2012 // 分类:虚拟化 // No Comments

首先用iostat查看各个磁盘读写情况,虚拟机磁盘是以dm-id为名显示的。

iostat 2 2 #取样两次,每次相隔2秒

查找tps大于20的vm,并按大小排序

iostat 2 2|grep ^dm-|awk -F"[ ]+|[-]" '{if($3>20){print $2"\t"$3}}'|sort -rnk 2
#第一列为磁盘ID,第二列为当前tps

根据磁盘ID查找相应的虚拟机

#!/bin/bash
#根据iostat结果ID找出相应VM
#执行sh file.sh 编号
case $1 in
*)
  id=`ls -l /dev/mapper/|awk '{if ($6=="'$*'"){print $NF}}'|awk -F-- '{print $NF}'`;xe vdi-list|grep -A 1 $id
;;
esac   

XenServer由mac地址获取虚拟机名称

发布时间:April 12, 2012 // 分类:虚拟化 // No Comments

1.通过vif列表直接获取

xe vm-vif-list|grep -B 2 "mac"

2.通过vm uuid获取

vmid=`xe vif-list MAC=be:c1:46:fd:4e:b7|grep vm-uuid|awk '{print $4}'`;xe vm-list|grep $vmid -A 1

Linux命令行下生成随机安全复杂密码

发布时间:April 12, 2012 // 分类:网络安全 // No Comments

1.使用openssl生成复杂密码。

openssl rand -base64 32 #密码长度32字节。
openssl rand -hex 32

2.使用gpg随机生成

gpg -a --gen-random 2 32
#-a 输出为base64
#2 安全级别 2为/dev/random  1为/dev/urandom

3.使用urandom生成复杂密码,包含各种字符。

#/bin/bash
#generate safe password
#tr -c匹配指定字符 -d删除其它字符
#执行sh safe-pass.sh 密码位数
case $1 in
*)
</dev/urandom tr -dc '1-9!@#$%^&*()a-z-A-Z' | head -c$*; echo " "
#tr -dc '[:graph:]' < /dev/urandom|fold -w32|head -n 20
;;
esac

Mysql错误 Lost connection to MySQL server at 'reading initial communication packet

发布时间:April 12, 2012 // 分类:数据库 // No Comments

一客户网站连接Mysql出现以下错误:

 Lost connection to MySQL server at 'reading initial communication packet', system error: 0

解决方法,关闭DNS反查,修改Mysql配置文件,添加以下参数并重启Mysql服务。

skip-name-resolve

Nginx设置目录密码认证/限制特定IP访问

发布时间:April 8, 2012 // 分类:Nginx,网络安全 // No Comments

网络安全无处不在,使用Nginx为您的网站后台加把锁吧。
验证界面如:
2012-04-08_071422.png
1.Nginx兼容于Apache下htpasswd生成的密钥,不过Nginx下无此工具,可以使用crypt生成密码。

perl -e 'print crypt($ARGV[0], "pwdsalt")' password ;echo ""#password请更改为您的密码

用php生成sha密码,不建议:

$user = 'test';
$pass = 'test';
$sha1 = base64_encode(sha1($pass, true));
echo $user.':{SHA}'.$sha1;

使用openssl生成sha512crypt密码,建议使用。

echo 123456|openssl passwd -6 -in - 

结果即加密后的密码,新建密钥配置谁的将用户密码以以下方式添加。

user:passwd

编辑Nginx配置文件

location ^~ /admin/ {        #特定目录
location ~ .*\.(php|php5)?$ {
allow 192.168.1.16; #允许IP
deny all; #拒绝所有
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
auth_basic "Login";
auth_basic_user_file /passwdfile;
}

添加ip白名单跳过验证:

satisfy any;
allow 127.0.0.1;
deny all;
auth_basic "Login";
auth_basic_user_file /passwdfile;
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
归档