Linux Operation and Maintenance (2) (14 questions)

If the content is not correct, please give correction, thank you!

1. The kernel/var/log/messages log: nf_conntrack: tablefull, dropping packet, could you tell me what causes, how to solve?

Iptables indicates that the connection tracing table is full and packet loss is beginning. The possible cause is frequent connection, closure, or TCP connection. 1) Increase the size of the trace table 2) disable some unnecessary connection states 3) disable the module IP_vs NF_Conntect

2. The php-fpm process is high in Nginx and Php on Linux. Please tell us the possible cause and how to solve the problem.

1) PHP plug-ins are incompatible with the existing PHP version, the solution is to prohibit related plug-ins from php.ini. 2) The software itself has a problem, which needs to be handled together with development and operation and maintenance to find the cause. 3) PHP programs have an infinite loop and the server load is too high

3. Error: nospace left on device, but df-h is not used up.

The reason: The system inode is full because all file name information is stored in the inode. [root@mysql-1 download]# df -i Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 1234576 138303 1096273 12% / tmpfs 60785 1 60784 1% /dev/shm /dev/sda1 51200 38 51162 1% /boot

4. The disk space is full. After some nginx logs are deleted, the disk space is still full.

Some deleted logs may still be called by processes, so you need to restart the nginx service to release the processes. Or in the actual production environment, use >/log/access.log to clear files

5. How do I view the number of Apache processes

Perfork mode: ps – ef | | grep HTTP grep -v grep | wc -l

Worker mode: pstree – a | grep HTTPD | wc -l

6. Select ‘FAILD’ and ‘SUCCESSFUL’ from ‘test.log’. Extract the third column [] root @ mysql – 1 # cat test. The log FAILD: SUCCESSFUL: DONE: CRITICAL FAILD: SUCCESSFUL: NO: GOOD FAILD: NO: DO: QINGYUN SUCCESSFUL:DONE:CRITICAL::CRITICAL

Method one: [] root @ mysql – 1 # egrep “FAILD | SUCCESSFUL” test. The log | grep -v DONE | awk – F ‘:’ ‘{print $3}’ NO DO

Method 2: [] root @ mysql – 1 # egrep “FAILD | SUCCESSFUL” test. The log | grep -v DONE | : cut – d – f3 NO DO

7. There are nearly 254 servers in the computer room of the company. Please design a solution on how to divide network segments and realize smooth service migration.

Solution 1: Use a longer subnet mask to expand the available IP address range and distribute the /etc/hosts file across the network. Solution 2: Add core switches, divide vlans on core switches, add the new servers to new vlans, and distribute the /etc/hosts file across the network

8. How does Nginx reverse proxy realize different virtual hosts on the proxy RS node? Please tell the principle and configuration method or idea.

The client sends a request to the reverse proxy. The reverse proxy forwards the request to the target server according to certain rules and returns the returned content to the client, which can be classified into the following two types:

Upstream {server 192.168.1.10:80 weight=5; Server 192.168.1.11:80 weight = 5; } upstream {server 192.168.1.20:80 weight=5; Server 192.168.1.21:80 weight = 5; } configure server server{listern 80; server_name app.abc.com }

