Linux OPS (10)-2016-12-9 Finishing

Source: Internet
Author: User
Tags system log wrapper browser cache file transfer protocol high cpu usage java web nginx server tomcat server


there is a period of time did not organize the interview topic, these days, completed 2 interns and 1 school recruit, very depressed, why financial operation is not concerned about technology, care about my school results, I would like to say that the school so water curriculum can explain what, with the technology has a little relationship? My academic performance is not good, can deny my professional post foundation not? Alas, the Labor wants to say, if you question my ability, you ask me, if the labor is abused by you I count I lose, the study is not fine I take, see used to have the ball.

Career in this life do not want to outsource and IDC these two types of companies, is the TM handyman, salary is low, the key is not honest, such as garbage wins blue. This school recruit that home is I mentioned before that the family, most people to me is recognized, is my school performance is too ugly, a little dangerous ah, still waiting for news, hope not to be found I entered the peak of the track. Anyway, always have to hold an interview form of posture to learn, because it is possible to lose their jobs in minutes. Follow-up I will tidy up the issue of personnel, one is to prepare for their own use, including the next 10 years job-hopping, was fired after the job is such a routine problem, later want to use, direct take to see is, and secondly, share to everyone, do a good person, but I will describe and answer in my own tone, you crossing smile.

Do not want to stop the forward Ah, or divided into minutes to be eliminated rhythm. Network, database, Linux operations, develops, not too much content, but how much to learn how much, then I want to pay more attention to the operation.



1. What is a relational database? What is a non-relational database? What are the advantages and differences between them?
A: (1) relational database: The database based on the relational model is a two-dimensional table with the relationship name, and the relational model consists of three parts: relational data structure, operation set and integrality constraint. such as MySQL and Oracle.
Non-relational database: A data structure stored in the form of key-value pairs, although it is very fast, it can only get the data through a fully consistent query of the keys. such as MongoDB and
Redis.
(2) SQL Advantage: Support transactions (ensure data consistency), support multi-table compound query.
(3) NoSQL Advantage: Good at writing large amounts of data, suitable for applications where fields are not fixed.
Reference Document: Http://www.cnblogs.com/chay1227/archive/2013/03/17/2964020.html

2. If one day you find that the Lord never synchronizes, what do you do? (The production environment is too difficult)
A: Check the master-slave consistency by installing the Pt-table-checksum software, or check the SQL thread and IO thread for Yes on the slave show slave status \g
(not very accurate).
Resolution: The analysis is the IO thread is out of sync or the SQL thread is out of sync, the first is to analyze the MySQL log situation, in general the case is
(1) Skipping error execution synchronization. Set global sql_slave_skip_counter = 1;
(2) Copy data from the main library to the slave, then import, and finally re-specify the master's Binlog file and location, re-master-slave replication synchronization.
Reference Documentation: (Installation of Pt-table-checksum) http://mrxiong.blog.51cto.com/287318/1651349/
(The master never synchronizes the resolution Step) http://www.cnblogs.com/lixiansen/p/5667340.html

