Linux system Operations Common interview short answer series (b) (14 questions)

Source: Internet
Author: User
Tags log log nginx reverse proxy rsyslog egrep

1./var/log/messages log appears kernel:nf_conntrack:tablefull,dropping packet, what is the cause of the problem, how to solve?

This error is iptables error message, the connection tracking table is full, start to drop packets, possibly due to frequent connection, shutdown, or some TCP connection of the network caused by
Workaround:
1) Increase the size of the tracking table
2) Disable some connection states that do not have to be tracked
3) Disable Module Ip_vs nf_conntect

2. Linux system Nginx and PHP environment, found PHP-FPM process High, please say the possible reasons and how to solve?

1) The PHP plugin is incompatible with the existing PHP version, the workaround is to disable the plugin from the php.ini.
2) The software itself has problems, need to develop collaborative operations to deal with, find the reason
3) PHP program has a dead loop phenomenon, using the server load is too high, the solution using the top command to view

3. Disk error: Nospace left on device, but df-h view space is not full, why?

Cause: The system inode is full, because all the file name information is stored in the Inode, the contents of the file is stored in the block inside
You can use Df-i to view the usage of the Inode
[Email protected] 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 51162 1%/boot

4. Disk space is full, delete a portion of the Nginx log, but disk space is full, why?

Deleted log information, some of which may still be called by the process, so you need to restart the Nginx service to release the process, or use >/log/access.log to empty the file in the actual production environment

5. How to 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. Extract the characters Faild and successful in the file Test.log, but do not include the done line, and then take: for the delimiter, extract the third column
[Email protected]]# cat Test.log
FAILD:SUCCESSFUL:DONE:CRITICAL
FAILD:SUCCESSFUL:NO:GOOD
FAILD:NO:DO:QINGYUN
Successful:done:critical::critical

Method One:
[Email protected]]# egrep] faild| Successful "Test.log |grep-v done|awk-f ': ' {print $} '
NO
Do

Method Two:
[Email protected]]# egrep] faild| Successful "Test.log |grep-v done|cut-d:-f3
NO
Do

7. The server room of the company nearly 254 units, please design a solution, how to divide the network segment, and achieve smooth migration of business.

The first scenario: changing the eldest son Netmask method, increase the range of IP address, the entire network distribution/etc/hosts file
Second scenario: increase the core switch, divide the VLAN in the core switch, add the new server to the VLAN, and distribute the/etc/hosts file all over the network

8. Nginx reverse proxy How to implement different virtual host on the RS node, please say the principle and configuration method or idea.

The client sends the request to the reverse proxy, and the reverse proxy forwards it to the target server in accordance with certain rules, and returns the returned content to the client, which can be divided into the following two types:

Configure internal different server forwarding:
Upstream App1 {
Server 192.168.1.10:80 weight=5;
Server 192.168.1.11:80 weight=5;
}
Upstream APP2 {
Server 192.168.1.20:80 weight=5;
Server 192.168.1.21:80 weight=5;
}
Configure the server
server{
Listern 80;
server_name app.abc.com
}

To configure a matching forwarding rule:
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;
}
As a load balancer.
Configure the Load Balancer server pool, which is the scheduling rule
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 tab,
server {
Listen 80;
server_name www.abc.com;
Proxy_pass http://test_servers;
Proxy_set_header Host $host
}
After the configuration is complete, reload the Nginx service

9. Say the different network connection states that correspond to the last column status in the Netstat-an command result
[Email protected] ~]# 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 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

Listen the first state (listening state) after the service is started
Established establishes a connection that indicates that both ends of the connection can communicate properly
Close_wait is interrupted by an active shutdown of the connection or network exception, so the status becomes
Time_wait active disconnection, received the other party confirmed status, equivalent to release resources, you can set some of the parameters of the state, that is, the active disconnection, the next time interval of reconnection
Syn_sent the state of the requested connection and the first synchronization signal that is required to access the other machine

What is Binlog? What does the Binlog record? There are several modes and pros and cons, which mode do you choose to synchronize in the enterprise?

