1. soft difference between connection and hard links
2. principles of Linux file deletion
3. Linux system boot process
BIOS (basic input output system)
- 1. check the hardware, namely, computer hardware meets basic criteria. (If the hardware Board issues the beep frequency, start end);
-
2. find the boot floppy disk, CD, or hard drive installed in the programs (boot record, or MBR);
-
3. load the boot program (MBR) is loaded into memory and transfers control to the MBR.
MBR (master boot record)
-
Load and execute GRUB
MBR is located in the first sector of the boot disk (usually/dev/hda or/dev/sda)
Total of 512-bit MBR consists of three components:
① 1-446bit master boot loader information
② 447-510bit storage partition table
③ 511-512bit stored MBR valid tags
GRUB (the Boot Manager)
-
Load and execute the kernel and initrd image
GRUB will let you select a boot kernel
GRUB through profiles to find the kernel and Initrd image and initrd image contains the basic kernel module driver
Kernel
-
1. Mount the root file system;
-
2. run/sbin/init program Initializes the system environment;
Because init is performed first by Linux program, so it processes 1.
Before the root system is mounted, initrd used by the kernel as a temporary file system, kernel, Qidong modified initrd to load the root drive, complemented by mounting the root partition on a drive.
init
-
According to set Linux/etc/inittab runlevel
Runlevel programs
-
Depending on the run-level, executive-level programs
S opening procedures for starting the process, that is, startup;
K procedures to shut down processes used at the beginning, that is, kill.
S and k behind the numbers represent the order of execution
That is, S12syslog, the start of the process order is 12.
S80sendmail the boot order is 80, will start later than syslog.
4. the top right corner of the command load average values mean, above represents the load problems
Split the four elements:
1. load average (average system load) what is it?
System load average is defined to run at a specific time interval in the queue (or waiting to run many processes running on the CPU) the average number of processes.
2. the load average of the three values stand for?
By top\uptime\w can get to the load average values, three figures were recorded in the value of the minute of it five minutes \ \ 15 minute average system load.
3. the above how many loads have problems?
Above represent the load there is a problem, there are two rules:
-
“How many core for the number of load” rule: multi-core processing, your system should not be higher than the total number of processor cores.
- “Core core” rule: core distributed in several individual physical treatment is not important, in fact, two quad-core processors is equal to four dual-core processors and eight single processor. Therefore, it should have eight processor cores.
4. which number we prevail? One minute? Five minutes? Or 15 minutes?
I think you should focus on the five-minute or 15-minute average. Frankly, if you load a minute ago was 1.00, it can still be found server situation is normal. But if values remain at 1.00 for 15 minutes, then it is worth noting that (in my experience, then you should increase the number of processors).
5. viewing network I/O commands
Dstat: versatile system resource statistics tool, not only can get NET (Internet) information, you can also get disk (hard drive) \ processor (CPU) and other information, the results can be saved as a CSV.
Dstat used as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
dstat [-afv] [options ..] [delay [count]] Use dstat -h to see all the options, not list them here, following a brief under common options Common options are as follows: # Directly with the number that #s collects data, the default is one second; dstat 5 represents updated every 5 seconds -c, - cpu CPU state statistics, including the user, system, idle (idle waiting percentage of time), wait (waiting for disk IO), hardware interrupt (hardware interrupt), software interrupt (software unloading Greek ┑ caries?? -d, --disk statistical disk read and write state -D Total, sda statistical information specified disk or summary -l, --load statistical system load, including 1 minute, 5 minutes, 15 minutes averages -m, --mem statistical system physical memory usage, including used, buffers, cache, free -s, --swap statistics have been used and the remaining amount of swap -n, --net network usage statistics, including receiving and sending data -N Eth1, total traffic statistics eth1 Interface Summary -r, --io statistics I / O requests, including read and write requests -p, --proc statistical process information, including runnable, uninterruptible, new -y, --sys statistics system information, including interrupts, context switches -t display statistics when the time is very useful for analyzing historical data --fs statistics number of open files and inodes count |
Under the network command to view
1
|
dstat -N lo,eth0 100 5 |
Explanation: the specified view Lo and eth0 network card, every piece of data there are 100 seconds (every second refresh data in real time, the frequency can be changed) for a total refresh 5.
6. memcache principle
7. when a site access slow, how do you optimize ###
Translation: when a site access slow, how do you go to find the problem, and in order to optimize the effectiveness of problem-solving
First, the use of 5 minutes to troubleshoot network, by means of tools (pagespeed) analysis on page load
1. an element or a picture to load too slowly: reasons analysis
2. when DNS resolution problem: through resolution services, to get your own domain name in DNS more cache
3. network bandwidth bottleneck: consider increasing bandwidth
4. network line wave: consideration of CDN, or mirror
Second, taking into account the server problem
1. is there a server overload: consider adding hardware
2. I/O operations: database of frequent reads and writes, frequently requested of the server (including static files read, pictures read) are of the I/O problem. For database issues, first optimizing SQL, stored procedures, and so on. If a single table data is generally considered to be separated or use a program to control the table. If the request is too large, consider clusters. For server (static) file I/O problem, you might consider a CDN, which would solve the regional problems. For dynamic file access involves code optimization and load balance the two.
3. application specific optimization: nginx for visits to modify configuration files, increase the Buffers reduce the keep alive connection time
Third, security
1. view web\mail other services such as logging, if there is attacked: for security reinforcement
2. are there any other attack DDOS,WEB CC
8. the MySQL master never sync how to solve
-
On the master side execution:
123mysql> flush logs;mysql> show master status;PS:记下File、Position的值。 -
On the slave side execution:
1234mysql> stop slave;mysql> CHANGE MASTER TO MASTER_LOG_FILE='bin-log.000002',MASTER_LOG_POS=107;mysql> start slave;mysql> show slave status
SQL command to manually sync, another method is to skip the things that caused the error
-
Skips a specified number of transactions:
123mysql>slave stop;mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1 #Skip a transactionmysql>slave start -
Modify the MySQL configuration file, through the slave_skip_errors parameter to all or specific types of errors
1234vi /etc/my.cnf[mysqld]slave-skip-errors=1062,1053,1146 # Skip specified types of error no errorslave-skip-errors=all #<span id="ouHighlight__1_1TO0_3" class="">Skip</span><span id="noHighlight_0.27845883020199835"> </span><span id="ouHighlight__2_3TO5_7" class="">all</span><span id="noHighlight_0.6231269435957074"> </span><span id="ouHighlight__4_5TO9_14" class="">errors</span>
9. the difference between process and thread
Translation: the concept of process and thread
- Process (English: process), is already on the computer running the program entities. Process is the program’s basic operational entities, the process itself is not a basic unit, but the thread container
- Threads (English: thread) is the smallest unit of operating systems that can perform operations scheduling. It was included in the process, is in the process of actual operation of the unit. A thread is a single sequential flow of control in a process, a process that can be complicated by multiple threads, and each thread-parallel execution of different tasks.
① process is the basic unit of the system for resource allocation, with separate memory address space; a thread is the basic unit of CPU scheduling, does not have a separate address space, with separate stacks, and local variables, registers, such as the program counter.
Second, the cost of creating a process, including the creation of virtual address space and system resources; create a thread low cost, basically a kernel object and a stack.
③ a process cannot directly access the resources of another; multiple threads within the same process share the resources of the process.
④ process switching costs, thread switching overhead is small; interprocess communication overhead, inter-thread communication overhead.
⑤ threads belonging to a process, not independently. Each process has at least one thread, thread
10. the principle of common RAID
RAID 0 in bits or bytes in a row partitioned data, read/write to multiple disks in parallel, it has a very high data transfer rates, but it has no data redundancy, and therefore not a true RAID structure. RAID 0 is simply to improve performance and provide no guarantee for the reliability of the data, and a disk failure will affect all data. Thus, RAID 0 does not apply to situations which require high data security.
RAID 1 data redundancy through disk data mirroring, in pairs of independent mutual backup data on disk. When the original data is busy and can be read directly from the mirrored copy of data, RAID 1 can improve read performance. RAID 1 disk arrays in the highest unit costs, but provide a high degree of data security and availability. When a disk fails, the system can automatically switch to the mirror disk read/write failure data without the need to restructure. Simply put: mirror-like structures, similar to the backup mode, a data is duplicated on both drives.
RAID 10 with high reliability and high performance disk structure with a structure and a mirror-like structure, because both have their advantages and disadvantages, so you can complement each other. Mainly used for limited capacity, but in a database that requires speed and error control.
RAID 5- distributed parity structure of independent disks, parity-check codes exist on all disks, any damage to the hard disk, can be based on other parity bit to restore corrupted data on your hard disk. Dropped support a still functioning properly.
11. did you do any performance tuning
This is a big subject, to ask ourselves is application tuning or tuning system no tuning, tuning steps:
1. identify system performance bottlenecks (including hardware and software bottleneck);
2. optimization options within *** (upgrade your hardware? Improved system architecture? );
3. the reasonable configuration of hardware and software;
4. the maximum balance system resource usage.
12. the process of requesting a Web site
Domain name–> after the TCP 3-way handshake of TCP connections–>–> server responds to http requests initiated HTTP requests, the browser get HTML code–> browsers parse HTML code and request resources in HTML code (such as js, CSS, images, etc)–> the browser to render the page presented to the user
13. LVS/Dr scheduling process
Client requests to the LVS ==> LVS accept requests according to the scheduling algorithm selected servers in the background ==> LVS modifies the packet destination MAC address to the server ==> server directly after processing the request back to the client
14. I access WEB log you want to view what are the TOP 10 IP view
Then the interviewer let me speak out specific orders, or see what I know some text commands. it is not difficult to:
cat logfile | cut -d ' ' -f 5 | sort | uniq -c | sort -nr | head -n 10 | less |
Cut command responsible for bringing text separated by a space, take the fifth column of data ==>
Sort ==> to heavy and statistics times (-c parameter is statistics parameter) ==> again sort (statistics times will was wrote in IP zhiqian, so here is by statistics times sort sort of-r is reverse is from big to small,-n for by digital sort main is sort default sort is may will put 10 judge for than 2 also small, through-n on not appeared this situation) ==> take times up of 10 article ==> less dispensable
15. the main principles of CDN
CDN is a combination of technologies, mainly consists of the following 3 ways:
① source station
Source refers to the publication of the original site. Add, delete, and change the site’s files, are performed at the source of other cache server crawls all objects from the source.
② cache server
Cache server is provided directly to the user access to the site resource, is made up of one or several servers when users access, intelligent DNS go to his access request was left him closer to the cache server. If the user requests the content just inside the cache and return the content directly to the user if access to the content is not cached, the cache server to a nearby cache server or directly to the source to crawl content, and then returned to the user.
③ Intelligent DNS
Intelligent DNS is the core of CDN technology, which according to the source, its access request to cache server from the user, such as user requests pointing to Guangzhou Guangzhou Telecom Telecom IDC machine room with caching servers. Through the intelligent DNS resolution, allowing users to access the same service provider under Server, eliminating internal North-South problem of slow network access, to accelerate. The emergence of intelligent DNS, upsetting the traditional practice of a domain name corresponding to a mirror, makes users more convenient to access the Web site.
Cache server has access to content:
==> smart client requests DNS resolution to the nearest cache server ==> cache servers return the requested resource
Cache server has no access to content:
==> smart client requests DNS resolution to the nearest cache server ==> cache server found no client requests a resource, source ==> source return the requested resource to the cache servers ==> cache returns client requested resources
16. cross-server synchronization files
Original problem is when the interviewer is that “all pictures in a folder (different types JPG|PNG) synchronized to another server”, I do not … Only hold the find command under vague said.
Back to review the next, is actually two things, one is how to find the files, one is how to get synced to another server:
How to find:
1. the ls command + grep command
ls /tmp/test | grep ".*\.jpg\|.*\.png" |
The most simple and easy to understand, but ls is not a find command, so this command just to see which files in the/tmp/test folder, and not under the/tmp/test subdirectory to the search.
2. find the command
find /tmp/test - type f -regex '.*\.jpg\|.*\.png' |
Most commonly used find command, you can specify regular \ \ \ \ file type file size file permissions file owner belongs to group \ files matching to find time on the file.
There are locate\whereis alternative commands, can be used, as long as you can navigate to the file you can, for example, there is no one.
How to sync:
Will look through the pipeline to the responsible for the synchronization commands
-
XARGS + SCP command
ls
/tmp/test
|
grep
".*\.jpg\|.*\.png"
|
xargs
-n1 -I {}
scp
{} root@192.168.1.97:
/tmp
find
/tmp/test
-
type
f -regex
'.*\.jpg\|.*\.png'
|
xargs
-n1 -I {}
scp
{} root@192.168.1.97:
/tmp
Using xargs receive standard input and execute remote copy command.
-
Find command + SCP command
find
/tmp/test
-
type
f -regex
'.*\.jpg\|.*\.png'
-
exec
scp
{} root@192.168.1.97:
/tmp
\;
Can also be combined with xargs command completion
find
/tmp/test
-
type
f -regex
'.*\.jpg\|.*\.png'
|
xargs
-n1 -I {}
scp
{} root@192.168.1.97:
/tmp
These two effects, the implementation process is to build each child process document SCP. pit is that SCP file you want to use, no secret-key authentication to a remote host, then each file to a password …
-
Ordinary rsync rsync synchronization synchronization:
find
/tmp/test
-
type
f -regex
'.*\.jpg\|.*\.png'
|
xargs
-n1 -I {}
rsync
{} root@192.168.1.97:
/tmp
Upload rsync synchronization server (remote host is set up rsync server is required):
find
/tmp
-
type
f -regex
'.*\.jpg\|.*\.png'
|
xargs
-n1 -I {}
rsync
-avzP {} wys@192.168.1.98::wys
Above two and SCP, it needs one password authentication, and rsync–password-file specify a password file (note that the password file permissions must be 600, otherwise it will complain) to wear our authentication password like this:
find
/tmp
-
type
f -regex
'.*\.jpg\|.*\.png'
|
xargs
-n1 -I {}
rsync
-avzP {} --password-
file
=
/tmp/wys
.password wys@192.168.1.98::wys
Synchronized command or service there, but not very much like this temporary use I think up rsync is enough.
Related knowledge:
Rsync server built: reference | References II
Rsync command: with reference to a
Find command: with reference to a
XARGS command: with reference to a note that there is an error in this inside-I parameter example replace string is less, it should be:
...-I {} CMD {} XXX... |
17. MySQL added to check basic problems (written based)
-
Increase
12NSERT INTO table name VALUES (value 1, value 2, ...); # by order of the columns in turn assigns the value of the object corresponding to the columnsINSERT INTO table name (column 1, column 2) VALUES (value 1, value 2); # corresponding column into the corresponding value -
By deleting
12DELETE FROM table name WHERE column operator value; # Example: DELETE FROM tab WHERE name = job; job matching to the name column is a record, delete itDELETE * FROM table name; # Empty Table -
Modified
1UPDATE table name SET column name = new value WHERE column = value; for example: UPDATE tab SET name = eason WHERE id = 3; match the id column value record 3, modify the recording name value eason -
Check
123456SELECT column name 1, column name 2 ... FROM table name; # specified column of the querySELECT * FROM table name; # lookup table for all contentSELECT column names FROM table name WHERE column operator value; # Example: SELECT name FROM tab WHERE id <10; matched to the id column is less than the record tab 10 to view these records the name column valueSELECT DISTINCT FROM table name Column name; # delete duplicate items returned resultsSELECT * FROM table name ORDER BY column names; # according to a column to sort (ascending order)SELECT * FROM table name ORDER BY column name DESC; # sorted according to a column (descending)
18. the server after changing motherboard Linux does not recognize the network adapter
System loaded NIC drive Hou will to read a file, this file is a cache file, contains has NIC of MAC address, because replaced has Board, NIC of Mac also changes has, but this file of Mac also is no variable, so existing of NIC MAC address and file in of different, so system on refused to started, put this file delete Hou heavy Kai system on can has operation for Xia:
1 2 |
> #mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.bak > #reboot # will generate a new cache files after restart |
Leave a Reply