3. What is the difference between top and PS commands in the process of accounting for resource rates? (Don't look at the details.)
A: (1) The top command is a real-time dynamic monitoring of the resources of the process, including memory, CPU, and the state of the process running, while the PS command is a display of all processes running at this point in the execution of the command.
(2) The top command is more comprehensive, recording the current system time, the average load situation, and the swap partition situation.

4. What is the use of hard links?
A: Because it is fast to delete large files on a Linux system through hard links.

5, beginners in the Linux system boot start item how to choose?
A: It is recommended to select six boot items:
①crond: This service is used to perform periodic system and user-configured scheduled tasks. There are scheduled tasks to be performed on a recurring schedule that need to be opened
②iptables:iptables packet filter firewall, when there is an external network IP, consider opening.
③network: When booting the system, if you want to activate/deactivate each network interface at startup, you should (must) consider turning it on.
④SSHD: This service is required to connect to a Linux server remotely, so it must be turned on, otherwise it will not be able to connect remotely to a Linux server.
⑤RSYSLOGD: is a mechanism provided by the operating system, the system daemon usually uses Rsyslog to write various information collection to the system log file, CentOS6 formerly the name of this service is syslog.
⑥sysstat: Includes a set of tools to monitor the performance and efficiency of the system, such as CPU utilization, hard disk and network throughput data, which can be used to determine whether the system is functioning properly.
Reference Document: http://ccyypoint2008.blog.51cto.com/5602714/1763539

6, detailed iptales work flow and rule filter order? (This question is not a good answer, I have not seen this way of asking questions)
A: The work Flow: The local network card receives the source sends the data frame, according to four table five chain rules, carries on the match forwards or discards.
Filtering order: Iptables executes the rule from top to bottom in the rule table, if no matching rule is encountered, executes one line down, if a matching rule is encountered, then executes this rule, after execution according to the action of this rule (accept, reject, log, etc.), In determining the next step of implementation, there are generally three cases of follow-up.
(1) One is to continue executing the next rule in the current rule queue. For example, after executing a log in the filter queue, the next rule in the filter queue is also executed.
(2) One is to abort the execution of the current rule queue and go to the next rule queue. For example, from the execution of the accept after the interrupt filter queue other rules, jump to the NAT queue rule to execute
(3) One is to abort the execution of all rule queues.
Reference Document: Http://www.educity.cn/linux/515608.html

7, how to explain the iptables four table five chain? Each table has what several chain (see picture to speak only understood, true extension hemp difficult to remember AH)
A: Nat table: Used to do address translation (Prerouting/output/postroutiong);
Filter used for filtering (input/forward/output);
Mangle: Modify the format of the packet (all five chains have);
Raw: (OUTPUT, prerouting) set RAW is generally designed to no longer let iptables do the link tracking processing of packets, improve performance
Prerouting: Replace the action with the Dnat destination address before the packet enters the routing table
INPUT: Destination is native after routing table
FORWARDING: The destination is not native after routing table
OUTPUT: Generated by this machine, forwarded outward
Postroutiong: After leaving the routing table for Snat source address substitution action
The priority of 4 tables is from high to low in order: Raw-->mangle-->nat-->filter, if there is a mangle table on the prrouting chain, there is also a NAT table, then it is processed by mangle and then handled by the NAT table.
Reference Document: Http://www.360doc.com/content/11/0506/09/706976_114731108.shtml

8. How to make the Iptables rules executed at the command line permanent?
A: Service iptables save is temporarily in effect
(1) Write the rule to/etc/sysconfig/iptables.
(2) Write rules to/etc/rc.local

9, Linux Server suddenly become read-only file system, what is the situation? (This problem seems to be often tested)
Answer: (1) Check the file permissions, re-mount the root partition, Mount-o Rw,remount/
(2) using the Mount command to view the mounted file system, what is the exception, if the file system is read-only, it is recommended to uninstall Umount-l/dev/sr0 (List label)
(3) The inode may have been used, although the disk has space but can not write files, with the Df-hi parameters to check. You must delete small files to combine find.
(4) The worst choice, with CD-ROM boot into the Linux rescue rescue mode, fsck.ext4-y/DEV/SDA for file repair, but before the backup good
file, or it may cause a disaster.
Reference Document: http://blog.csdn.net/ablo_zhou/article/details/5530826/

10. Why integrate Apache and Tomcat?
Answer: (1) to separate the request from the client for static and dynamic separation. Tomcat itself can handle static content as a Web server, but it is very stressful to handle static resources and also handle dynamic resources to handle the Tomcat server.
(2) Tomcat application Server is not good enough to support rewrite redirection rules, expires browser cache, gzip transfer compression, and so on.

11. "." In the shell What is the difference from "source"?
A: "." is a new shell process, and then executes the corresponding script
Source is executed under the current shell, and no other shells are enabled.

12, a master more from the environment, the main machine down, choose which slave as the new master? (Alas, finally know what he wants to ask?) )
Answer: Select the maximum log offset for the trunk as the new master. Compare to choose Relay_master_log_file,exec_master_log_pos largest as the new main library, here we choose SLAVE1 as the new main library, in fact, if two from the IO thread has been normal, no lag behind the master, And Relaylog have been replayed to complete, two from is the same, choose which can. Automatic failover can also be achieved using keepalived high-availability software.
Reference Document: Http://wenku.baidu.com/link?url=6HbE86_8JasiUAd6aJmgSa005KRAomGW3QVWZaEODsh_1jNqKTQazQlhxnaRTqJb_ E4-8a9o5t_xivhm8sstp0tpjtkgxocvvkq4mz6inm3

