linux daily operation and maintenance work

Linux's use of the environment are becoming increasingly sophisticated, flocked to a variety of open source products, a great flourishing of spectacular, then when landing Linux Enterprise, return to work, we have to face many problems that Linux-dimensional aspects of transport, today we deliberately Linux in a business organization related to the use of them share exchange activities. The event is rich in content, in which we conduct some sort of system.

Select a Linux

Choose a Linux version of the series for mainstream versions of their enterprises is relatively not easy, let's introduce the basis of all enterprises in the selection of the reference:

RedHat and CentOS

Select Red Hat products to centos, mainly consider several aspects:

  1. centos redhat compiled version is basically no major changes
  2. Now many environments are clustered environment, including web cluster, cluster middleware, rac cluster and so on, OS level itself is not 100% availability factor requirements so high.
  3. Mainstream version of the life cycle is longer, more suitable for a hardware lifecycle management, installation time until the device is basically scrapped.
  4. Batch installation deployment convenience, hardware and software compatibility is very good.
  5. The main use version 6 release, the new application can take full account of the use of upgraded version 7

SuSe

Use of Suse Linux Enterprise Edition, the main considerations are as follows:
1, the release performance and stability of the more prominent
2, customer technical support system more complete, faster service response (which is basically the most important factor)
3, It was also embrace the open source community as well ecological openstack and so on.
4, the main version is more SUSE11.

Two installation deployment

Way: U disk, CD-ROM and network installations
where network installation has become the preferred method of the current batch deployment: The main tools Cobbler and PXE + kickstart
can refer to the following links content:
http://www.cnblogs.com/mchina/p/ centos-pxe-kickstart-auto- install-os.html

Three initial configuration

Disable Service

 
 
  1. chkconfig --level 35 iptables off
  2. chkconfig --level 35 ip6tables off
  3. service iptables stop
  4. chkconfig --level 35 postfix off

Disable SeLinux

 
 
  1. vi /etc/selinux/config SELINUX=disabled

Configuring YUM source configuration

 
 
  1. [root@rhel63 yum.repos.d]# vi local.repo
  2. [local]
  3. name=local
  4. baseurl=file:///mnt/Server
  5. enabled=1
  6. gpgcheck=0

It can be configured as an optical disk, or internal source YUM EPEL

Commonly used software installation

 
 
  1. # yum install ftp telnet make imake gcc compat-libstdc++-33 gcc-c++ libstdc++ libXp kernel kernel-devel kernel-headers rsh ksh lsof openssh-clients -y
  2. # yum install iptraf.x86_64 unzip.x86_64 libaio.x86_64 eject sysfsutils dmidecode pciutils dstat lsscsi -y

Installation xwindows

 
 
  1. # yum groupinstall "X Window System" -y
  2. # yum groupinstall Desktop -y (可以不安装桌面)
  3. # yum install xorg-x11-apps -y (包含xclock)

Configuring ntp

 
 
  1. */10 * * * * /usr/sbin/ntpdate 10.0.0.1

As Crontab add record to specify the internal server ntp

SSH login settings

Modify ssh disable DNS options:

 
 
  1. echo "UseDNS no" >> /etc/ssh/sshd_config service sshd restart

Add allows you to specify user login:

 
 
  1. echo "AllowUsers user1" >> /etc/ssh/sshd_config
  2. service sshd restart

Upload a scan tool

 
 
  1. rescan-scsi-bus.sh

The script on the network, download their own use

Format change history

 
 
  1. echo "export HISTTIMEFORMAT='%F %T'" >> /etc/profile

Four security reinforcement

The main reference of security reinforcement content is Redhat and Centos series version of the system:
Reference links
http://www.centoscn.com/CentosSecurity/CentosSafe/2015/0315/4881.html

Comment out the system does not require the users and user groups

