Linux system Operations Common interview Brief Answer (a) (15 questions)

Source: Internet
Author: User
Tags stop script apache access log rsync pkill

1. Please describe the boot process of Linux system
Power-on BIOS self-test ——— –>mbr boot ——— –>grub boot menu ——— –> load kernel ——— –> start init process ——— –> read Inittab file ——— –> start Mingetty process ——— > Login System

2, authoritative DNS and recursive DNS meaning, the implementation of the principle of intelligent DNS
Authoritative DNS is a DNS server that is authorized to parse the domain name at a previous level, and it can delegate the resolution authorization to other servers;

Recursive DNS is responsible for accepting the user's query on any domain name and returning the result to the user, which can cache the result to avoid the user to query upward;

Intelligent DNS is the user-initiated query to determine which carrier's user query, and then forward the request to the appropriate operator IP processing, reduce cross-operation access time, improve access speed.

3, through the Apache Access log access.log statistics IP and the number of visits per address, list the top 10 IP addresses, write specific commands
awk ' {print '} ' Access.log|uniq-c|sort-rn |head-10

4, write script implementation will/usr/local/test directory larger than 100K file, copy it to/tmp directory

123456789
#!/bin/bashfor file in ' ls/usr/local/test ' doif [-f $file];then    if [' ls-l $file ' |awk ' {print $} '-gt 10000];then< C2/>MV $file/tmp/    fifidone

5, forwarding the local 80 port request to the 8080 port, the native address 10.0.0.254, write the command
Iptables-t nat-a pretouting-d 10.0.0.254-p tcp–dprot 80-j dnat–to-destination 10.0.0.254:8080

6, how to realize the node access log of Nginx agent is the real guest's IP, not the proxy IP
Configure the Nginx.conf configuration file to add the same markup content

12345678
server{                   Listen;                   server_name blog.text.com;                   Location/{                   Proxy_pass http://test_servers;                   Proxy_set_header Host $host;                   Proxy_set_headerx-forwarded-for $remote _addr;            }

After the modification is complete, reload the Nginx:/application/nginx/sbin/nginx-s Reload

7, MYSQL one master more from, the main library down, how to reasonably switch to from the library, the other from the library how to deal with?
1) Log in all from the library to view post information, use post the largest as the new main library, and then from the upgrade to the new main library, login from the library (the new main library) to execute the stop slave,
2) Modify the MY.CNF configuration file, open the Log-bin and restart the database service, log on to the database to perform Restet master, show Master Status\g, view the main library information, and finally create an authorized synchronization user with permissions and site use database users and permissions, Synchronization of all the machine's/etc/hosts file (at this point is reflected before the whole network with the domain name is not the role of IP, or you have to modify the site program to switch to the new main library server IP, otherwise unable to connect to the database);
3) log in to other slave libraries, perform the change master operation, and view the synchronization status.

8, Error Operation drop statement causes database data corruption, please give the actual general steps of recovery
All data recovery is based on the backup, must have a full backup, otherwise recovery is not discussed, the error caused by the database corruption requires the use of incremental recovery method to recover the database, the following steps:

1) View backup and Binlog files

2) Refresh and back up the Binlog file
Mysqladmin-uroot-pmysql123-s/data/mysql.sockflush-logs

3) Restore the Binlog file to an SQL statement
Mysqlbinlog–no-defaults mysql-bin.000061 mysql-bin.000062 >bin.sql

4) Delete the statement in which it was mistakenly manipulated (that is, the drop action)

5) Extract the full file, restore the full file
Gzip-d mysql_backup_2016-10-12.sql.gz
Mysql-uroot-pmysql123-s/data/3306/mysql.sock < Mysql_backup_2016-10-12.sql
If you have operations on a table, you need to pick up the table name when recovering data

6) Restore the SQL statement of the Binlog file record before the mis-operation
Mysql-uroot-pmysql123-s/data/3306/mysql.sock < Bin.sql
Finally log in to the database, to see if the data is successful, if there is a definite error operation time, the data can be directly restored to this period of time.

9, to enumerate an example of the actual production, Web site access speed is due to the slow database access caused by

Problem situation Description:
Suddenly one day, a colleague response, the site is very slow access, and sometimes can not open the site, the refresh wait for a long time after the normal open.

Steps to resolve:
Login database execution Show full processlist see a lot of the same query action and the same table, so make sure the site is not open because of this, so the IP is forbidden to access. Avoid such problems in daily work the solution is as follows: The database can be read and written separated; Install the data cache server, try to make most of the requests do not directly docking the database.

