In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to operate the operating system in linux, the article is very detailed, has a certain reference value, interested friends must read it!
Basic knowledge of Linux operating system: 1, the operating system distinguishes between physical memory and virtual memory;2, understand the relationship between memory and hard disk;3, the vulnerabilities that often occur in various parts, such as the mail server and dynamic web server that are prone to such bottlenecks in the CPU;4, master some optimizations of Linux itself.
Linux operating system basics:
1. Operating system overview
CPU: Just like the human brain, it is mainly responsible for the judgment of related things and the actual processing mechanism.
Query command: cat /proc/cpuinfo
Memory: A memory block in the brain where information collected by skin, eyes, etc. is recorded for CPU judgment. Query command: cat /proc/meminfo
physical memory
Physical memory is the capacity of the memory stick we insert into the memory slot of the motherboard. When looking at computer configuration, the main thing to look at is this physical memory.
virtual memory
Windows uses virtual memory technology, that is, take out a part of the hard disk space to act as memory use, when the memory is used up, the computer will automatically call the hard disk to act as memory, in order to ease the tension of memory.
Relationship: Windows virtual memory and physical memory may be used, linux, only physical memory used up, virtual memory will be used
·Hard disk: A memory block in the brain that records important data for future use.
Query command: fdisk -l (requires root privileges)
2. Memory and hard disk relationships
Specific commands will be introduced later
3. Operating system monitoring commands> Write a separate copy
·vmstat
·sar
·iostat
·top
·free
·uptime
·netstat
·ps
·strace
·lsof
4. How to Analyze Operating Systems
Actual flow: read data> data> hard disk> virtual memory (swaP)> memory> cpu cache> execution queue
Analysis direction, exactly the opposite
5.... loopholes that often occur in various parts.
CPU: mail server, dynamic web server prone to such bottlenecks
Memory: Print servers, database servers, static web servers prone to this type of bottleneck
·Disk I/O: projects with frequent read and write operations
·Network bandwidth: frequently upload and download a large number of projects
Some optimizations of Linux itself
1. System installation optimization
When Linux is installed, disk partitioning and SWAP memory allocation directly affect system performance. For the SWAP setting of virtual memory, there is no requirement that the virtual memory is twice the physical memory, but according to experience, if the memory is small (physical memory is less than 4GB), generally set the SWAP swap partition size to twice the memory; if the physical memory is about 4GB less than 16GB, you can set the SWAP size equal to or slightly smaller than the physical memory; if the memory is more than 16GB, in principle, you can set SWAP to 0, but it is best to set SWAP of a certain size.
· 2. kernel parameter optimization
For example, if the Oracle database application deployed by the system is used, then it is necessary to share the memory segment (kernel.shmmax, kenerl.shmmni, kernel.shmall) with the system.
System semaphore (kernel.sem), file handle (fs.file0max) and other parameters are optimized; if the deployed WEB application, network parameters need to be optimized according to the characteristics of the web application, such as modifying net.ipv4.ip_local_port_range, net.ipv4.tc_tw_reuse, net.core.somaxconn and other networks.
kernel parameters
· 3. File system optimization
Optional file systems under linux are ext2, ext3, xfs, ReiserFS
The Linux standard file system starts with VFS, then ext, ext2, ext2 is the standard file system on Linux, ext3 is formed by adding logs on the basis of ext2. From VFS to ext3, the design philosophy has not changed much, all of which are based on the design philosophy of superblocks and inode in the early UNIX family. XFS file system is an advanced log file system developed by SGI. It provides low-latency and high-bandwidth access to file system data by distributing disk requests, locating data and maintaining cache consistency. Therefore, XFS is extremely scalable and robust, with excellent logging function, strong scalability and fast writing. ReiserFS is a high-performance journaling file system developed under Hans Reiser, which manages data through a fully balanced tree, including file data, file names, and journal support. Compared with ext2 and ext3, the biggest advantage is that access performance and security are greatly improved. It has the advantages of efficient and reasonable use of disk space, advanced log management mechanism, special search mode, mass disk storage, etc.
4. key knowledge
physical and virtual memory
(1). How do I view physical and virtual memory?
The Top command allows you to view values for physical memory and virtual memory
(2).Buffer
A memory chip on a hard disk controller that has extremely fast access speeds and acts as a buffer between the hard disk's internal storage and external interfaces. Because the internal data transmission speed of the hard disk is different from the external interface transmission speed, the cache plays a buffer role in it. The size and speed of cache are important factors directly related to the transmission speed of hard disk, which can greatly improve the overall performance of hard disk.
(3).Cache
CPU cache memory (Cache Memory) is located between the CPU and memory temporary storage, its capacity is much smaller than the memory, but the exchange speed is much faster than the memory. The appearance of cache is mainly to solve the contradiction between CPU operation speed and memory read and write speed, because CPU operation speed is much faster than memory read and write speed, which will make CPU spend a long time waiting for data to arrive or write data to memory. The data in the cache is a small part of the memory, but this small part is the CPU will access in a short time, when the CPU calls a large amount of data, it can avoid memory directly from the cache, thus speeding up the read speed.
(4) CPU interrupt
When the CPU finishes executing a current instruction, if the peripheral issues an interrupt request to the CPU, the CPU will issue an interrupt response signal if the response is satisfied, and at the same time close the interrupt, indicating that the CPU is not accepting the interrupt of another device. At this time, the CPU will find out which device is the source of the interrupt request and save the contents of the CPU's own program counter (PC). He then moves on to the interrupt service routine that handles the interrupt source. The CPU will recover the field information after saving the field information and equipment services (such as exchanging data). After these actions have been completed, the interrupt is opened and the next instruction in the main program is returned to where it was interrupted.
(5). context switch
Context Switch or Environment Switch
In multitasking systems, a context switch is an event that occurs when control of the CPU is transferred from a running task to another ready task.
In an operating system, CPU switching to another process requires saving the state of the current process and restoring the state of the other process: the currently running task goes to a ready (or suspended, deleted) state, and another selected ready task becomes the current task. Context switching involves saving the runtime environment of the current task and restoring the runtime environment of the task to be run.
The process context is represented by the PCB (process control block, also known as PCB, i.e. task control block) of the process, which includes the state of the process, the value of the CPU register, etc.
A state save is usually performed to save the CPU's current state, and then a state restore is performed to restart operation.
Context switching negatively impacts performance. However, some context switches are more expensive than others; one of the more expensive context switches is the Cross-Core Context Switch. A thread can run on a dedicated processor or across processors. Threads served by a single processor have Processor Affinity, which is more efficient. Kernel preemption and scheduling threads on another processor can cause cache misses, accessing local memory as a result of cache misses and excessive context switches. In short, this is called "cross-core context switching."
6. processes and threads
Process concept
Process is the basic unit of resource allocation and scheduling. For example, if a user runs his own program, the system creates a process and allocates resources to it, including various tables, memory space, disk space, I/O devices, and so on. The process is then placed on the process's ready queue. The process scheduler selects it, allocates CPU and other related resources to it, and the process actually runs. A process is a unit of concurrent execution in a system.
threading concepts
A thread is the smallest unit of computation performed in a process, i.e. the basic unit of processor scheduling. If a process is understood as a task logically accomplished by the operating system, then a thread represents one of many possible subtasks to accomplish that task
Relationship between processes and threads
A thread can belong to only one process, and a process can have multiple threads, but at least one thread. (2) Resources are allocated to a process, and all threads of the same process share all resources of the process.
(3) The processor is divided into threads, that is, what really runs on the processor is threads.
(4) Threads need to be synchronized collaboratively during execution. The threads of different processes should be synchronized by means of message communication.
Related learning recommendations: Linux video
Note:
Linux is a case-sensitive system, Mozilla, MOZILLA, mOzilla and mozilla are four different commands (but only the fourth mozilla is really valid). Also, my_filE, my_file, and my_FILE are three different files. User logins and secrets are also case-sensitive (this is because UNIX systems and the C language have traditionally been case-sensitive).
2. File names can have up to 256 characters and can contain numbers, dots, and ". ", underscore"_", crossbar"-", plus some other characters that are not recommended.
3. File name preceded by ". "files are generally not displayed when entering the"ls"or"dir"command. You can think of these files as implicit files, but you can also display them using the command "ls-a".
4. A "/" pair equals "\" in DOS (root directory, meaning parent directory of all other directories, or a space symbol between directories and between directories and files). For example, cd /usr/doc.
5. Under Linux, all directories are displayed under a single directory tree (as opposed to the drive identifier for DOS). This means that all files and directories on all physical devices are consolidated under a single directory tree.
6. In configuration files, lines starting with #are comment lines. Try not to delete old settings when modifying configuration files-you can add "#" to the original settings into comment lines, always add some comments about modifications in the modified places, and you will find that you will benefit a lot from future management.
Linux is an inherited multi-user operating system. Your personal settings (and those of other users) are placed in your home directory (usually/home/your_user_login_name). Many configuration files have file names starting with ". "So users generally don't see these files.
8. System-wide settings are generally placed in the directory/etc.
9. Similar to other multiuser operating systems, under Linux files and directories have their own owners and access rights. In general, you are only allowed files in your home directory (/home/your_user_login_name). Learn something about file permissions management, or you'll find Linux a real pain in the ass.
10. Command parameter options are generally preceded by a "-" followed by a single character (or "--" when the option is more than one character). Thus,"-" is a bit like "/" in DOS. For example, type the command rm --help.
That's all there is to how linux operates, thanks for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.