Note: not recommended to delete when you need a user that he will be re-add a lot of trouble.

 
 
  1. cp /etc/passwd /etc/passwdbak #修改之前先备份
  2. vi /etc/passwd #编辑用户,在前面加上#注释掉此行
  3. #adm:x:3:4:adm:/var/adm:/sbin/nologin
  4. #lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
  5. #sync:x:5:0:sync:/sbin:/bin/sync
  6. #shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
  7. #halt:x:7:0:halt:/sbin:/sbin/halt
  8. #uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
  9. #operator:x:11:0:operator:/root:/sbin/nologin
  10. #games:x:12:100:games:/usr/games:/sbin/nologin
  11. #gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
  12. #ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin#注释掉ftp匿名账号
  13. cp /etc/group /etc/groupbak #修改之前先备份
  14. vi /etc/group #编辑用户组,在前面加上#注释掉此行
  15. #adm:x:4:root,adm,daemon
  16. #lp:x:7:daemon,lp
  17. #uucp:x:14:uucp
  18. #games:x:20:
  19. #dip:x:40:

Turn off unnecessary services system

 
 
  1. service acpid stop chkconfig acpid off #停止服务,取消开机启动 #电源进阶设定,常用在 Laptop 上
  2. service autofs stop chkconfig autofs off #停用自动挂载档桉系统与週边装置
  3. service bluetooth stop chkconfig bluetooth off #停用Bluetooth蓝芽
  4. service cpuspeed stop chkconfig cpuspeed off #停用控制CPU速度主要用来省电
  5. service cups stop chkconfig cups off #停用 Common UNIX Printing System 使系统支援印表机
  6. service ip6tables stop chkconfig ip6tables off #禁止IPv6
  7. 如果要恢复某一个服务,可以执行下面操作
  8. service acpid start chkconfig acpid on
  9. ## 禁止非root用户执行/etc/rc.d/init.d/下的系统命令禁止非root用户执行/etc/rc.d/init.d/下的系统命令
  10. chmod -R 700 /etc/rc.d/init.d/*
  11. chmod -R 777 /etc/rc.d/init.d/* #恢复默认设置

To add the following file attributes can not be changed, in order to prevent unauthorized users from obtaining permission

 
 
  1. chattr +i /etc/passwd
  2. chattr +i /etc/shadow
  3. chattr +i /etc/group
  4. chattr +i /etc/gshadow
  5. chattr +i /etc/services #给系统服务端口列表文件加锁,防止未经许可的删除或添加服务
  6. lsattr /etc/passwd /etc/shadow /etc/group /etc/gshadow /etc/services #显示文件的属性
  7. 注意:执行以上权限修改之后,就无法添加删除用户了。
  8. 如果再要添加删除用户,需要先取消上面的设置,等用户添加删除完成之后,再执行上面的操作
  9. chattr -i /etc/passwd #取消权限锁定设置
  10. chattr -i /etc/shadow
  11. chattr -i /etc/group
  12. chattr -i /etc/gshadow
  13. chattr -i /etc/services #取消系统服务端口列表文件加锁
  14. 现在可以进行添加删除用户了,操作完之后再锁定目录文件

Restrict permissions different files

 
 
  1. chattr +a .bash_history #避免删除.bash_history或者重定向到/dev/null
  2. chattr +i .bash_history
  3. chmod 700 /usr/bin 恢复 chmod 555 /usr/bin
  4. chmod 700 /bin/ping 恢复 chmod 4755 /bin/ping
  5. chmod 700 /usr/bin/vim 恢复 chmod 755 /usr/bin/vim
  6. chmod 700 /bin/netstat 恢复 chmod 755 /bin/netstat
  7. chmod 700 /usr/bin/tail 恢复 chmod 755 /usr/bin/tail
  8. chmod 700 /usr/bin/less 恢复 chmod 755 /usr/bin/less
  9. chmod 700 /usr/bin/head 恢复 chmod 755 /usr/bin/head
  10. chmod 700 /bin/cat 恢复 chmod 755 /bin/cat
  11. chmod 700 /bin/uname 恢复 chmod 755 /bin/uname
  12. chmod 500 /bin/ps 恢复 chmod 755 /bin/ps

Prohibit the use of Ctrl + Alt + Del to restart the server shortcuts

 
 
  1. cp /etc/inittab /etc/inittabbak
  2. vi /etc/inittab #注释掉下面这一行
  3. #ca::ctrlaltdel:/sbin/shutdown -t3 -r now

Do not upgrade using the yum update kernel when the system update, the update only packages

Note: Due to compatibility issues and hardware systems, has upgraded the kernel may cause the server does not start, it is very terrible, there is no particular need, it is recommended not arbitrarily upgrade the kernel.

 
 
  1. cp /etc/yum.conf /etc/yum.confbak
  2. 1、修改yum的配置文件 vi /etc/yum.conf 在的最后添加 exclude=kernel*
  3. 2、直接在yum的命令后面加上如下的参数:
  4. yum --exclude=kernel* update
  5. 查看系统版本 cat /etc/issue
  6. 查看内核版本 uname –a

Turn off automatic updates Centos

 
 
  1. chkconfig --list yum-updatesd #显示当前系统状态
  2. yum-updatesd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
  3. service yum-updatesd stop #关闭 开启参数为start
  4. 停止 yum-updatesd: [确定]
  5. service yum-updatesd status #查看是否关闭
  6. yum-updatesd 已停
  7. chkconfig --level 35 yum-updatesd off #禁止开启启动(系统模式为3、5)
  8. chkconfig yum-updatesd off #禁止开启启动(所有启动模式全部禁止)
  9. chkconfig --list yum-updatesd #显示当前系统状态
  10. yum-updatesd 0:关闭 1:关闭 2:启用 3:关闭 4:启用 5:关闭 6:关闭

Close extra virtual console

We know that switching from the console to the X window, generally use the Alt-F7, why? Because the system default defined six virtual consoles,
so it became the first X 7. In fact, many people generally do not need so many virtual console, modify / etc / inittab, comment out the ones you do not need.

 
 
  1. cp /etc/inittab /etc/inittabbak
  2. vi /etc/inittab
  3. # Run gettys in standard runlevels
  4. 1:2345:respawn:/sbin/mingetty tty1
  5. #2:2345:respawn:/sbin/mingetty tty2
  6. #3:2345:respawn:/sbin/mingetty tty3
  7. #4:2345:respawn:/sbin/mingetty tty4
  8. #5:2345:respawn:/sbin/mingetty tty5
  9. #6:2345:respawn:/sbin/mingetty tty6

Modify the command history records

 
 
  1. cp /etc/profile /etc/profilebak
  2. vi /etc/profile
  3. 找到 HISTSIZE=1000 改为 HISTSIZE=50

Hide Server System Information

By default, when you log in to a linux system, it will tell you the name of the linux distribution name, version, kernel version of the server.
In order to prevent leakage of these default information out, we have to carry out the following operations, let it show only a "login:" prompt.
Delete / etc / issue and /etc/issue.net these two files, or rename these two files, the effect is the same.

 
 
  1. mv /etc/issue /etc/issuebak
  2. mv /etc/issue.net /etc/issue.netbak

Optimized Linux kernel parameters

 
 
  1. cp /etc/sysctl.conf /etc/sysctl.confbak
  2. vi /etc/sysctl.conf #在文件末尾添加以下内容
  3. net.ipv4.tcp_max_syn_backlog = 65536
  4. net.core.netdev_max_backlog = 32768
  5. net.core.somaxconn = 32768
  6. net.core.wmem_default = 8388608
  7. net.core.rmem_default = 8388608
  8. net.core.rmem_max = 16777216
  9. net.core.wmem_max = 16777216
  10. net.ipv4.tcp_timestamps = 0
  11. net.ipv4.tcp_synack_retries = 2
  12. net.ipv4.tcp_syn_retries = 2
  13. net.ipv4.tcp_tw_recycle = 1
  14. #net.ipv4.tcp_tw_len = 1
  15. net.ipv4.tcp_tw_reuse = 1
  16. net.ipv4.tcp_mem = 94500000 915000000 927000000
  17. net.ipv4.tcp_max_orphans = 3276800
  18. #net.ipv4.tcp_fin_timeout = 30
  19. #net.ipv4.tcp_keepalive_time = 120
  20. net.ipv4.ip_local_port_range = 10024 65535 #(表示用于向外连接的端口范围。缺省情况下很小:32768到61000 注意:这里不要将最低值设的太低,否则可能会占用掉正常的端口! )
  21. /sbin/sysctl -p #使配置立即生效

System Optimization

 
 
  1. cp /etc/profile /etc/profilebak2
  2. vi /etc/profile #在文件末尾添加以下内容
  3. ulimit -c unlimited
  4. ulimit -s unlimited
  5. ulimit -SHn 65535
  6. source /etc/profile #使配置立即生效
  7. ulimit -a #显示当前的各种用户进程限制

Prohibit ping server

 
 
  1. cp /etc/rc.d/rc.local /etc/rc.d/rc.localbak
  2. vi /etc/rc.d/rc.local #在文件末尾增加下面这一行
  3. echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
  4. 参数0表示允许 1

Check the password policy settings are in line with complexity requirements

 
 
  1. cp -p /etc/pam.d/system-auth /etc/pam.d/system-auth_bak
  2. vi /etc/pam.d/system-auth
  3. 可使用pam pam_cracklib module或pam_passwdqc module实现密码复杂度,两者不能同时使用
  4. password requisite pam_cracklib.so dcredit=-1 ucredit=-1 lcredit=-1 ocredit=-1 minclass=2 minlen=8
  5. password sufficient pam_unix.so md5 shadow nullok try_first_pass use_authtok

Check the login prompt - after a successful login warning is set Banner

Modify the contents of the file / etc / motd, such as the absence of the file, it is created.

 
 
  1. #echo " Authorized users only. All activity may be monitored and reported " > /etc/motd

Check to see if the login timeout

Perform backups:

 
 
  1. cp -p /etc/profile /etc/profile_bak
  2. cp -p /etc/csh.cshrc /etc/csh.cshrc_bak

/Etc/csh.cshrc modify the file, add the following line:

 
 
  1. set autologout=30

After changing this setting, log in again to effective

Over five path settings

With the popularity of the X86 environment, Linux market share is increasing, in order to facilitate follow-up and management of our equipment comes with Linux multipath software mature, we often first in everyday devices multipathing software selection consider using the DM software, this is a combination of multi-path setting is mainly REDHAT CENTOS and comes with software DM --- multipath
reference Links:
http://www.aixchina.net/Question/229227

Six abnormal OS system performance index acquisition

CPU usage up to 10 process

 
 
  1. ps axww -o user,pid,pcpu,pmem,start,time,comm | head -1;ps axww -o user,pid,pcpu,pmem,start,time,comm | grep -v PID | sort -nr -k 3 | head
  2. ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
  3. ps auxw|head -1;ps auxw|sort -rn -k3|head -10

Memory footprint of up to 10 process

 
 
  1. ps axww -o user,pid,pcpu,pmem,start,time,comm | head -1 ;ps axww -o user,pid,pcpu,pmem,start,time,comm | grep -v PID | sort -nr -k 4 | head
  2. ps aux|head -1;ps aux|grep -v PID|sort -rn -k +4|head
  3. ps auxw|head -1;ps auxw|sort -rn -k4|head -10

Virtual memory is the most used process before 10

 
 
  1. ps auxw|head -1;ps auxw|sort -rn -k5|head -10

View the system load

 
 
  1. dstat --top-mem --top-io --top-cpu --nocolor 1 10

Statistics of current connections

 
 
  1. ss -an | grep -v "State" | awk '{++S[$1]} END {for(a in S) print a, S[a]}'
  2. netstat -tan | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'

The current number of connections up to 10 process

 
 
  1. ss -tnp | grep -v "State" | awk '{print $6}' | awk -F '"' '{print $2}' | awk '{++S[$1]} END {for(a in S) print a, S[a]}' | sort -nr -k2 | head
  2. netstat -tnp | grep -v "Active" | grep -v "TIME_WAIT" | grep -v "State" | awk -F '/' '{print $NF}' | awk '{++S[$1]} END {for(a in S) print a, S[a]}' | sort -nr -k2 | head

Seven daily use LVM

LVM occupy a large proportion of them in the daily operation and maintenance work, and I cited LVM common daily operations and procedures.

  1. Add a disk to the OS, a file system format, reference to the following: scan the disk
       
       
    1. pvcreate /dev/sdb
    2. vgcreate -s 8M datavg /dev/sdb
    3. lvcreate -L 10G -n datalv datavg
    4. mkfs.ext3 /dev/datavg/datalv
    5. mount /dev/datavg/datalv /data
    6. lvextend -L 20G /dev/datavg/datalv
    7. resize2fs /dev/datavg/datavlv

    This is not to do with each step is explained in detail, are interested can search alone

2. The file system expansion and shrink (the root file system to be reduced quite cautious)

 
 
  1. # lsscsi
  2. [1:0:0:0]cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
  3. [2:0:0:0]disk VMware Virtual disk 1.0 /dev/sda
  4. [2:0:1:0]disk VMware Virtual disk 1.0 /dev/sdb
  5. [2:0:2:0]disk VMware Virtual disk 1.0 /dev/sdc
  6. [2:0:3:0]disk VMware Virtual disk 1.0 /dev/sdd
  7. # pvs
  8. PV VG Fmt Attr PSize PFree
  9. /dev/sda2 VolGroup lvm2 a-- 49.51g 0
  10. /dev/sdb VolGroup lvm2 a-- 50.00g 6.57g
  11. # pvcreate /dev/sdc
  12. Writing physical volume data to disk "/dev/sdc"
  13. Physical volume "/dev/sdc" successfully created
  14. # vgcreate datavg /dev/sdc
  15. Volume group "datavg" successfully created
  16. # vgs
  17. VG #PV #LV #SN Attr VSize VFree
  18. VolGroup 2 2 0 wz--n- 99.50g 6.57g
  19. datavg 1 0 0 wz--n- 5.00g 5.00g
  20. # lvcreate datavg -n datalv -L 3g
  21. Logical volume "datalv" created
  22. # mkfs.ext4 /dev/datavg/datalv
  23. mke2fs 1.41.12 (17-May-2010)
  24. Filesystem label=
  25. OS type: Linux
  26. Block size=4096 (log=2)
  27. Fragment size=4096 (log=2)
  28. Stride=0 blocks, Stripe width=0 blocks
  29. 196608 inodes, 786432 blocks
  30. 39321 blocks (5.00%) reserved for the super user
  31. First data block=0
  32. Maximum filesystem blocks=805306368
  33. 24 block groups
  34. 32768 blocks per group, 32768 fragments per group
  35. 8192 inodes per group
  36. Superblock backups stored on blocks:
  37. 32768, 98304, 163840, 229376, 294912
  38. Writing inode tables: done
  39. Creating journal (16384 blocks): done
  40. Writing superblocks and filesystem accounting information:
  41. done
  42. This filesystem will be automatically checked every 27 mounts or
  43. 180 days, whichever comes first. Use tune2fs -c or -i to override.
  44. # mkdir /datafs
  45. mount /dev/datavg/datalv /datafs/
  46. # df -h
  47. Filesystem Size Used Avail Use% Mounted on
  48. /dev/mapper/VolGroup-lv_root
  49. 88G 3.8G 80G 5% /
  50. tmpfs 939M 0 939M 0% /dev/shm
  51. /dev/sda1 485M 33M 427M 8% /boot
  52. /dev/mapper/datavg-datalv
  53. 3.0G 69M 2.8G 3% /datafs

Online file system expansion:

 
 
  1. # vgs datavg
  2. VG #PV #LV #SN Attr VSize VFree
  3. datavg 1 1 0 wz--n- 5.00g 2.00g
  4. # lvextend -L 4G /dev/datavg/datalv
  5. Extending logical volume datalv to 4.00 GiB
  6. Logical volume datalv successfully resized
  7. [root@esayops ~]# resize2fs /dev/datavg/datalv
  8. resize2fs 1.41.12 (17-May-2010)
  9. Filesystem at /dev/datavg/datalv is mounted on /datafs; on-line resizing required
  10. old desc_blocks = 1, new_desc_blocks = 1
  11. Performing an on-line resize of /dev/datavg/datalv to 1048576 (4k) blocks.
  12. The filesystem on /dev/datavg/datalv is now 1048576 blocks long.
  13. # df -h
  14. Filesystem Size Used Avail Use% Mounted on
  15. /dev/mapper/VolGroup-lv_root
  16. 88G 3.8G 80G 5% /
  17. tmpfs 939M 0 939M 0% /dev/shm
  18. /dev/sda1 485M 33M 427M 8% /boot
  19. /dev/mapper/datavg-datalv
  20. 4.0G 70M 3.7G 2% /datafs

Shrink the file system:

 
 
  1. # lvs
  2. LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
  3. lv_root VolGroup -wi-ao-- 89.00g
  4. lv_swap VolGroup -wi-ao-- 3.94g
  5. datalv datavg -wi-a--- 4.00g
  6. # umount /datafs
  7. # df -h
  8. Filesystem Size Used Avail Use% Mounted on
  9. /dev/mapper/VolGroup-lv_root
  10. 88G 3.8G 80G 5% /
  11. tmpfs 939M 0 939M 0% /dev/shm
  12. /dev/sda1 485M 33M 427M 8% /boot
  13. # resize2fs /dev/datavg/datalv 2G
  14. resize2fs 1.41.12 (17-May-2010)
  15. Please run 'e2fsck -f /dev/datavg/datalv' first.
  16. # e2fsck -f /dev/datavg/datalv
  17. e2fsck 1.41.12 (17-May-2010)
  18. Pass 1: Checking inodes, blocks, and sizes
  19. Pass 2: Checking directory structure
  20. Pass 3: Checking directory connectivity
  21. Pass 4: Checking reference counts
  22. Pass 5: Checking group summary information
  23. /dev/datavg/datalv: 11/262144 files (0.0% non-contiguous), 34382/1048576 blocks
  24. # resize2fs /dev/datavg/datalv 2G
  25. resize2fs 1.41.12 (17-May-2010)
  26. Resizing the filesystem on /dev/datavg/datalv to 524288 (4k) blocks.
  27. The filesystem on /dev/datavg/datalv is now 524288 blocks long.
  28. # mount /dev/datavg/datalv /datafs/
  29. # df -h
  30. Filesystem Size Used Avail Use% Mounted on
  31. /dev/mapper/VolGroup-lv_root
  32. 88G 3.8G 80G 5% /
  33. tmpfs 939M 0 939M 0% /dev/shm
  34. /dev/sda1 485M 33M 427M 8% /boot
  35. /dev/mapper/datavg-datalv
  36. 2.0G 69M 1.9G 4% /datafs

3 online delete a shared disk LUN

 
 
  1. pvremove
  2. multipath -f
  3. echo 1 > /sys/block/sdd/device/delete

E.g:

 
 
  1. [root@esayops /]# lsscsi -g
  2. [1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0 /dev/sg0
  3. [2:0:0:0] disk VMware Virtual disk 1.0 /dev/sda /dev/sg1
  4. [2:0:1:0] disk VMware Virtual disk 1.0 /dev/sdb /dev/sg2
  5. [2:0:2:0] disk VMware Virtual disk 1.0 /dev/sdc /dev/sg3
  6. [2:0:3:0] disk VMware Virtual disk 1.0 /dev/sdd /dev/sg4

Delete unused a lun

 
 
  1. [root@esayops /]# echo 1 > /sys/block/sdd/device/delete
  2. [root@esayops /]# lsscsi
  3. [1:0:0:0] cd/dvd NECVMWar VMware IDE CDR10 1.00 /dev/sr0
  4. [2:0:0:0] disk VMware Virtual disk 1.0 /dev/sda
  5. [2:0:1:0] disk VMware Virtual disk 1.0 /dev/sdb
  6. [2:0:2:0] disk VMware Virtual disk 1.0 /dev/sdc

Delete link:

 
 
  1. 1. Take the disk offline:
  2. cd /sys/block/sdb/device
  3. echo “offline” >state
  4. 2. Delete from /dev
  5. echo 1 >delete
  6. You can make your own script with the name rmdev ??
  7. #!/bin/ksh
  8. dev=$1
  9. [[ ! -d “$dev” ]] && echo “$dev does not exist” && exit 1
  10. echo “offline” >/sys/block/”$dev”/device/state
  11. echo 1 >/sys/block/”$dev”/device/delete

Eight Linux command master operation and maintenance

Command daily operation and maintenance of Linux use the following have too many memories of appropriate based on individual circumstances.
System load: Top, nmon, dstat and other
network: SS, netstat, route, diag, the ping, ip, lsof and other
IO: dd, iostat, FIO, nmon, dstat, PVS, LVS, Vgs of the and other
memory: as Free, dstat and other
process : PS, the lsof like
configuration: lscpu, the lspci, dmidecode, the lsscsi, the udev other
equipment identification: echo '---', the rescan-scsi-bus.sh other
diagnostic: the strace, the ltrace other
such well find how to combine xargs , Tree use, lsblk and so on, and many require long-term accumulation, of course, use or configuration of view, LVM setup, the network
there are a lot of mature open source and commercial product management, not in this list, feel free to Baidu and google.

Current mainstream python, ruby ​​These tools can choose a language according to their grasp.

Nine diagnostic tool

Among the daily operation and maintenance process, inevitably called to diagnose performance problems or failures, tools and means all-inclusive, here are some examples of some of the tools I use every day for reference,

 
 
  1. Pstack truss pmap gdb strace strace -o ssh.strace -Ttt -p 1983
  2. ipcs 共享内存 ipcrm
  3. ldd
  4. logsave logsave /tmp/logsave.log ls 纪录命令的输出到文件
  5. lastlog 纪录用户最后的登录时间 lastb显示用户错误登录的纪录
  6. logwatch 监控分析日志信息
  7. grpck /etc/group
  8. pwck /etc/passwd
  9. pidstat pidof
  10. iostat -xdm 1
  11. blockdev
  12. curl 访问web 测试 比lynx好一点

Here attach a Linux boot flow chart, so many people can be more clear understanding of Linux to solve such problems in the whole process started, the compiler.
123.png

123.png

Ten network nirvana

Netcat, SSH tunnel several forwarding mode, lsof, dstat, ethtool, iptraf, iperf, diag, route and route multiple network cards and dual NIC bonding technology should be understood that these are the os level operation and maintenance networks often use to several aspects

In daily operation is more commonly used to bind dual LAN to share a specific process of binding the following:

 
 
  1. 1、cp /etc/sysconfig/network/ifcfg-eth0 /etc/sysconfig/network/ifcfg-eth0.bak
  2. cp /etc/sysconfig/network/ifcfg-eth0 /etc/sysconfig/network/ifcfg-bond0
  3. 2、vi /etc/sysconfig/network/ifcfg-eth0,注释所有(除以下两行内容),并将值修改如下:
  4. BOOTPROTO='none'
  5. STARTMODE='off'
  6. 3、cp /etc/sysconfig/network/ifcfg-eth0 /etc/sysconfig/network/ifcfg-eth1
  7. 4、vi /etc/sysconfig/network/ifcfg-bond0,增加或更新如下内容,其他内容可注释:
  8. BOOTPROTO='static'
  9. IPADDR='192.168.1.100'
  10. NETMASK='255.255.255.0'
  11. STARTMODE='onboot'
  12. BONDING_MASTER='yes'
  13. BONDING_MODULE_OPTS='mode=0 miimon=100 use_carrier=0'
  14. BONDING_SLAVE0='eth0'
  15. BONDING_SLAVE1='eth1'
  16. 说明:以上配置mode=0为负载均衡模式,如果需要配置成主备模式,BONDING_MODULE_OPTS配置如下:
  17. BONDING_MODULE_OPTS='mode=1 miimon=100 use_carrier=0 primary=eth0'
  18. 5、rcnetwork restart,重启网络服务生效,并进行测试。
  19. 6、cat /proc/net/bonding/bond0 可以查看bonding的状态。

Guess you like

Origin www.cnblogs.com/zywu-king/p/11568256.html