Question preparation for the failure of the operation and maintenance interview

Questions are collected online, without basic shell operations and database operations

1. TCP/IP three-way handshake, four-way handshake process
TCP/IP
briefly describes the TCP three-way handshake process?
Answer: In the TCP/IP protocol, the TCP protocol provides a reliable connection service, and a three-way handshake is used to establish a connection. The first handshake: When establishing a connection, the client sends a syn packet (syn=j) to the server, and enters the SYN_SEND state, waiting for the server to confirm. The second handshake: the server receives the syn packet, it must confirm the client's SYN (ack=j+1), and at the same time it sends a SYN packet (syn=k), that is, the SYN+ACK packet, and the server enters the SYN_RECV state. The third handshake: The client receives the SYN+ACK packet from the server, and sends an acknowledgment packet ACK (ack=k+1) to the server. After the packet is sent, the client and server enter the ESTABLISHED state and complete the three-way handshake. After the three-way handshake is completed, the client and the server start to transmit a simplified version of the data: first, A sends a SYN (synchronization request) to B, then B replies with SYN+ACK (synchronization request response), and finally A replies with an ACK confirmation, so that a TCP connection (three times) The process of handshake) is established.

Why is there a three-way handshake when connecting, but a four-way handshake when closing?
This is because when the Server side receives the SYN connection request message from the Client side, it can directly send a SYN+ACK message. The ACK message is used for reply, and the SYN message is used for synchronization.
But when the connection is closed, when the client sends a FIN message, it only means that it no longer sends data but can still receive data. When the server receives the FIN message, it may not close the SOCKET immediately, so it can only reply one first. ACK message, tell the client, "I received the FIN message you sent." Only after all the messages on my Server side have been sent, I can send FIN messages, so I cannot send them together. Therefore, a four-step handshake is required.

2. MySQL master-slave replication
The principle of master-slave replication is as follows: the
master library opens the binlog function and authorizes the slave library to connect to the master library. The slave library obtains the relevant synchronization information of the master library through the change master, and then connects to the main library for verification. The main library IO thread According to the request of the slave thread from the library, start to fetch information from the position recorded by master.info, and send the fetched position and the latest position together with the binlog information to the IO thread of the slave, and the slave will send the relevant information The sql statement is stored in the relay-log. Finally, the sql thread of the slave library applies the sql statement in the relay-log to the slave library. At this point, the entire synchronization process is completed, and the above process will be repeated indefinitely.

The complete steps are as follows:
1. The main library turns on the binlog function and performs full backups, and pushes the full backup files to the slave library server.
2. show master status\G records the current location information and the binary file name.
3. Logs in and restores from the library. Complete file
4. Execute change master to statement
5. Execute start slave and show slave status\G

3. The solution to the slow back-end interface call.
Ask the respondent which service application or page call is slow, and ask him to send the page or related URL to you. First of all, the most intuitive analysis is to use a browser Press F12 to see which piece of content is too slow (DNS resolution, network loading, big picture, or the content of a certain file, etc.), if there is, then prescribe the right medicine to solve it (optimize the picture if the picture is slow, and check the intranet if the network is slow Situation, etc.). Secondly, look at the log of the back-end service. In fact, most of the problems are related to the log for the most effective analysis. It is best to use tail -f to track the log. Of course, you have to click test to access the interface log before it will be output. Finally, exclude sql, find sql and go to mysql to execute it, and see if it takes a long time. If it takes a long time, you need to optimize the SQL problem. Expain SQL to see the index situation and optimize it. If the amount of data is too large, the table can be divided into tables, and the database can be divided into databases. If there is nothing wrong with SQL, it may be a problem with the written logic code. Review the code line by line, find time-consuming changes, and optimize the logic.