13. What are the physical characteristics of MySQL master and slave? (Oh, my gosh, now I think about it.) What does the technical director want to ask?
A: Ensure data consistency and completeness. But the data is consistent in the establishment of master-slave relationship, the master created data will be transferred to the machine above, before the data, can only be manually imported (it's so simple, I can't remember, alas, no wonder I lost my job)
Reference Document: Http://blog.chinaunix.net/uid-20639775-id-3254611.html

14. What is the separation between reading and writing?
A: (1) Read-write separation is simply the database read and write operations to separate the corresponding database server, so as to effectively reduce the database processing pressure, but also to reduce the disk IO pressure. The main database provides write operations, from the database to provide read operations, in fact, in many systems, mainly read operations. When the primary database is written, the data is synchronized to the slave machine so that the database integrity can be effectively guaranteed.
(2) using Mysql-proxy as a read-write separation software, Mysql-proxy 4040 Port is responsible for listening to the front-end applications sent over the request, Mysql-proxy itself and
A task that is not responsible for reading and writing is simply the role of SQL routing, where the write operation occurs on master and the read occurs on a node from the server cluster. This design can greatly reduce the high CPU usage of MySQL instance.

15, the master-slave replication has master,slave1,slave2,... Wait so many MySQL databases, such as a Java Web application in the end should be connected to which database? (this question I should think many times, can only say that the theory is very simple, the implementation of the experiment not a day is not complete, not the operation can do is things)
A: Of course, we can do this in the application, insert/delete/update these update database operations, with connection (for master), select with connection (for slaves operation. Then our application has to finish how to select one from slaves to execute Select,
For example, a simple round robin algorithm. In this case, the equivalent of the application to complete the SQL statement routing, and the MySQL master-slave replication schema is very associated with, once master hangs, some slave hang, then the application will be modified. Is it possible to have an application that doesn't have much to do with MySQL's master-slave replication architecture?
To find a component, application program only needs to deal with it, use it to complete the MySQL proxy, and implement the routing of the SQL statement.
MySQL Proxy is not responsible, how to choose one from the numerous slaves? Can be handed to another component (such as Haproxy) to complete. This is called a read-write separation of MySQL read write Splite,mysql.
Reference Document: http://biweili.blog.51cto.com/4234993/1839448

16, please from an operational dimension (non-development), exhausted all the ideas, the database server optimization? (The reason to ask is to avoid answering some SQL statement optimizations, probably not the answer that the OPS interviewer wants to hear, the development guy will accept)
Answer: (1) Old idea, change from hardware is the most force, use solid-state drive to do RAID Array (possibly raid 1+0), improve disk IO capability
(2) According to the business logic, the database is divided into a table, is to reduce the volume of data read and write pressure (not to say, improve reading and writing ability)
(3) Distributed cluster, Mysql-proxy and Ameoba-led reading and writing separation scheme
(4) Set up a memcached server to cache the data that is frequently queried and reduce the read pressure of the backend server
(5) Optimization of parameters in the configuration file, such as maximum number of concurrent connections, connection timeout, table cache, and index cache.

17, the principle of the integration of Nginx and fastcgi?
A: Nginx does not support direct invocation or parsing of external programs, and all external programs (including PHP) must be called through the FastCGI interface. The FastCGI interface is a socket under Linux (the socket can be either a file socket or an IP socket). In order to invoke a CGI program, you also need a fastcgi wrapper (wrapper can be understood as the program used to start another program), which is bound to a fixed socket, such as a port or a file socket. When Nginx sends a CGI request to the socket, through the FastCGI interface, wrapper accepts the request and derives a new thread, which invokes the interpreter or the external program to process the script and reads the return data; Wrapper the returned data through the FastCGI interface, passing the fixed socket to nginx; Finally, Nginx sends the returned data to the client, which is the whole process of nginx+fastcgi.
http://blog.csdn.net/sunnyzhangwenhan/article/details/8833296

18. What are the different types of processes running? What is the difference.
Answer: Standalone and xinetd. (1) Standalone is called the standalone run mode, and XINETD is called the Super Mode, which is initiated based on the parent process.
(2) Apache service is such a mode of operation, standalone is to start one and then listen to all connections, and xinetd to the client connection request is started, as the end of the connection process also ends accordingly.

19, if the Apache server only allow 192.168.1.1来 access, do not allow others to access, how to set?
A: In configuration file httpd.conf, vim httpd.conf
-------------------------
<directory/> # #用于定义URI的访问控制属性
Order Deny,allow # #此处不区分大小写也行的, where allow and deny are not reversed
Deny from all
Allow from 192.169.1.1
</Directory>
----------------------

20. How does the nginx+fastcgi work? (The wrapper derivation thread is missing here.)
Answer: (1) Nginx server listens on 80 port.
(2) The client and the server to establish a TCP three handshake, and then, the connection is established successfully, you can transfer data.
(3) The client sends an HTTP request message, the Web server receives the request message will be based on the URI to determine whether the dynamic request, if it is a dynamic request, then the Web server through the process of communication to find the FastCGI interface, where the interface can be understood as a socket.
(4) Then, the FastCGI interface through the CGI protocol to the dynamic request to the separate PHP-FPM process pool processing, the PHP process may read the background database, between them through
A driver for communication.
(5) After the PHP interpreter (php.ini) explanation is executed, the processing results are sent to the Web server, and then the Web server encapsulates the HTTP reply message back to the client.
(6) The client's browser to parse, you can get the desired page.
Reference Document: Http://www.cnblogs.com/mangguoxiansheng/p/5967745.html

21, what is called the interpretation of execution?
A: (1) A high-level language compiled into an intermediate language, the intermediate language can be re-compiled on different platforms to become an executable program.
(2) Read a line to the computer's CPU to submit a row, and then read a row and then submit a row, the execution is a bit inefficient.

22. What is the difference between NFS and FTP and samba? (I think this kind of problem is really stupid, they are completely different, can't hit a pole up)
A: (1) NFS is a network file system for sharing files between Linux or UNIX, based on the C/S mode, the server is shared, the client is mounted locally, there is TCP-based transmission, there are
Based on UDP transmission, NFS is not secure based on IP address sharing.
(2) FTP is a file transfer protocol for uploading or downloading, the data port on the server is 20 by default, the control port is 21, based on TCP protocol transmission, Windows and Linux can use between Ftp,linux and Linux also can use FTP, FTP has a very strict authority control mechanism.
(3) Samba is a file and printer shared between Windows and Linux, and is mounted based on the CIFS (Universal Network File System) protocol.

23, with tcpdump sniffing 80 port access to see who the highest, tcpdump can catch HTTPS traffic packet it.
Answer: tcpdump-i ETH0-TNN DST Port 80-c 1000 | Awk-f "." ' {print ' $ '. ' $ "." $ "." $4} ' | Sort | uniq-c | Sort-nr|head-20
(1) tcpdump-i ETH0-TNN DST Port 80-c 1000: Statistics the packet with destination port 80 in this machine,-TNN: Display directly with IP and port number, not hostname and service name, and do not display timestamp timestamp. -C 1000:count Statistics of 1000 packets.
(2) awk-f "." ' {print$1 '. " $ "." $ "." $4} ': The output of the tcpdump is processed on one line, and the remote host IP is printed sequentially as a delimited domain.
(3) Sort: Sorts the output of the access-side IP.
(4) Uniq–c: Merge the same rows and count the number of peers.
(5) Sort–nr: Sort by the same number of rows, reverse the order, the largest in the front.
(6) Head-20: Extract the first 20 lines

24. The difference between nagios and cacti. (I'll review it myself)
A: (1) cacti is primarily used to monitor network traffic and system performance, and Nagios is primarily used to monitor the status of hosts and services.
(2) Cacti is able to map and focus more on the changes in threshold peaks over time, while Nagios is more concerned about changes in service status.
(3) Nagios alarm function more powerful, SMS and mail alarm, cacti mail alarm need to download template (image template, host template, data template) and Web GUI settings.
(4) Cacti monitor a thing, need to download a template, configure it in a Web GUI, and Nagios monitors a thing that needs to be defined in the configuration file and called to each other.

25. How to test the reading and writing separation?
A: (1) Use any one client, login to the Mysql-proxy Proxy Server 4041 management port, select * from backends; view master and slave machine status;
(2) Then use any one client, login to the Mysql-proxy proxy server 4040 read and write separation port, and then insert the table data, and then, respectively, in the Master and slave machine
, see if there is a corresponding data, and maintain consistent functionality.
(3) Finally, repeat (1) step, log on to the 4041 management port to see if the master-slave machine status has changed, such as up and up to turn state.

26, (6) Apache processing request Prefork or worker model, and Nginx is the event model.
(7) Apache's event IO processing model is the Select model, and the Nginx event IO processing model is the Epoll model.

27, Nagios Alarm How to set, cacti threshold alarm how to set. Do you prefer using cacti or nagios?
A: Nagios: (1) Start the SendMail service that comes with the machine, ensure that 25 ports can be opened.
(2) Contact.cfg defines the email address of the contact in the Nagios configuration file, and alerts under what monitoring metrics, such as outage (d), unreachable (U), State recovery (R), floating (f), and at what time period.
CACTI: Install some plug-ins, such as thold and setting, to alert you as to how much percentage of usage is defined on the Web interface.
Individuals prefer to use nagios, although it is cumbersome to define each other in the Nagios configuration file, but it is easy to debug, and cacti can monitor the functionality, Nagios can monitor, and even more features of Nagios, such as monitoring routers, switches, printers.
Reference Document: Cacti thresholds for mail alerting: http://lizhenliang.blog.51cto.com/7876557/1361618/

28. What are the meanings of each state in the TCP finite state machine?
A: It seems to have been organized before, although often contact, but can not express the specific meaning of language.
CLOSED: No connection is active or in progress
LISTEN: The server is waiting to enter the call
SYN_RECV: A connection request has arrived, waiting for confirmation
Syn_sent: Application has started, open a connection
Established: Normal data transfer status
FIN_WAIT1: Application says it's done
Fin_wait2: The other side has agreed to release
CLOSING: Both sides try to close simultaneously
Time_wait: The other side has initialized a release (this Thing Love Test)
Last_ack: Waiting for all packets to die

29, smooth restart what meaning, nginx How to do smooth restart (note, not a smooth upgrade)
A: The smooth start means to reload the configuration file, start a new worker thread, and stop the old nginx worker thread without stopping the Nginx service.
(1) kill-hup ' Cat/var/run/nginx.pid '
(2)/usr/local/nginx/sbin/nginx-s Reload # #都是通过信号的形式告知给内核

30. What modules does memcached contain, slab the basic principle of allocator memory management mechanism? How does it work? (The slab here can be understood as a page of memory)
Answer: module: Memory management mechanism (slab), hash algorithm, multithreading and Libevent event processing mechanism.
The basic principle of the slab allocator is to divide the memory into trunk blocks of several specific lengths according to a predefined size, and to classify trunk blocks of the same length into slab groups, and the size of the slab group
Increment according to the argument of a growth factor. When Memcached accepts a key-value pair storage request sent to the front-end client application, it first calculates if the data block has enough size to accommodate the record, if it is not enough to apply to the system, if the application limit is reached, use the LRU algorithm to eliminate the least recently used data block, Make room to save the new record (item).
Role: Resolve memory fragmentation issues as much as possible.



Linux OPS (10)-2016-12-9 Finishing

Related Article

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.