前提:
1 、vim /etc/yum.repos.d/local.repo
[base]
name=Server
baseurl=http://172.16.0.1/yum/Server
gpgcheck=0
enabled=1
[VT]
name=VT
baseurl=http://172.16.0.1/yum/VT
gpgcheck=0
enabled=1
[Cluster]
name=Cluster
baseurl=http://172.16.0.1/yum/Cluster
gpgcheck=0
enabled=1
[CS]
name=ClusterStorage
baseurl=http://172.16.0.1/yum/ClusterStorage
gpgcheck=0
enabled=1
yum groupinstall “Development Libraries”
配置主机名字:
vim /etc/sysconfig/network
HOSTAME=stu5.magedu.com
grub损坏:
grub> find (hd0,0)/ 按Tb键
root (hd0,0)
setup (hd0)
quit
cp /var/tmp/grup.test /boot/grub/grub.conf
解决重启问题:
vim /etc/inittab
vim /etc/rc.d/rc.local
修改密码:
进入单用户模式 passwd
redhat redhat
2、mkdir /backup
mdadm -C /dev/md1 -a yes -l 5 -n 3 -c 32 /dev/sda5 /dev/sda6 /dev/sda7
mke2fs -j /dev/md1
vim /etc/fstab
/dev/md1 /backup ext3 defaults 0 0
3、mkdir /users
pvcreate /dev/sda7 /dev/sd8 创建物理卷
vgcreate –s 8M myvg /dev/sda7 /dev/sda8 创建卷组
lvcreate –L 4G –n lv1 myvg 创建逻辑卷
mke2fs –j /dev/myvg/lv1
vim /etc/fstab
/dev/myvg/lv1 /users ext3 defaults 0 0
4、groupadd –r mysql useradd –r –M –s /sbin/nologin mysql
Groupadd –g 600 magedu useradd –d /users/gentoo
Passwd gentoo gentoo gentoo
useradd –d /users/centos centos
passwd centos centos centos
useradd –d /users/www www
usermod –G magedu gentoo usermod –G magedu centos
5、mkdir /data
mkfs –j –L DATA –b 1024 –m 3 /dev/sda10
vim /etc/fstab
LABEL=DATA /data ext3 defaults 0 0
6、umount /dev/myvg/lv1
e2fsck –f /dev/myvg/lv1
resize2fs /dev/myvg/lv1 2G
lvreduce –L 2G /dev/myvg/lv1
mount-a
7、cp /etc/rc.d/rc.sysinit /data/
umount /data
tune2fs –o acl /dev/sda10 /data
setfacl –m u:gentoo:rw- /data/rc.sysinit
setfacl –m g:magedu:rw- /data/rc.sysinit
setfacl –x u:centos /data/rc.sysinit
8、visudo
centos ALL=(root) NOPASSWD:/usr/sbin/useradd,/usr/sbin/userdel,/usr/sbin/usrmod,/usr/bin/passwd,!/usr/bin/passwd root
su – centos
sudo /usr/sbin/userdel www
9、yum install mysql-server yum install httpd
10、tar xvf axel
cd /usr/local/axel-2.4/
./configure --prefix=/usr/local/axel
make
make install
vim /etc/profile
#export PATH=$PATH:/usr/local/axel/bin
source /etc/profile /etc/man.config MANPATH /usr/local/axel/share/man
12、mkdir /backup/test cd /backup chown :magedu test chmod g+wr test chmod o=--- test chmod g+s test chmod o+t test
13、vim /etc/sysctl.conf
14、vncpasswd vncserver &
15、vim /etc/fstab
crontab –e 20 3 */2 * * /bin/tar -jcf /backup/etc-`date +%F` .tar.bz2 /etc
16、find /etc -user root -amin +7 -type f -exec cp {} tmp/test \;
17、vim /etc/fstab defaults,usrquota mount -o remount,usrquota /dev/myvg/lv1
quotacheck -cmug /users
edquota centos
quotaon /users dd if=/dev/zero of=./a bs= 1M count=130
18、lvcreate -L 1G -s -p r -n snap_lv1 /dev/myvg/lv1 cd /backup/ tar jcf /tmp/etc.tar.bz2 ./
19、!/bin/bash
#Name:analyzelog.sh
#Description:Analyze log files..
#Version: 0.0.1
#Author:WangLiDong
#Datetime: 2012-03-04 23:18:29
byip() {
! grep -o "^$1" $log &> /dev/null && echo "$log no exist THIS IP:$1." && return 3
echo -n "$1 :"
echo -e "\033[ 32m `grep -o "^$1" $log | wc -l`\033[ 0m "
}
bydate() {
! grep "\[$1.*\]" $log &> /dev/null && echo "$log no exist this date:$1." && return 4
for ip in `grep "$1" $log | grep -o "^[0-9\.]\{1,\}" | sort -u`;do
byip $ip
done
}
byname() {
! grep "$1" $log &> /dev/null && echo "$log no exist *$1..." && return 5
echo -e "\033[ 31m ### Name ### TIMES\033[ 0m "
echo -n "*$1: "
echo -e "\033[ 32m `grep "$1" $log | wc -l`\033[ 0m "
}
byall() {
for myip in `grep -o "^[0-9\.]\{1,\}" $log | sort -u`;do
byip $myip
done
}
howtouse() {
echo "Use like this:analyzelog <-i IP|-d DATE|-t TYPE|-a> LOG_FILE"
}
printinfo() {
echo -e "\033[ 31m ---$log---\033[ 0m "
echo -e "\033[ 31m ### IP ### TIMES\033[ 0m "
}
log=`echo $@ | cut -d ' ' -f "$#"`
[ ! -f $log ] && echo "$log not exist..." && exit 6
while getopts ":i:d:t:a" opt;do
case $opt in
i)
printinfo
byip $OPTARG;;
d)
echo "$OPTARG"
printinfo
bydate $OPTARG;;
t)
byname $OPTARG;;
a)
printinfo
byall;;
?) howtouse;;
esac
done