Binlog: Is an action statement that records all updated data, and the statement is saved as an event that describes the process of changing the data
Role: For real-time backup data, database master-slave replication
Log_bin Open Record Binlog function

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

Binlog deletion: Can be divided into automatic and manual deletion
Automatically delete
Can over Binlog parameter expire_logs_days to achieve
Show binary logs;
Show variables like "expire_logs_days;"
Set gloable expire_logs_days=3;
Manually delete
Reset Master Removes the binlog of the master
Reset slave removed from the trunk log

Three modes:
Row level mode: The log records the form of each row of data being modified and then modifies the same data at the slave end
Advantage: You can not record the execution of the SQL statement context-sensitive information, only to record which data is modified, how to modify the
Cons: All executed statements are recorded in a log file, and are recorded with the modification of each row of records, resulting in a large amount of log content

Statement mode: Each SQL that modifies the data is recorded in the Bin-log of the master, slave the SQL process resolves the same SQL that was executed by Sing Woo original master at the time of the copy execution
Advantages: Solve the disadvantage of the row level mode, do not need to record each row of data changes, reduce the amount of log, you can get high performance
Disadvantage: Because the record is the execution statement, in this mode there will be a master and slave can not replicate problems appear

Mixed automatic mode: MySQL distinguishes the log format of treated records according to each specific SQL statement executed.
Enterprise Usage Scenarios:
1) If MySQL special function is not used, it is basically the default mode statement mode
2) If you are going to some special features of MySQL, you will basically use the row level mode

11. Please describe the principle of HTTP protocol in detail

HTTP protocol: Is the basis for communication between client and server, HTTP protocol is based on TCP/IP protocol
The principle consists of four processes:
Connection: The browser establishes a connection with the server and opens a socket virtual file indicating that the connection was established successfully
Request: The browser submits a request to the server via a socket (usually get or post instructions)
Answer: After the browser requests the submission, through the HTTP protocol to the server, the server receives the processing to pass the result again through the HTTP to the client, thus displays the requested page in the client
Close connection: When the answer is complete, the browser disconnects from the server

12. Please describe MySQL master-slave replication principle in detail

Principle: The main library opens the Binlog function and authorizes the user right from the library to connect the main library to synchronize, the database changes or changes generated Bin-log log, from the library through the change Mster statement to get the main library information, from the library to open slave and connect the main plus to carry out the relevant verification, after verification, The IO thread of the main library sends the relevant location point information from the library's request, with the latest blnlog information to the IO thread from the library, the IO thread from the library puts the SQL statement information in Relay-log, and finally the SQL statement from the library is applied to the relay-log from the library. Synchronize the data between the main library and the library, and then repeat the action again

13. Use a single command to turn off all services except SSHD, Crond, network, Rsyslog services (no power-on automatic)

Method One:
[[Email protected]~]# for name in ' Chkconfig–list|grep 3:on|awk ' {print '} ' |grep-ev "sshd|crond|rsyslog|network" ';d och Kconfig $name Off;done
[Email protected]~]# chkconfig–list|grep 3:on
Crond 0:off 1:off 2: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

Method Two:
[[email protected] ~]# chkconfig–list|grep 3:on|awk ' {print '} ' |grep-ev ' sshd|crond|rsyslog|network ' |sed-r ' s# (. *) # Chkconfig \1off#g "|bash
[Email protected]~]# chkconfig–list|grep 3:on
Crond 0:off 1:off 2: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 meaning of each boot level in the system/etc/inittab

[[Email protected]~]# tail/etc/inittab
#Default RunLevel. The runlevels used is:
# 0–halt (do not set Initdefault to this) shutdown
# 1–single User Mode single
# 2–multiuser, without NFS (the same as 3,if you does not have networking) multiuser, no NFS
# 3–full Multiuser mode full multi-user model
# 4–unused
# 5–x11 Desktop mode
# 6–reboot (do not set Initdefault to this) reboot
#
Id:3:initdefault: Default

Linux system Operations Common interview short answer series (b) (14 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.