第4次答疑
1.
定时备份:
rsync+定时任务===备份软件配置,重要的配置。
实时复制:
rsync+inotify 适合小文件 200k
rsync+sersync 推荐,大的数据量备份
nfs数据:
drdb同步-基于block基于分区,备节点无法使用。
选用分布式文件系统:fastdfs,glusterfs
数据库:
主从复制
mha
2.linux中查询性能的命令
[root@ipt ~]# w
09:38:57 up 6:16, 2 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - Thu12 3days 0.20s 0.20s -bash
root pts/1 10.0.0.253 Sat15 0.00s 0.04s 0.00s w
[root@ipt ~]# uptime
09:39:02 up 6:16, 2 users, load average: 0.00, 0.00, 0.00
[root@ipt ~]# top
M-按照内存进行排序;P-按照CPU使用率进行排序。
[root@ipt ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 19356 1532 ? Ss 03:22 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 03:22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 03:22 0:00 [migration/0]
......
VSZ:swap虚拟内存+物理内存。
RSS:实际占用的物理内存。
top系列:
[root@ipt ~]# yum install -y htop iotop iftop
[root@ipt ~]# dd if=/dev/zero of=/tmp/100 bs=100 //count=10 次
^C7493141+0 records in
7493141+0 records out
749314100 bytes (749 MB) copied, 63.7207 s, 11.8 MB/s
另一端口进行实时监控:
[root@ipt ~]# iotop -o //-o参数只显示正在读写的IO端口。
[root@ipt ~]# iftop
interface: eth0
IP address is: 10.0.0.17
MAC address is: 00:0c:29:24:38:76
[root@ipt ~]# iftop --help
3.怎么解决nfs单点故障?
rsync+inotify/sersync
drdb同步-基于block分区,备节点无法使用。
选用分布式文件系统fastdfs,glusterfs

读时使用同步的web本地服务器数据,不用nfs上的存储的数据;只有写的时候才使用。
4.showmount -e和rpcinfo -p区别?
showmount -e --查询nfs可以挂载的信息。
rpcinfo -p --查询rpc服务中是否有nfs注册信息。
5.switch case语句
case "条件" in start) echo starting... ;; stop) echo stop... ;; restart) echo restarting... ;; *) echo "Usage:input start|stop|restart" ;; esac
eg:
[root@ipt ~]# cat /service/scripts/case.sh
#!/bin/sh
#case
case "$1" in
start)
echo starting...
;;
stop)
echo stop...
;;
restart)
echo restarting...
;;
*)
echo "Usage:$0 start|stop|restart"
;;
esac
[root@ipt ~]# /bin/sh /service/scripts/case.sh start
starting...
[root@ipt ~]# /bin/sh /service/scripts/case.sh stop
stop...
[root@ipt ~]# /bin/sh /service/scripts/case.sh restart
restarting...
[root@ipt ~]# /bin/sh /service/scripts/case.sh
Usage:/service/scripts/case.sh start|stop|restart
[root@ipt ~]# awk 'NR==418,NR==458' /etc/init.d/iptables
case "$1" in
start)
[ -f "$VAR_SUBSYS_IPTABLES" ] && exit 0
start
;;
stop)
[ "x$IPTABLES_SAVE_ON_STOP" = "xyes" ] && save
stop
;;
restart|force-reload)
restart
;;
*)
echo $"Usage: ${IPTABLES} {start|stop|reload|restart|condrestart|status|panic|save}"
RETVAL=2
;;
esac
6.系统的函数功能
优雅的显示ok和false(带颜色):
[root@ipt ~]# source /etc/init.d/functions
[root@ipt ~]# action "oldboy" /bin/true
oldboy [ OK ]
[root@ipt ~]# action "oldgirl" /bin/false
oldgirl [FAILED]
判断文件内容是否发生改变
[root@ipt ~]# md5sum /etc/inittab
753a386bcd9ab0ca581056348463891e /etc/inittab
[root@ipt ~]# md5sum /etc/inittab >/tmp/tab.md5
[root@ipt ~]# md5sum -c /tmp/tab.md5
/etc/inittab: OK
[root@ipt ~]#
[root@ipt ~]# echo $?
0
[root@ipt ~]# echo "#" >>/etc/inittab
[root@ipt ~]# md5sum -c /tmp/tab.md5
/etc/inittab: FAILED
md5sum: WARNING: 1 of 1 computed checksum did NOT match
[root@ipt ~]# echo $?
1
专业:
[root@ipt ~]# cat /service/scripts/chk-tab.sh #!/bin/sh #desc:check /etc/inittab file source /etc/init.d/functions /usr/bin/md5sum -c /tmp/tab.md5 if [ $? -eq 0 ];then action "file not changed!" /bin/true else action "file changed!" /bin/false fi
[root@ipt ~]# /bin/sh /service/scripts/chk-tab.sh
/etc/inittab: OK
file not changed! [ OK ]
[root@ipt ~]# echo "#" >>/etc/inittab
[root@ipt ~]# /bin/sh /service/scripts/chk-tab.sh
/etc/inittab: FAILED
/usr/bin/md5sum: WARNING: 1 of 1 computed checksum did NOT match
file changed! [FAILED]
运维人员shell水平应该达到什么水平:
1.完成全网备份项目;
2.软件启动脚本rsync等;
......
浙公网安备 33010602011771号