Primary operations (i)

Source: Internet
Author: User
Tags log log inode usage nginx server haproxy

Find one topic to do efficiency too low, wasting time, rather than re-selected to do! Find the biggest probability of hit, do the most standard problem, this is the work of these days, the challenge is coming, do not be abused ah. In fact, the state is not good, wasting a lot of time


Primary operations (i)

1. Write a script that you are most adept at? (Hit rate 50%)

A: monitor MySQL master-slave replication status of the script, and mail alarm

1 #!/bin/bash

2 #主从复制, the script is executed from the server, scheduled 0:00 every day

3 #Author: Yue Hongcai

4 #2016-8-8

5

6 port= ' Netstat-an|grep "3306" |wc-l

7 ip= ' ifconfig eth0|grep "inet addr" |awk-f ": ' {print $} ' |awk ' {print '} '

8 If [$PORT-eq 1];then

9 echo "MySQL server is running."

Ten Else

Mail-s "$IP MySQL server 3306 not found!" [Email protected]

Fi

13

Status=${mysql-uroot-p123456-s/tmp/mysql.sock-e "show slave STATUS \g" |grep-i running}

Io_env=${echo $STATUS |grep IO |awk ' {print $} '}

Sql_env=${echo $STATUS |grep Sql|awk ' {print $} '}

17

If [$IO _env== "yes"-a $SQL _env== "yes"];then

echo "The slave repliaction is running"

Else

echo "+++++ $date ++++" >>/check_mysql.log

echo "Slave is down." >>/check_mysql.log

Mail-s "$IP MySQL slave repliaction is not ok!" [Email protected] <</check_mysql.log

Fi


2, what is the Apache compiler module, what is the function? (Too hard, hit 10%)

A: Configure the Apache reverse proxy to use Apache's mod_rewrite and Mod_proxy module groups


3. What is Nagios's architecture? (Mid-range problem, hit rate 30%)

A: (1) The Nagios process reads the NAGIOS.CFG master configuration file, which has a series of operational client configuration information.

(2) The Nagios process operates on a client-side configuration file similar to Localhost.cfg, which communicates with the agent on the monitored side to obtain monitoring results and data.

(3) The Nagios process writes the monitoring results to the Status.dat file, and the Status.dat file is equivalent to the log or database

(4) The CGI program analyzes the monitoring results in the Status.dat file, which is finally displayed in the Web interface.

Reference Document: Http://www.cnblogs.com/zhuhongbao/p/4174868.html


4, compare two files, with what order? (more difficult, hit 20%)

Answer: Cat file1 file2 | Sort | Uniq Remove the intersection of two files (leaving only files that exist in two files)

Cat File1 File2 | Sort | uniq-d (repeated only output duplicate rows)

Cat File1 File2 | Sort | Uniq–u Delete the intersection, leaving only the other rows

Cat File1 File2 | Sort |uniq-c counts the number of occurrences per row and prints

# #cat File1 file2 >1.txt, consolidating the contents of two files into one file


5, Apache configuration file to see the domain name point (difficult, a moment, do not know what meaning, hit 10%)

A: It is estimated that you want to test rewrite rewrite rules

Two domain www.abc.com www.def.com now need to operate open www.def.com jump to www.abc.com

<virtualhost *:80>

Documentroot/www/abc

Php_admin_value Open_basedir "/www/abc/tmp"

ServerName www.abc.com

Serveralias abc.com www.def.com


Rewriteengine on

Rewritecond%{http_host} ^www.def.com [NC]

Rewriterule ^/(. *) http://www.abc.com/[L]


Errorlog "/www/logs/apache/abc.com-error.log"

Customlog "/www/logs/apache/abc.com-access.log" common

Include "/www/apache/conf/httpd-platform-com-proxy-ajp.conf"

Include "/www/apache/conf/httpd-platform-rewrite.conf"

</VirtualHost>


6, a EXT3 partition, using the Touch text.file command system prompt disk is full, use the df-h command to see the disk size when the use of only 60% of the space why? (Mid-range, 30%)

A: Use Df-i to view inode usage, possibly because the inode is exhausted due to too many small files, possibly because the/tmp directory has a lot of temporary files, Find/tmp-type f-exec rm {} \, or traverse looking for 0 bytes of file, and delete. Find/home-type f-size 0-exec rm {} \; the last way to reformat a partition

Reference Document: Http://www.cnblogs.com/myjavawork/archive/2011/11/09/2242296.html


7, memory management in the meaning of Active,inactive,used,freed,swap? (two not heard before, 30%)

Answer: Combine Cat/proc/meminfo and free-m

Active: Buffer or cache size in active use, Inactive: the size of the buffer or cache in infrequently used,

Used: Used memory size, free: idle memory size, swap: size of swap partition due to insufficient physical memory


8. What do you think is the essential difference between Linux and Windows? (this question, I really have been asked, mainly on-the-spot play I do not think, the answer is not attractive, hit 50%)

A: (1) security mechanisms, such as iptables, Tcp_wrappers, and the service itself, a lot of barriers to the Linux system security has a certain guarantee

(2) The stability of the service itself, Linux application services under the fault-free working time is better than windows, whether it is from the statistical or operational personnel in the mouth can be derived from the results

(3) Open source and non-open source issues, the nature of the different, one is for the general public service, one is for professionals to serve

(4) Linux is a multi-tasking system with time-sharing, while Windows is a single-user system


9, Nagios How to SMS alarm? (I rub, this problem is exactly what I need to search, too hard, have time to carefully study, hit 50%)

A: Download fetion, define define command{} in Command.cfg, define templates.cfg define} in contact{, and finally restart Nagios.

Reference Document HTTP://WWW.CNYUNWEI.COM/PORTAL.PHP?MOD=VIEW&AID=89493


10, I have a folder inside there are many files, how to sort by time, how all listed? (still more difficult, hit 50%)

A: Using the Sort-k command,-k specifies sorting by the number of keywords, we can know which column the time is in, then ll |sort-k 7


11, the A.txt b.txt c.txt compression to back.tar.gz, how to view the files inside the package (relatively simple, 40%)

Answer: TAR-ZCVF back.tar.gz {a.txt,b.txt,c.txt} tar-ztvf back.tar.gz View the files packaged in it (-t-list)


12. How does the SMB server add users? How do I set up a shared folder? (It's not easy to say it in a breath, hit 30%)

(1), Useradd users

(2), smbpasswd-a users

(3), enter the password two times.

(4), then vi/etc/samba/smb.conf

[Share name]

Comment = Sales Stuff

Path =/var (shared path)

Valid users = user name

Public = yes

writable = yes

printable = no

Create mask = 0777

Directory mask = 0777

Last Restart service services SMB restart


13, introduced under the Nginx load balancer (This is unfamiliar ah, contact not much, 40%)

A: Nginx can do reverse proxy and static and dynamic separation, upstream currently supports 5 kinds of ways load balancing scheduling allocation algorithm

1), polling (default) each request is assigned to a different back-end server in chronological order, and can be automatically rejected if the backend server is down.

2), weight specifies the polling probability, the weight and the access ratio are proportional to the performance of the backend server is uneven.