10, a shell script can be executed manually, put into a scheduled task can not be executed, possible reasons?
Can be executed manually, indicating that the script itself does not have a logical problem, possibly due to the following points
1) The timing task is written with errors, the executed script does not write the absolute path, cannot find the script
2) environment variable problem caused.

11. Using Shell to develop rsync service start, stop script, and through the chkconfig Switch machine management

 123456789101112131415161718192021222324252627282930313233343536 
[[email protected] download]# vi rsstart.sh#!/bin/sh# #create by Mingongge at 2017-01-10. /etc/init.d/functionscase "$" instart) rsync--daemon if [$?-eq 0];then Action "rsync is started"/bi N/true Else Action "rsync is started"/bin/false fi; Stop) Pkill rsync sleep 2 If [' Ps-ef|grep rsync|grep-v grep |wc-l '-eq 0];then action "Rsync is S Toped "/bin/true Else Action" rsync is stoped "/bin/false fi;;       Restart) Pkill rsync sleep 2 If [' Ps-ef|grep rsync|grep-v grep |wc-l '-eq 0];then rsync--daemon If [$?-eq 0];then Action "rsync is restarted"/bin/true fi fi; *) echo "USAGE: {start|stop|restart}";; Esac 

"rsstart.sh" [New] 36L, 731C written
[[email protected] download]# chmod +x rsstart.sh
[[email  Protected] download]# sh rsstart.sh
USAGE: {start|stop|restart}
[[email protected] download]# sh rsstart.sh start
Rsync is started [OK]
[[email protected] download]# ps-ef|grep rsync
Root 1088 1 0 Jan09 ? 00:00:00 Rsync–daemon
Root 3527 2869 0 03:54 pts/0 00:00:00 grep rsync
[[email protected] download]# sh RSstar t.sh Stop
Rsync is stoped [OK]
[[email protected] download]# ps-ef|grep rsync
Root 3540 2869 0 03:54 pts/ 0 00:00:00 grep rsync
[[email protected] download]# sh rsstart.sh start
rsync is started [OK]
[[email  ;p rotected] download]# sh rsstart.sh Restart
rsync is restarted [OK]
[[email protected] download]# Ps-ef|gre P rsync
Root 3558 1 0 03:54? 00:00:00 rsync–daemon
Root 3564 2869 0 03:55 pts/0 00:00:00 grep rsync

Configuring the Switch Machine management
Then add the following to the front of the script:
# chkconfig:2345 21 99
# Description:chkconfig Rsync Service
Specific to their own test, there is also the possibility of this startup, close the serial number has a conflict, need to modify.

12, please describe the OSI7 layer model each layer name and function, and for example in different layers of the corresponding protocol
The first layer: the physical layer, using the transport medium to provide the physical connection to the data, the corresponding protocol: ARP
Second layer: Data Link layer: Establish and manage the protocol for link links between nodes: PPTP, CDP
The third layer: The network layer, is to control the data link layer and the upper transport layer between the information forwarding, establishing and maintaining the corresponding protocol: IP, routing protocol
Layer Fourth: The Transport layer, which provides the session transfer service to ensure that the data is correctly transmitted by the corresponding protocol: TCP UDP
Layer Fifth: Session layer, provide session management, support data exchange
Layer Sixth: Presentation layer, processing data (data format, encoding, encryption, etc.), transmitted to the session layer in a certain format
Layer Seventh: Application layer, to provide users with various types of application services (file, print, mail and other services) correspondence protocol: HTTP, FTP, SMTP, POP3

13, Linux system environment How to see how long the system has been running?

Execute system command uptime, where the third field, such as 2:32 below, indicates how long the system has been running since the last start.
[[email protected] DOWNLOAD] #uptime
02:05:22 up 2:32, 2 users, Load average:0.00, 0.00, 0.00

14. How to add route in Linux system

Host routing
Route add-host 192.168.197.100 Dev eth0
Gateway Routing
Route add default GW 192.168.197.1
Network routing
Route ad-net 192.168.1.0 netmask 255.255.255.0 deveth1
Route ad-net 192.168.1.0 netmask 255.255.255.0 gw192.168.197.1

15. The contents of the known Test.txt file are as follows, please take out 5-15 lines of the file
[email protected] ~]# cat Test.txt
1
2
3
4
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb
16
17nnnnnn

method One: [Email protected] ~]# grep 15bbbbbb-b test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb

Method Two: [Email protected] ~]# sed-n ' 5,15p ' test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb

Method Three: [Email protected]~]# awk ' {if (NR4) print '} ' test.txt
5bbb
6xxxxxxxxxxx
7123i4i44
8
9
10
11
12
13ffffff
14fffff
15bbbbbb

Linux system Operations Common interview Brief Answer (a) (15 questions)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.