你正在浏览的是 未分类 目录

Megacli在线创建RAID问题一例

0 ~o~

今天对一台服务器的硬盘进行了调整,需要重新组建RAID10。

结果明明显示硬盘是unconfiggood的,RAID就是创建不了。

原来是这个状态显示不正确,其实有块盘是foreign状态的。

查找foreign磁盘:

megacli -CfgForeign -Scan -a0

There are 1 foreign configuration(s) on controller 0.

 

清除foreign:

megacli -CfgForeign -Clear [.]-a0

Foreign configuration 0 is cleared on controller 0.

 

SSH自动定时更改密码

1 foot

很多免费提供SSH账号的都是自动定时更改SSH密码,比如每10分钟改一次。并且隔一段时间,还可以自动定时断开SSH。
研究了一下,发出来共享下。
使用root账号登录VPS, 建立一个文件夹,名字随便比如autossh
mkdir /usr/share/autossh
cd /usr/share/autossh
在这个文件夹下建立两个文件,文件名随便
/usr/share/autossh/r_autossh.sh
/usr/share/autossh/c_autossh.sh
r_autossh.sh文件内容
#!/bin/sh
userdel autossh
/usr/bin/php -r ‘$pwd=substr(md5(“saltsecne99cc”.time()),5,5);file_put_contents(“/usr/share/autossh/pwd.txt”,$pwd);file_put_contents(“/usr/share/autossh/crypt.txt”,crypt($pwd));’
PASSWORD=$(cat /usr/share/autossh/pwd.txt)
CPT=$(cat /usr/share/autossh/crypt.txt)
useradd -N -s /usr/sbin/nologin -p $CPT freessh
echo “User: freessh”
echo “Password: $PASSWORD”
echo “”
unlink /usr/share/autossh/crypt.txt
c_autossh.sh文件内容
#!/bin/sh
killall -u freessh
然后设置执行权限
chmod a+x /usr/share/autossh/*.sh
设置crontab,执行crontab -e
# m h dom mon dow command
*/10 * * * * /usr/share/autossh/r_autossh.sh #每十分钟,自动更改一次freessh账号密码
*/30 * * * * /usr/share/autossh/c_autossh.sh #每30分钟,自动断开freessh的链接
保存crontab,重启一下cron服务/etc/init.d/cron restart
现在己经实现自动定时更改SSH密码和自动定时断开SSH了。

双网卡内外网双IP添加静态路由

0 ~o~

案例:
内网IP:10.2.0.3
外网IP:60.2.18.10
内网网关:10.2.0.1
外网网关:60.2.18.1
备注:默认网关写在/etc/sysconfig/network里,是外网网关,静态路由写在/etc/sysconfig/static-routes 里,这样重启网络也不会丢失了~

#!/bin/bash
sed -i \'/^/sbin/route/d\' /etc/rc.local
echo "DEVICE=eth0
ONBOOT=yes "> /etc/sysconfig/network-scripts/ifcfg-eth0
awk -F \'"\' \'/IPADDR/{print $1$2}\' /etc/sysconfig/network-scripts/ifcfg-bond0 >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "DEVICE=eth1
ONBOOT=yes" > /etc/sysconfig/network-scripts/ifcfg-eth1
sed -n \'/IPADDR/p\' /etc/sysconfig/network-scripts/ifcfg-bond0|sed -r \'s/(.*).137.(.*)"/2/g\'|awk \'{system("echo "$1"+58")}\'|awk -F. \'{print "IPADDR=60.XX.XX."$4+60}\' >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i "/^GATEWAY/d" /etc/sysconfig/network
echo "GATEWAY=60.2.18.1" >> /etc/sysconfig/network
echo "any net 10.0.0.0/8 gw 10.16.0.1
any net 172.0.0.0/8 gw 10.16.0.1" >/etc/sysconfig/static-routes
#sed -i \'6,9d\' /etc/modprobe.conf
rm -f /etc/modprobe.d/bonding.conf
sleep 2
mv /etc/sysconfig/network-scripts/ifcfg-bond0 /etc/sysconfig/network-scripts/ifcfg-bond0.bak

LAMP一键安装脚本

0 ~o~

很久以前修改的一个脚本,用于一键安装LAMP环境。

#!/bin/bash
#Date:2010.12.20
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear
echo ""
echo -e "33[7m"
echo "+----------------------------------------+"
echo "+ +"
echo "+ LAMP一键安装脚本 +"
echo "+ Author: Panzhongy.pt@Taobao.com +"
echo "+ Platform: Linux +"
echo "+ 2010-12-15 +"
echo "+----------------------------------------+"
echo -e "33[0m"
www="/home/wwwroot"
user="root"
pass="123456"
install_base()
{
echo "+--------------------------------------+"
echo "+ install apache+mysql+phpmyadmin +"
echo "+--------------------------------------+"
yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
yum -y install pango-devel mod_ssl php-gd php-snmp php-pear php-ldap
yum -y install net-snmp net-snmp-devel net-snmp-utils net-snmp-libs net-snmp-utils net-snmp-perl libart_lgpl ntp
ckconfig httpd on
chkconfig mysqld on
mkdir $www
cp -R conf/vhost.conf /etc/httpd/conf/
sed -i -e "s#@www@#$www#g" /etc/httpd/conf/vhost.conf
echo "Include /etc/httpd/conf/vhost.conf">> /etc/httpd/conf/httpd.conf
sed -i -e \'s/AddDefaultCharset UTF-8/#AddDefaultCharset UTF-8/g\' /etc/httpd/conf/httpd.conf
service httpd restart
service mysqld restart
mysqladmin -u root password $pass
}
init()
{
echo ""
echo "Please input HTTP path:"
read -p "(Default: $www):" temp
if [ "$temp" != "" ]; then
www=$temp
fi
echo ""
echo "Please input MySQL username:"
read -p "(Default: $user):" temp
if [ "$temp" != "" ]; then
user=$temp
fi
echo ""
echo "Please input MySQL password:"
read -p "(Default: $pass):" temp
if [ "$temp" != "" ]; then
pass=$temp
fi
}
init
install_base

您使用的是IE浏览器,请下载Chrome来获得更好的体验