4. DNS resolution process
1. Enter the www.qq.com domain name in the browser, the operating system will first check whether its local hosts file has this URL mapping relationship, if so, first call the IP address mapping to complete the domain name resolution .
2. If there is no mapping of this domain name in the hosts, search the local DNS resolver cache to see if there is this URL mapping relationship. If so, return directly to complete the domain name resolution.
3. If the hosts and the local DNS resolver cache do not have a corresponding URL mapping relationship, first the preferred DNS server set in the TCP/IP parameters will be found. Here we call it the local DNS server. When this server receives a query, if you want The queried domain name is included in the local configuration zone resource, and the resolution result is returned to the client to complete the domain name resolution. This resolution is authoritative.
4. If the domain name to be queried is not regionally resolved by the local DNS server, but the server has cached the URL mapping relationship, then the IP address mapping is called to complete the domain name resolution. This resolution is not authoritative.
5. If both the local zone file and cache resolution of the local DNS server are invalid, the query will be performed according to the settings of the local DNS server (whether a forwarder is set). If the forwarding mode is not used, the local DNS will send the request to 13 root DNSs. After receiving the request, the DNS server will determine who is authorized to manage this domain name (.com), and will return an IP responsible for the top-level domain name server. After the local DNS server receives the IP information, it will contact the server responsible for the .com domain. After the server responsible for the .com domain receives the request, if it cannot resolve it by itself, it will find a next-level DNS server address (qq.com) that manages the .com domain to the local DNS server. When the local DNS server receives this address, it will find the qq.com domain server, repeat the above actions, and query until it finds the www.qq.com host.
6. If the forwarding mode is used, the DNS server will forward the request to the upper-level DNS server, and the upper-level server will resolve it. If the upper-level server can’t resolve it, find the root DNS or forward the forwarding request to the upper-level , This cycle. Regardless of whether the local DNS server is used for forwarding or root prompting, the final result is returned to the local DNS server, and the DNS server then returns to the client.

The query from the client to the local DNS server is a recursive query, and the interactive query between the DNS servers is iterative query.

5. Commonly used high-availability technology
Keepalived: Keepalived is a service software that guarantees the high availability of the cluster. It is used to prevent single points of failure and is implemented using the VRRP protocol. When the master actively reduces its weight between the master and the backup or the backup detects that the master fails, the backup will take over the work of the master and continue to serve.
HAproxy: HAProxy provides high availability, load balancing, and proxy based on TCP and HTTP applications, and supports virtual hosts. It is a free, fast and reliable solution. HAProxy is especially suitable for web sites with heavy loads, which usually require session retention or seven-layer processing. HAProxy runs on current hardware and can fully support tens of thousands of concurrent connections. And its operating mode makes it easy and safe to integrate into your current architecture, while protecting your web server from being exposed to the network.
Heartbeat+ DRBD:
The working principle of heartbeat (Linux-HA): The core of heartbeat consists of two parts, the heartbeat monitoring part and the resource takeover part. The heartbeat monitoring can be carried out through the network link and the serial port, and it supports redundant links. Send messages to each other to tell the other party about their current status. If the message sent by the other party is not received within the specified time, then the other party is considered to be invalid. At this time, the resource takeover module needs to be activated to take over the resources running on the other party's host. Or service.
Distributed Replicated Block Device (DRBD) is a software-implemented, non-sharing, storage replication solution that mirrors the contents of block devices between servers.
Data mirroring: real-time, transparent, synchronous (return after all servers are successful), asynchronous (return after the local server succeeds)

6. Occupied process
View the current system status: top to
view thetop5 processes occupying the largest memory: top, and then press the M (uppercase) key. Method 2: ps -aux | sort -k4nr | head -5

7. Boot sequence of Linux system, query program run level and modify run level
POST power-on self-test-"MBR boot-"GRUB-"load kernel -" start init process -" read /etc/inittab file, /etc /init/*.conf file-"Use /etc/rc.d/rc.sysinit initialization script-"Execute /etc/rc.d/rc script (load all scripts under /etc/rc3.d/)-"Execute /etc/rc.d/rc.local-"Execute /bin/login login program
query program run level: runlevel
modify run level: init [0123456]

