The O & M of Enterprise Linux systems has become the focus of enterprises. As an excellent open-source network operating system, it is very important to make full use of Linux tools and use corresponding methods to improve O & M efficiency. In the first article, we introduced the use and practice of four application tools related to O & M. This article is the second article on this topic, the O & M of Enterprise Linux systems has become the focus of enterprise attention. As an excellent open-source network operating system, it is very important to make full use of Linux tools and use corresponding methods to improve O & M efficiency. In the first article, we introduced the use and practice of four application tools related to O & M. This article is the second article on this topic, this section focuses on the important principles and methods in the O & M process, including how to avoid problems and how to solve system problems, to provide a useful reference for the actual O & M of Enterprise Linux.
Need to Know I: enhanced communication between system administrators and system users
One of the main responsibilities of a system administrator is to communicate with system users. When a service system is shut down, an announcement is required when a new type of software is launched and how users can access new system printers. You can even start to act as a local tabloid to let users know new employees, RIF, birthdays, company picnic information, etc.
Different communications have different focuses. For example, the company picnic information within two months is different from the sensitivity of messages that will shut down the system within five minutes. To meet these different requirements, Linux provides different communication methods. The following list describes and compares the most common methods. These methods are generally provided to all users, except that the messages of the current day are generally reserved only for users with root permissions.
The following tools (utilities) can enhance the communication and communication between system administrators and system users.
Write: The write utility can be used to communicate with users logging on to the local system. For example, you can use it to ask the user to stop running the program of the slow system. the user may reply that it will be completed in three minutes. You can also use write to require the system administrator to Mount tape or restore files. The message sent by write may not appear in the graphic environment.
IM: Empathy IM (Internet Message; live.gnome.org/Empathy) utility uses GoogleTalk, MSN, IRC, AIM, Facebook, Yahoo, ICQ and other protocols to support text, voice, video chat and file transmission. You can click the main menu: Applications? Internet? EmpathyInternet Messaging. IM is common in many workplaces and can be used to contact Red Hat support.
The Wall: wall (writeall) utility can effectively communicate with all logged-on users in real time. This utility gets input from standard input, working in a similar way as write, but users cannot use wall to write only one person back to you. If you want to shut down the system or in other crisis situations, you can use wall. users without logon will not be able to receive messages. You can use the root user identity to run wall only in the case of crisis; it will interrupt anyone's work. Messages sent by wall may not appear in the graphic environment.
Email: Email is used to communicate less urgent with one or more systems and/or remote users. After sending an email, you must be willing to wait for each user to read it. Emails can be used to remind users who forget to log out. Their bills are overdue, or they use too much disk space. Contrary to messages received through write, users can easily permanently store records of messages received through email, so they can track important details at any time. For example, you can use an email to notify users of a new complex operation process so that each user can keep a copy of the information for reference.
Message of the current day: the user will see the message of the current day every time they log on to the text environment, but will not see the message when they open the terminal simulator window. If necessary, you can edit the/etc/motd file to change the message. The message on the current day reminds users of scheduled maintenance, updates to new system functions or programs.
Need to Know II: problems that may occur during O & M
Even experienced system administrators make mistakes. of course, new system administrators make more mistakes. Although you can reduce the possibility of a problem by carefully reading and following the instructions in the software documentation, many problems still occur. No matter how long a list is, it cannot be comprehensive, because every day there will be new problems. This section describes some common skills to avoid problems.
First, perform regular backup: for a system administrator, nothing is more painful than losing important information forever. If the local system supports multiple users, recent backup may be the only protection against public condemnation. If you are using a single-user system, when you lose a hard disk or accidentally delete a file, a recent backup will certainly make you happy.
Second, read and follow the instructions: software developers provide documents. Even if the software package has been installed, read the instruction carefully again. They may have changed, or you may remember wrong. Software changes are faster than book revisions, so there is no specification to be foolproof. Therefore, you need to find the latest online documentation for reference. The/usr/share/doc directory contains information about utilities, libraries, and software packages.
When the instructions are unclear, ask for help: if the instructions seem ambiguous, try to find clear instructions.
Finally, delete or mistakenly enter information in a key File: a method that will definitely bring you a nightmare is to execute commands. Maybe no other command will make the Linux system useless so quickly. The only way is to start from the installation media to restore the installed system and recover lost files from the latest backup. Although this example describes an extreme situation, many files are the key to the normal operation of the system. Deleting one of these files or mistakenly inputting information in these files can almost certainly cause problems. For example, if you directly edit the/etc/passwd file, entering an error message in a field will make one or more users unable to log on. In addition, do not go to rm? In rf, use a parameter that contains a wildcard. after you enter the command, pause and read it, and then press Enter. Carefully check what you have done and make a copy of the key file before editing it. In particular, be careful when using rm with wildcard characters. When you must use a parameter (such as *) containing wildcards in the rm command, specify the I option so that rm will prompt you before deleting each file. Alternatively, you can use the echo command with the same parameters to check which files will be deleted. This check is especially important when the root permission is used.
Method: solve the actual problem during O & M
The system administrator is responsible for keeping the system safe and smooth. When a user encounters a problem, the administrator is usually asked to help the user back to the right track. The recommended methods in this section can maintain user satisfaction and optimal system performance.
The ten-step method solves the login failure problem for users.
When a user cannot log on to the system, the root cause may be a user error or a hardware or software fault. The following ten steps help you identify the problem.
Step 1: check the log files in/var/log. The/var/log/messages File collects system errors, messages from The Daemon, and other important information. It may indicate the cause of the problem or more symptoms. In addition, check the system console. Sometimes messages related to system problems are not written to/var/log/messages (for example, a complete disk), but displayed on the system console.
Step 2: determine whether there is a problem or a wider problem with the terminal/workstation of only one user or one user.
Step 3: confirm that the user has not enabled its caps lock key.
Step 4: make sure that the user's home directory exists and that there are entries corresponding to the user in the/etc/passwd file. Verify that the user has his/her home directory and startup files, and that they are readable (and that the user has executable permissions on his/her home directory ). Make sure that the user logon shell entry in/etc/passwd is accurate and the specified shell exists.
Step 5: If the user forgets his/her password, change the password of the user.
Step 6: check the user's startup file (. Profile ,. Login ,. Bashrc ). This user may have edited one of these files and introduced a syntax error that disables logon.
Step 7: check the data cable between the terminal or the terminal and the computer. Try to close the terminal or monitor and then turn it on again.
Step 8: Check whether you can log on to the console when the problem appears wide. Make sure that the system is not in single-user mode. If you cannot log on, the system may have crashed and you need to restart it and perform any necessary recovery steps.
Step 9: use df to check the entire file system. If the/tmp file system or the user's home directory is full, logon may fail unexpectedly. In some cases, you may be able to log on to the text environment, but not to the graphic environment. When a user logs on to an application, the application cannot create a temporary file or update a file in the user's home directory, the logon process may terminate.
Step 10: If you log on through a network connection, you need to restart the service (such as ssh) that the user is trying to use ). Make sure that the clock on both systems is synchronized. When encrypted logon methods such as HTTPS, ssh, LDAP, and kerberos are used, different clock settings may cause logon failure. Make sure that DNS works properly. Some network services have a strong correlation with name resolution, including reverse lookup (that is, the name resolution problem will lead to a slow connection through ssh ).
Accelerate system operation
When the system runs slowly for unknown reasons, the process may not be closed when the user logs out. The performance of this problem includes a long response time and a large amount of system load. if data shown in w or uptime is greater than, it is best to run top to quickly locate rogue processes. Use ps? Ef can list all processes. In ps? The ef output contains a large number of TIME columns. For example, if the TIME field of the Firefox process exceeds 100.0, the process may not run properly. However, if the user is performing a lot of Java work and has been logged on for a long time, this value may be normal. Check the STIME field to view the start time of the process. If the running time of the process is longer than that of the user's online logon, it is better to stop the process.
When a user leaves an unattended terminal without notice, it is best to terminate all processes owned by the user. If you run the GUI on the console, terminate the process or window manager that starts the desktop environment. You also need to continue searching for process names including gnome-session, startkde, or other processes ending with wm. Generally, the window manager is the first and last process to run and exits when the user logs out. If the termination window manager does not work, try to terminate the X server process, which is usually listed as/usr/bin/Xorg. if the above operation fails, when you log on as this user, run kill? 15? 1 Command or equivalent kill? TERM? 1 Command to terminate all processes owned by the user. Use? 1. replace the process ID to tell kill to send signals to all processes owned by the user. For example, as root, you can enter the following command:
# Su zach-c 'kill-TERM-1'
If you cannot terminate all processes (sometimes the TERM cannot terminate the process), you can use the KILL signal (? 9 ). The following line will definitely terminate all processes owned by Zach, but it is unfriendly:
# Su zach-c 'kill-kill-1'
If su zach is not included? C. This command will shut down the system.
Master and find open files
The lsof utility displays the opened file name. The options only show some processes, only some file descriptors of a process, or only some network connections (network connections use file descriptors, just like normal files, lsof also displays these ). Use ps? After ef determines the suspicious process, enter the following command:
# Lsof-s-p pid
Replace the PID with the ID of the suspicious process. lsof will display the list of file descriptors opened by the PID process .? The s option shows the size of all opened files ,? The p option allows you to specify the process PID you are interested in (if you combine these options, lsof will not run ). The file size information is used to determine whether a very large file is opened by the process. In this case, you need to contact the owner of the process or terminate the process if necessary .? Rn indicates that the lsof output is re-displayed every n seconds.
Keep machine logs for auditing
Machine logs contain information shown in Table 1, which helps you locate and fix system problems. It is used to record the date and time of each entry in the log. Avoid retaining logs only on the computer. this is the most useful when the system is disabled. At the same time, emails that detail user issues are retained. One policy is to save the email to a single file or folder that you can read. Another method is to set up an email alias so that you can send an email to the alias when there is a problem. This alias can forward emails to you and store copies in the archive file.
Table 1 Machine log classification
The following is an example of the entries in the/etc/aliases file. you can set this type of Alias: trouble: admin,/var/spool/mail/admin. emails sent from archive to the trouble alias are forwarded to the admin user and stored in/var/spool/mail/admin. archive file. It is absolutely safe to keep the system running securely without any system that uses dial-up lines or public access terminals. However, you can often change the root password and choose a password that is difficult to guess, so that the system is as secure as possible. Do not tell anyone who absolutely does not need the root password. You can also encourage the system to select a difficult password and change it on a regular basis. By default, the passwords on Fedora/RHEL use MD5 hash, which makes them more difficult to crack than those encrypted using DES. Of course, if the encrypted password is easy to find or guess, the difference is not big. The system-config-authentication utility allows you to specify a local Password hash Algorithm. you can select the Advanced Options tab and select from the Password Hashing Algorithm drop-down box. A difficult-to-guess password is the one that others think is not possible. Do not use words, family members, pets, friends' names or foreign words in the dictionary. A good strategy is to select a phrase that contains some punctuation marks (for example, place ^ between them), a mix of uppercase and lowercase, and replace the letters of some words with numbers. The example of a good password is C & yGram5 (candygrams ). Ideally, you can use a random combination of ASCII characters, but this is hard to remember. You can use several password cracking programs to find the user who chooses a weak password. These programs work by repeatedly hashing words in dictionaries, phrases, names, and other sources. If the hash password matches the program output, the program discovers the user password. The two password cracking programs are crack (crack package) and john (www.openwall.com/john#johnpackage ). These and many other programs and security tips can be obtained from CERT (www.cert.org, Computer EmergencyResponse Team Computer Emergency Response Team. Cracking a good password requires a lot of computing power. The password cracking program generally first looks at character sets consisting of uppercase letters, lowercase letters, and numbers. When adding symbols, they must do more work to crack the password. In addition, the longer the password, the more computing power required for cracking. The password is long enough to make it more difficult to be cracked and short enough to be easily remembered. The length of 8 to 20 characters is usually good. The password must contain symbols such as #, @, and %. If it takes too long to crack your password, the person or machine responsible for cracking may be transferred to the account that is easy to crack. The Setuid file ensures that only users with root permissions can write files containing root programs and run in setuid mode (for example, passwd and su ). In addition, ensure that the user does not transfer the programs running in setuid mode and the programs owned by root to the mounting system. These programs can be used to bypass system security. One technology that prevents users from having a setuid file is to use the nosuid flag for mounting. you can set it in the flag section of the fstab file. The BIOS in many machines provides a certain degree of protection to prevent unauthorized users from attempting to modify the BIOS or restart the system. When setting BIOS, you can find the Security section. You may be able to add a BIOS password. If you rely on the BIOS password and use the jumper on the motherboard when the computer is locked, it is usually easy to reset the BIOS password. The root log file and email users often send emails to the root and postmaster to communicate with the system administrator. If you do not forward the root email to yourself, check the root email regularly. When you use su to execute system management tasks, you will not receive a reminder email that has reached the root user. However, you can use su? C' mail? Run the "u root" command to view the root email. Regularly check system log files to find evidence of problems. Some important files include/var/log/messages, which records errors of the operating system and some applications;/var/log/secure, which contains messages related to system security; /var/log/maillog, which contains the mail system error;/var/log/cron, which contains the crond message. The logwatch utility (logwatch package) is a report writer written in Perl that can send e-mail reports on log files. By default,/etc/cron. daily/0logwatch runs this script every day and sends it to the root user. For more information, see the logwatch manual page and the script itself. The system may use up disk space sooner or later to monitor disk usage. Therefore, do not fill up a partition. When a partition has at least 5% to 30% of the remaining space, the speed of writing files to Linux is significantly faster. If the used space of a partition exceeds the maximum disk space, the system performance will be reduced. Fragment when a file system is full, it will become fragmented. This is similar to the concept of DOS fragment, but it is almost invisible and usually rare in modern Linux file systems, because the design of Linux file systems is fragmented. If you do not fill up the file system, you may never have to worry about fragmentation. If there is no space in the file system, data cannot be written. To check file system fragments, uninstall the file system and run fsck on it; use it on ext2, ext3, and ext4 file systems? F option. The fsck output includes the percentage of file system fragments. You can sort out the file system through Backup. First, use mkfs to create a clean empty image and restore the file system. Which tool is used for backup and recovery is not important. Reporting Linux provides several programs to report the disk space of which file systems are being used. Refer to the "du", "quota", "df", and "find utility" pages? Size option. In addition to these utilities, you can also use the disk quota system to manage disk space. The four major strategies for increasing the number of files available on the file system with rapid growth are: Compressing files, deleting files, increasing the number of LVM-based file systems, and compressing directories. Some files (such as log files and temporary files) will inevitably grow over time. For example, the core dump file occupies a large amount of space, but is rarely needed. In addition, occasional programs run by users may generate huge files accidentally. As a system administrator, these files must be reviewed on a regular basis so that they are not out of control. If a file system quickly consumes space (for example, within an hour, instead of weeks or months), first figure out the cause of space depletion. Ps available? Ef command to determine whether the user has created a process out of control and generated a huge file. When evaluating the ps output, you can find a process that consumes a lot of CPU time. If such a process is running and a large file is created, the file will continue to grow and thus need to be freed up. If a large file is deleted, the occupied space is not released unless the process is terminated. In this case, you need to contact the user who runs the process and ask him to terminate the process. If the user cannot be contacted, use the root permission to terminate the process. In addition, a large log file can be truncated rather than deleted, although logrotate can also be used to better handle this common situation. For example, if the/var/log/messages file is very large due to incorrect configuration of the system daemon, you can use/dev/null to truncate it: # cp/dev/null/var/log/messages or # cat/dev/null>/var/log/messages or do not need to derive a new process, #:> /var/log/messages if you delete/var/log/messages, you must restart the rsyslogd daemon. If you do not restart rsyslogd, the space on the file system will not be released. When no process consumes disk space and the capacity is gradually used up, you need to find and delete unnecessary files. You can use cpio, dump, or tar to archive these files before deleting them. You can safely delete most core files that have not been accessed for a few days. The following command line can execute this function without deleting necessary core files (such as/dev/core ): # find/-type f-name core | xargs file | grep 'B core file' | sed's/: ELF. * // g' | the xargs rm-f find command lists all common files named core and sends the list to xargs. xargs runs file on each file in the list. the file utility displays a string containing files to be deleted, such as B corefile (the created core dump file. The grep command filters out any lines from the file that do not contain this string. Finally, sed deletes everything after the colon, so that all the paths of the core file that remain on the line are the path names of the core file, and xargs deletes the file. To free up more disk space, you can carefully review and delete the old temporary files in the/tmp and/var/tmp directories. Keep track of disk usage in/var/mail,/var/spool, and/var/log. It is usually inefficient to delete directories that do not use space that contains too many files. The reason for the inefficiency of directories on the ext2, ext3, or ext4 file systems depends partly on the length of the file it contains. The best practice is to keep the directory relatively small. It is recommended that a directory contain fewer files instead of hundreds of files (or directories). it is usually difficult to include thousands of files. In addition, Linux uses a caching mechanism for frequently accessed files to accelerate the process of finding their inode from the file name. This caching mechanism only supports a file name with a maximum of 30 characters. Therefore, you should avoid accessing a file with a very long file name. When a directory becomes too large, it can usually be divided into several smaller directories and moved to those new directories. After moving the contents of the Directory, make sure to delete the original directory. Because the Linux directory does not automatically shrink and the files in the deleted directory will not shrink, even if it releases all disk space. Therefore, to delete unused space and make the directory small, you must copy or move all files to a new directory and delete the original directory. The following process deletes unused directory spaces. First, delete all unnecessary files from the large Directory, create a new empty directory, and then move all the remaining files from the old large directory or copy them to the new empty directory. Remember not to forget to copy hidden files. Delete the old directory and name the new directory. # Mkdir/home/max/new # mv/home/max/large/*/home/max/large /. [A-z] */home/max/new # rmdir/home/max/large # mv/home/max/new/home/max/large