3), ip_hash each request according to the hash result of access IP allocation, so that each visitor fixed access to a back-end server, you can solve the session problem.

4), Fair (third party) according to the response time of the back-end server to allocate the request, the response time is a short priority allocation.

5), Url_hash (third party)

Vi/usr/local/nginx/conf/nginx.conf

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Sendfile on;

Keepalive_timeout 65;

Upstream myserver{

Server www.linux.com:80;

Server www.88181.com:8080;

}

server {

Listen 80;

server_name my22;

Location/{

Proxy_pass Http://myServer;

}

}

}

Effect: After entering http://192.168.1.113/index.php, you will find that it will be in the I ' M the 88181, I ' M the Linux

The two pages are exchanged back and forth, and the view is incremented twice per refresh, which proves that the default is rotation.

Reference Document: Http://www.linuxdiyf.com/linux/10205.html


14, say the database of several backup methods, and say the pros and cons (say shallow line, 40%)

Answer: (1) mysqldump Backup (2) mysqlhotcopy Backup (3) Enable binary log (Binlog) master-slave copy Backup (4) rsync Backup (5) CP Copy file (6) third-party tools such as Bigdump

In nature, it is divided into transaction log backups, incremental backups, full backups, differential backups

Reference Document: http://blog.csdn.net/enweitech/article/details/51612858


15, a brief description of Nagios installation steps (hehe, ask this question, really no words, I am so long! Hit rate 50%)

A: (1) Deploy the lamp environment, download the Nagios source package, need to unzip and enter the Nagios directory, (2)./configure--prefix=/usr/local/nginx,make All, make install, make Install-init,make Install-config, making Install-commandmode, make install-webconf (3) Create Nagios users and groups, Install the Nagios-plugin plug-in directly./configrue &&make &&make Install, (4) Htpasswd-c/usr/loacl/nagios/etc/

Htpasswd.users nagiosadmin (5) Restart Apache and Nagios, log in http://IP/nagios/


16. How to create a hidden directory? Hide existing files? (This problem is newer Ah, only know the hidden files can be seen with ls-a.) indicates hidden files, hit rate 20%)

A: mkdir. TEST_DTR # #在文件夹前面用一个. It is estimated that the creation of hidden files is also the case, if the file has been renamed Add-on.