8. The difference between soft link and hard link.
A soft link refers to the creation of a new file. The block stores the file name of the linked file. The inode of the soft link is different from the inode of the source file. Delete the source file and then rebuild. If the inode is changed, the soft link file remains effective.
A hard link is to create a new file name and point its inode to the inode of the source file, so the inode of the hard link is the same as the source file. After the source file is deleted, the hard link is still valid.

9. Host A needs to transmit a 100G data to Host B. What transmission optimizations can be done?
Data packing and compression
Data fragmentation, synchronous transmission
Increase transmission bandwidth, network port aggregation

10. Mount the 192.168.16.3 Windows server folder to the Linux local /mnt/server directory, the Windows account is: administrator, and the password is: 123456
1. First, share the directory server that needs to be mounted under windows.
2. Make sure that linux and windows are in the same local area network.
3. Create a directory /mnt/server that needs to be mounted under linux.
4. Use the mount command to mount.
Mount command: mount -t cifs -o username=administrator,password=123456//192.168.16.3/server /mnt/server

11. How does mysql's innodb locate the lock problem, how does mysql reduce the master-slave replication delay
, how does mysql's innodb locate the lock problem:
When using show engine innodb status to check the engine status, a deadlock problem
wasfound.In 5.5, the information_schema library was added Three tables about locks (MEMORY engine)
innodb_trx ## All currently running transactions
innodb_locks ## The current locks
innodb_lock_waits ## Correspondence between lock waiting

How does mysql reduce the delay of master-slave replication:
If the delay is relatively large, first confirm the following factors:

  1. The hardware of the slave library is worse than that of the master library, causing replication delays
  2. The master-slave replication is single-threaded, and if the master library writes too much concurrency to transfer to the slave library, it will cause delay. Higher versions of mysql can support multi-threaded replication
  3. Too many slow SQL statements
  4. Network delay
  5. master load. The main library reads and writes under high pressure, causing replication delays, and the front end of the architecture needs to add buffer and caching layers
  6. slave load. The general approach is to use multiple slaves to share read requests, and then take a dedicated server from these slaves

MySQL database master-slave synchronization delay solution
The simplest solution to reduce the slave synchronization delay is to optimize the architecture, try to make the DDL of the main library execute quickly.
Also, the main library is written, which has higher data security, such as sync_binlog =1, innodb_flush_log_at_trx_commit
= 1, and the slave does not need such a high data security, it can be said that sync_binlog is set to 0 or binlog
innodb_flushlog can also be set to 0 to improve the execution efficiency of sql. The other is to use a better hardware device than the main library as a slave

12. How to reset mysql root password?
1. In the SHELL environment, use the mysqladmin command to set:
mysqladmin -u root -p password "new password" After pressing enter, the old password is required

2. In the mysql> environment, use the update command to directly update the data in the user table of the mysql library:
Update mysql.user set password=password('new password') where user='root';
flush privileges;

3. In the mysql> environment, use the grant command to modify the authorization permissions of the root user.
grant all on . to root@'localhost' identified by'new password';

13. mysql data backup tool
mysqldump tool
mysqldump is a backup tool that comes with mysql, the directory is under the bin directory: /usr/local/mysql/bin/mysqldump
supports hot backup based on innodb, but because it is a logical backup, the speed is not very high Fast, suitable for scenarios
where thebackup data is relatively small.Mysqldump full backup + binary log can realize point-in-time recovery.

Backup based on LVM snapshots
In physical backup, there are physical backups based on the file system (LVM snapshots), or you can directly use commands such as tar
to package and backup the entire database directory , but these can only be used for backup, different storage The engine backup is also different. Myisam automatically backs up to the table level
. Innodb can only back up the entire database without opening an independent table space.


The xtrabackup tool provided by tar package backup percona
supports physical hot backup of innodb, supports full backup, incremental backup, and is very fast, supports data
migration caused by innodb storage between different databases, and supports slave backup recovery in replication mode Backup and recovery, in order to allow xtrabackup to support more functional extensions
, independent tablespaces can be set up, innodb_file_per_table function can be turned on, and separate table backups can be supported after enabling

Guess you like

Origin blog.csdn.net/vivian233/article/details/110917323