In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you the "sample analysis of Linux system configuration", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and study the "sample analysis of Linux system configuration".
Preface
The Linux operating system contains a large number of service programs, which start or terminate according to the preset state when switching runlevels. Many of the system services may not be needed by users, but they are also run by default.
1. System service control 1. Systemctl
In the CentOS system, the control scripts for various system services are placed in the usr/lib/systemd directory by default, and the specified system services can be controlled by the systemctl command tool. The syntax format is as follows.
Systemctl Control Type Service name
For most system services, several common types of control are as follows
Start (start): run the specified system service program to realize the service function stop (stop): terminate the specified system service program, turn off the corresponding function restart (restart): exit first, then rerun the specified system service program reload (reload): do not exit the service program, just refresh the configuration Same status as restart operation in some services (View status): view the running status and related information of the specified system service
For servers running in the actual production environment, do not easily perform stop or restart operations, so as to avoid interrupting client access and causing unnecessary losses. if you just want to enable the new configuration for the system service, you can reload the configuration with a relatively mild "reload" parameter instead of bluntly executing "restart". For example, for a httpd service that is providing users with Web access, when you need to apply the new configuration It is recommended that you execute the "systemctl reload httpd.service" command to reload the configuration instead of "systemctl restart httpd.service"
2 、 target
(1) View target
Defining the target of the current system will help the administrator to troubleshoot some application problems. If you do not know the current target, you can directly execute the "runlevel" command to query. The two characters in the display result represent the target before the switch and the current target, respectively. If the running level has not been switched before, the first column will show "N".
If users want to see the default target running when the system starts, they can execute the "systemctl get-default" command to display the default target of the system.
The target of run-level systemd indicates that 0target uses this level to turn off host 1rescue.target single-user mode and log in to the system without password authentication. It is mostly used for system maintenance of 2multi-user.target user-defined / domain-specific runlevels, which by default equals the full multi-user mode of 33multi-user.target character interface, at which most server hosts run at 4multi-user.target user-defined / domain-specific runlevels. By default, it is equivalent to the multi-user mode of the 35graphical.target graphical interface, and provides a graphical desktop operating environment 6reboot.target restart, which will restart the host when used.
(2) switch target
When the user needs to convert the system to other target, it can be done through the traditional init program, as long as the number corresponding to the run level (0-6) is used as the command parameter, or the systermctl command is used to switch the target. For example, in order to save system resources, change the target running of the system from graphic mode (5) to character mode (3), and execute "init 3" or "systemctl isolate multi-user." Target "command, after switching the system to character mode, the graphical desktop environment is no longer available, and pressing the Alt+F7 key combination will not restore the graphical desktop environment. When you need to use the graphical desktop again, you can execute the" init 5 "or" systermctl isolate graphical target "command to switch back.
By switching the operation of target, you can also achieve two special functions, that is, shutdown and restart. Run levels 0 and 6 correspond to shutdown and restart modes respectively, so as long as you execute the command "init 0" or "init 6", you can achieve the corresponding shutdown or restart operation, and run level 0 and 6 correspond to the "poweroff.target" and "reboot.target" goals of systemd, respectively. Therefore, the corresponding shutdown and restart operations can also be achieved by executing "systemctl poweroff" and "systemctl reboot" commands.
To permanently switch runlevels, you can change the boot default runlevel of the current system from graphical.target to multi-user.target by executing the following command
Systemctl set-default runlevel3.target
Use the following command to switch the boot interface back to graphical interface mode
Systemctl set-default runlevel5.target
3. Common system services
In the CentOS system, more than 100 system services are installed by default. These system services provide rich application services for users. Only by knowing the purpose of each system service can we selectively optimize the operation and enable Linux services on demand.
Common system Services in CentOS system
Service name usage atd extension, regular task bluetooth discovery, authentication Bluetooth related devices crond performs scheduled tasks irqbalance multicore CPU processor scheduling support kdump records memory information during kernel collapse lvm2-monitorLVM management and monitoring netfs access to shared folders and other network file system network configuration and use network card, network address restorecondSELinux security mechanism file monitoring and recovery function rhnsd access Red Hat Network Get notifications, submit subscriptions, etc. Rpcgssd management NFS (Network File Systeam, network file system) access client program context saslauthd text-based authentication smartd monitors the status of the local hard disk and sends failure reports smb file sharing service sshd provides remote login and management of Linux host functions rsyslog records kernel, system log information vsftpd provides file upload and download functions through FTP (File Transfer Protocol, file transfer protocol)
It must be emphasized that whether these services are turned on or off should be determined according to the actual functional requirements of the host. For example, if the current Linux host is used to provide file sharing services to the local area network, then the smb service should be enabled, not closed.
4. Self-booting service management
The Linux operating system will enter the default systemd running target (such as character mode or graphics mode) after each boot, and run various system services that are set to start by default in this goal. To prevent some system services from running automatically, you can use ntsysv or systemctl tools for optimization.
(1) use ntsysv
The ntsysv tool can be run in character mode, providing users with a graphical interactive interface designed to centrally configure the startup status of various system services. When you need to set the startup status of multiple services at the same time, it is very convenient to use the ntsysv tool. When you execute the "ntsysv" command alone, it is only used to manage the services in the current running target. The "--level" option allows you to manage the services in the specified running target (level). For example, by executing the "ntsysv-- level 35" command, you can open the ntsysv management program, press the direction key to select different system services, press the Space (space) key to set the default startup state of the service ([*] indicates startup, "[]" indicates shutdown), and if you want to view the description information of the selected service Press F1 to get help
(2) use systemctl
The function of the systemctl tool is similar to that of ntsysv, but systemctl does not provide an interactive operation interface. It is used to query or set the default startup state of system services. When you need to set the default startup state of a service in the current running target, it is more efficient to use the systemetl tool.
There are three common options
Enable: auto boot disable: boot auto shutdown is-enable: check boot status
Execute the "systemctl list-units-- type=service" command under the current system to view all activated system services on the current system
Second, service management 1, firewall and core protection
In general, it is not recommended to turn off firewall and core protection.
Firewall operation
Systemctl status firewalld.service View Firewall status systemctl stop firewalld off Firewall systemctl start firewalld enable Firewall systemctl disable firewalld boot automatically close Firewall systemctl enable firewalld boot automatically start Firewall
Core protection operation
Setenforce 0 temporarily turn off Selinux protection, disable vim / etc/sysconfig/selinux after restart or shutdown, open selinux file "modify SELINUX=disable" and save exit, permanently close Selinux protection vim / etc/selinux/config open config file "modify SELINUX=disable" save exit, permanently close Selinux protection 2, time management
Install the ntpdate service
Yum-y install ntp ntpdate
Set to synchronize with network time
Ntpdate time server (ntp1.aliyun.com, time.nist.gov,time.nuri.net) hwclock-- systohc writes system time to hardware (BIOS) timedatectl View system time date View Centos current system time Command 3, SSH Service
SSH is a reliable protocol designed to provide security for remote login sessions and other network services. The use of SSH protocol can effectively prevent information disclosure in the process of remote management. You can remotely manage Linux by establishing a SSH connection. The method to turn on SSH is as follows
Vim / etc/ssh/sshd_config
Remove the # in front of PasswordAuthentication and change it to yes
Service ssh start starts SSH service netstat-anptu | grep sshd checks service process status service ssh status verifies SSH service status update-rc.d ssh enable sets SSH boot self-boot above is all the contents of this article "sample Analysis of Linux system configuration". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.