Configure matching forwarding rules: location /app1/ {proxy_pass http://example.com/app1; proxy_set_header Host $host; } location/app2/ { proxy_passhttp://example.com/app2; proxy_set_header Host $host; Upstream test_servers {server 192.168.1.2:80 weight=5; Server 192.168.1.4:80 weight = 5; Server 192.168.1.6:82 weight = 15; } Then configure the server label, server {listen 80; server_name www.abc.com; proxy_pass http://test_servers; Proxy_set_header Host $Host} After the configuration, reload the nginx service

[root@ ~]# netstat -an Active Internet connections (Servers andestablished) Proto Recv -q Send -q Local Address Foreign Address State TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN TCP 0 0 139.24.65.45:54296 10.11.68.13:80 ESTABLISHED TCP 0 52 39.24.65.145:22 36.32.8.85:546 ESTABLISHED TCP 0 0 139.24.165.45:586 10.11.8.13:80 CLOSE_WAIT

Established Indicates that the two ends of the listen service can communicate normally. Close_wait The other party actively closes the connection or the network is interrupted due to an exception. Therefore, the state changes to time_wait actively disconnects the connection. Syn_sent Indicates the status of a connection request. It is the first synchronization signal sent when you need to access another machine

10. What is a binlog? What does a binlog record? There are several modes and their advantages and disadvantages. Which mode do enterprises choose to synchronize?

Binlog: An operation statement used to record all updated data. The statement is stored as an event and describes the change process of data

Binlog view mysqlbinlog/home/mysql/binlog binlog. 000003

Binary logs can be automatically deleted or manually deleted. Automatic deletion can use the binlog parameter expire_logs_days to implement the show binary logs. Show variables like “expire_logs_days;” set gloable expire_logs_days=3; Manually delete reset master Delete the master binlog reset slave Delete the slave trunk log

The three modes are as follows: Row level: The log records the modified form of each Row of data and then modifies the same data on the secondary end. Advantages: The log does not record the information related to the CONTEXT in which the SQL statement is executed, but only the modified data and the modified data. Disadvantages: All statements executed are recorded in a log file and are recorded as changes per line, resulting in a large amount of log content

In statement mode, each SQL statement that is modified is recorded in the master’s bin-log. During replication, the SLAVE SQL process parses the same SQL statement that was executed by the master. This solution solves the disadvantage of the upper row level mode, which does not need to record the changes of each row data and reduces the amount of logging. The disadvantage is that the master and slave cannot be copied in this mode because the execution statement is recorded

Mixed automatic mode: MYSQL uses different log formats for each particular SQL statement executed. Statement mode is the default mode if special mysql functions are not required. Row Level mode is the default mode if special mysql functions are required

11. Describe the HTTP protocol in detail

The HTTP protocol is based on THE TCP/IP protocol. The principle of the PROTOCOL consists of four processes: Connection: The browser establishes a connection with the server, and the virtual file of a socket is opened to indicate that the connection is established successfully. The browser submits a request (usually a GET or POST command) to the server through the socket. The browser sends the request to the server through HTTP. The server processes the request and sends the result back to the client through HTTP. When the answer ends, the connection between the browser and the server is disconnected

12. Please describe the primary/secondary replication principle of MySQL in detail

Principle: The master library enables the binlog function and authorizes the user permission to connect the slave library to the master library for synchronization. The modification or change of the database generates bin-log logs. The slave library obtains the relevant information of the master library through the statement of change mster. The IO thread of the master library will send the relevant location information and the latest BLNlog information to the IO thread of the slave library according to the request of the slave library. The IO thread of the slave library will put the SQL statement information in relay log. Finally, the SQL thread of the slave library will apply the SQL statement in relay log to the slave library. Synchronize data between the master and slave libraries, and then repeat the above action over and over again

13. Shut down all services except SSHD, Crond, Network and rsyslog with a single command (automatic startup is not required)

Method one: [root @ centos6 ~] # for the name in ` chkconfig — list | grep 3: on | awk ‘{print $1}’ | grep – Ev “SSHD | crond | rsyslog | network” `; dochkconfig $name off; Done/root @ centos6 ~ # the chkconfig — list | grep 3: on the crond 0: off 1:2: off on 3: on 4: on 5: on 6: off network 0: off 1:2: off on 3:on 4:on 5:on 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Method 2: / root @ centos6 ~ # the chkconfig — list | grep 3: on | awk ‘{print $1}’ | grep – Ev “SSHD | crond | rsyslog | | network” sed – r “S # # (. *) the chkconfig \ off # 1 g” | bash/root @ centos6 ~ # the chkconfig — list | grep 3: on the crond 0: off 1:2: off on 3: on 4: on 5: on 6: off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

14. Describe the meanings of each boot level in /etc/inittab

[root@centos6~]# tail /etc/inittab #Default runlevel. The runlevels used are: # 0 — halt (Do NOT set initdefault to this) Without NFS (The same as 3,if you do not have networking) No NFS # 3 — Full multiuser mode — unused # 5 — X11 Desktop mode — reboot (Do NOT set initdefault to this Id: 3: initdefault: by default