17. When a file has not been modified for 5 minutes, send an email to a mailbox. Done with the shell. (Hard, can't remember the command, hit 50%)

Answer: #!/bin/bash

File= ' Find. Mmin 5-a-type F ' ##-mmin n the last modification to file data was N minutes ago

if [!-Z $FILE];then

Mail-s "This file $FILE has not been modified for 5 minutes" [email protected]

Fi

Reference Document: Https://www.kafan.cn/edu/45424616.html


18. The difference between the SED awk grep find (This problem is too easy to test, hit 80%)

A: sed: reads a line of content into memory, matches the pattern space, if the condition is met, and if not satisfied, reads the next line in the text to continue the alignment. Then SED is primarily used to handle each line of

Awk: Reads the entire line of content to the $, then assigns the value of each column to $1,$2 according to the delimiter, knows the most row of $nf, prints it, and then reads the next line

grep: Filters A field in the text and prints the entire line of content that contains the field.

Find: Users look in a directory, the system consumes a large


19. What is the difference between NAT and Dr? (constant test, hit rate 60%)

A: (1) NAT refers to a load balancer, the destination IP address of the packet is changed to the IP address of the real server, and can be applied to the public network and private network environment, when the packet response will go through the load balancer, thus becoming the bottleneck of the whole system.

(2) While the Dr Direct route mode, the request message passes through the load balancer, after certain scheduling algorithm, changes the destination MAC address of the packet to the MAC address of the real server, and the loopback network card of all real servers

The VIP address is shared, ignoring the ARP response, the load scheduler is not required to answer the message, and can accept multiple concurrent requests, but only for private network environments.


20, MySQL master-slave replication principle, and MySQL database master from the key configuration is what? (not difficult, the more detailed the better, hit 50%)

A: Master has an IO thread, and slave has SQL threads and IO threads.

(1) When executing slave start from the server, the IO thread from the server connects to master via the authorized user and requests master to send the Bin-log log content after the specified file and location.

(2) After the master server receives a request from an IO thread from the slave server, master then returns to slave the corresponding Bin-log content and the next specified update location in Binlog.

(3) After the slave IO process receives the information, the received log content is added sequentially to the end of the Relay-log file on the slave side, and the file name and location of the Bin-log on the master side will be read

Log to the Master-info file so that you can clearly tell the master "where I need to start the log content from somewhere in the Bin-log" at the next read, please send it to me ";

(4) Slave's SQL process detects new additions to the Relay-log and immediately parses the Relay-log content into a command that is actually executed on the master side and writes the data to disk.

The key step is to specify the master's IP address and the synchronized POS point for the master-side authorization and slave-side:

Change Master to>

master_host= ' 192.168.149.128 ' >

Master_user= ' Tongbu ' >

master_password= ' 123456 ' >

Master_log_ file= ' mysq i a bin.000006 ' >

master_log_pos=98;


21, visit the website 500 error, what reason, cite three kinds of situations, how to solve? (That's why, it's so hard, hit 40%)

A: (1) Permissions configuration problem, the file does not have permission to read, it will throw this error, check the error log can be resolved.

(2). htacess configuration error, one is that there is a syntax error, one is not uncomment module_rewrite, and. Htacess inside is rewrite.

(3) There is a problem with the virtual host configuration file, try to check the IP access


22, the use of tcpdump, from the network segment 192.168.32.0/23 sent to the local 80 port data monitoring down (simple, but also test center, 30%)

Answer: tcpdump TCP port and net 192.168.1.0/24 # #如果是某台主机host 192.168.1.1


23, Nginx server occurred 502 error (only know the wrong gateway, do not know how to solve, 30%)

A: The meaning of Nginx 502 Bad Gateway is that the requested fastcgi has been executed, but for some reason (usually the problem of reading resources) is not completed and the fastcgi process terminates

The usual scenario is that the backend host service is unavailable or the system is down, PHP is not available, or the timeout

Reference Document: Http://www.cnblogs.com/mybest/archive/2012/12/27/2836211.html


24, decomposition of the file A, the number of lines within the file for the segmentation boundary, after each split small file has 2000 lines, after the file name is A01,a02....a[n] (this novel, not easy to answer, 20%)

A: split-d-L a ##-d (delimiter) option can specify a suffix number, such as 00,01,02, the first a for the file name, and the second a for the new file name prefixed by a

Reference Document: Http://www.jb51.net/LINUXjishu/115514.html


25, the A directory of all ordinary files, moved to the B directory, while ensuring that the rights are not changed, how to operate?

Answer: #!/bin/bash

For file in ' ll/a '

Do

If [-F $file];then

Cp-p $file/b ##-p (preserve) maintained meaning

Done

26, DDoS attacks there are several ways, are how to do the protection? (It's easy to ask the DDoS attack principle, but to ask the way, you don't know, hit 30%)

A: SYN Flood,smurf, teardrop, ping of death, etc., in the forefront of the deployment of hardware firewalls, such as Hua Sai USG500, Tian Tai Firewall

Reference Document: Http://jingyan.baidu.com/article/7c6fb42848410480642c9023.html


27, Keepalived and heartbeat comparison (for the time being not studied so, but in case the test, 30%)

A: Keepalived uses the VRRP protocol method, the virtual Routing Redundancy Protocol, heartbeat is the high availability of the host or network-based services;

The purpose of the keepalived is to simulate the dual machine of the router, heartbeat is a dual machine with service

The high availability of LVS is recommended with keepavlived, the high availability of the business use heartbeat


28, Nginx, Lvs, haproxy load balancing differences, how to achieve the session to maintain? (The weight of the topic, relatively long, the key to say, otherwise can not remember, hit 50%)

A: (1) Nginx: The advantages: Support rewrite rules, the network bandwidth requirements are not high, high stability, for reverse proxy, the probability of downtime is very small, built-in to the backend server port detection health Check function.

Cons: Only http, mail load balancing is supported

Session hold mechanism: Use the ip_hash mechanism of the upstream module to direct the request of an IP to the same server.

Upstream Backend {

Ip_hash;

Server 192.168.1.1:80;

Server 192.168.1.2:80;

}

(2) LVS: Advantages: Strong resistance to load, working in the 4 layer (access layer) for distribution only, no traffic generation, scheduling algorithm is particularly rich, simple configuration

Disadvantage: The software itself does not support regular expression processing, can not do static and dynamic separation

Session hold mechanism: Use persistence (in seconds) to set the session hold time.

(3) HAProxy: Support the full transparent proxy, support the connection rejection in order to anti-DDoS attack, support the virtual host, bring the powerful monitor server state of the page.

Cons: Not found yet

Session-hold mechanism: Balance source load balancing based on Origin address

Reference Document: Http://www.ha97.com/5646.html


28, the principle of CDN and intelligent DNS (this is the addition of the problem ah, hit rate 50%)

A: CDN is essentially the same as most cache servers, an edge network that provides access to the closest site to the user and improves access speed

(1) The user enters the domain name into the browser, the browser first discovers that there is no DNS cache locally, and the request points to the intelligent DNS load balancing system in the CDN network;

(2) The Intelligent DNS load Balancing system resolves the domain name and returns the IP node with the fastest response to the user.

(3) The user makes a request to the IP node (CDN server);

(4) because it is the first visit, the CDN server requests the original web site and caches the content;

(5) Request results sent to the user

Intelligent DNS: As China Telecom in the north, the Chinese unicom in the south, resulting in southern users to visit the Telecommunications server site particularly slow. So the intelligent DNS, if you are a unicom user, resolves the IP of the Unicom server for you to use, it is using the Bind+view architecture. It is worth mentioning that it is based on the local DNS user request location to determine whether Unicom users or telecommunications users.


29, a Web server nearly three months are relatively stable, today suddenly found that memory usage is high, how to solve? (Most love to test this question, hit 90%)

A: Using the top command, press the SHIFT+M key to see what process caused the memory spike, which, by experience, might be a problem with MySQL and check the access log for malicious access.


30, edit a file, root user, the file is read-only, how to save the exit, ordinary users? (The order is really hard to remember, 20%)

Answer: root:wq! Normal User: w! sudo tee%


31, will be a, B, C directory of documents A1, A2, A3 file, renamed to AA1, AA2, AA3. Use shell scripting.

Answer: #!/bin/bash

N=1

For dir in A B C

Do

cd/$dir

MV A$n aa$n

Let N=n+1

Cd..

Done


32, the system tuning parameter enumeration (difficult, hit 40%)

Answer: Generally TCP parameters, vi/etc/sysctl.conf

NET.IPV4.TCP_FIN_TIMEOUT=30 # #如果套接字由本端要求关闭, this parameter determines the time it remains in the Fin-wait2 state

NET.IPV4.TCP_KEEPALIVE_TIME=3200 # #保持长连接的时间

Net.ipv4.tcp_syncookies=1 # #当出现SYN等待队列溢出时, cookies are enabled to handle a small amount of SYN attacks

net.ipv4.tcp_max_syn_backlog=8192 # #表示SYN队列的长度

net.ipv4.tcp_max_tw_buckets=5000 # #系统保持TIME_WAIT套接字的最大数量

Sysctl-p # #配置参数生效


33. Remove the seventh and Nineth columns from the *.log log file and sort by IP.

Answer: Awk-f ":" ' {print $7,$9} ' *.log |sort-k 1 |sort-nr

34. Where is cacti's log?

Answer:/var/www/htm/cacti/log



Primary operations (i)

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.