Linux OPS Practice-March 4, 2016-March 19 course Assignments

Source: Internet
Author: User
Tags mysql backup

1, build lamp environment, and practice based on DNS to do domain-based virtual host.

Build lamp Environment:

[email protected] ~]# yum install httpd mariadb-server php php-mysql

Initialize MARIADB:

[Email protected] ~]# mysql_secure_installation

DNS-based domain-based virtual host

[Email protected] ~]# vim/etc/httpd/conf.d/myhoust.conf <virtualhost *:80> ServerName www.myhost.com documentroot "/web/" </VirtualHost>



2, based on the environment in the 1 topic, re-establish a similar environment, requirements:

A) automate synchronization of Web service file updates to another machine

Host1

[email protected] ~]# yum install nfs-utils rpcbind [[email protected] ~]# Vim/etc/export S/web * (Rw,sync)

Host2

[Email protected] ~]# mount-t NFS 10.9.9.7:/web/web

b) database for master-slave replication

Master:ee-o

MY.CNF Log-bin=/tmp/mysql-bin server-id=1

Slava:ee-a

MY.CNF Log-bin=/tmp/mysql-bin server-id=2

2. Authorized slave

MariaDB [ab]> Grant Replication Slave on * * to ' ee-a ' @ ' 10.9.9.16 ';

3. View the bin Log

                     mariadb [(None)]> show master logs;                                          +------------- ----+-----------+                     | log_name        | file_size  |                     +-----------------+-----------+                     | mysql-bi.000001 |        245 |                     +-----------------+-----------+

4.salve

                mariadb [ (none)] > change master to                                          -> master_host= ' 10.9.9.1 ',                     - > master_port=3306,                     -> master_user= ' ee-a ',                     -> master_password = ",                 "    -> master_log_file= ' mysql-bi.000001 ',                     -> master_log_pos=245;                     mariadb [ (none)] > start slave;



c) Web site source code backup and MySQL backup via shell script, backup strategy including full-volume, incremental, differential backup

                     #!bin/bash                                           #全量备份                      tar -cf /bak/web.bak ' date +%y %m%d '  /web                     mysqldump -uab -phello -A > mariadb.dump                     #! bin/bash                      #增量备份 &NBsp;                    read -p  "Please enter this is the first few backups"  level                     dupm -l $ ((  $levle -1 ))  -f /bak/web ' date +%y%m%d '  /web                     mysqldump -uab -phello -a  > mariadb.dump                     #!bin/bash                      #差异备份                      read -p  "0: First time backup ; 1: Non-first backup " level                    dupm  -l  $level  -f /bak/web ' date +%y%m%d '  /web                     mysqldump -uab - Phello -a > mariadb.dump

3, the use of pressure measurement tools (ab/webbench, etc.) to achieve the page pressure measurement, the need to adjust the Apache operating mode to compare the final performance.

[[email protected] ~]# ab -c 1000 -n 100000 http://10.9.9.7/ Index.htmlprefork:concurrency level:      1000time taken for  tests:   45.518 secondsComplete requests:       100000failed requests:        80    (Connect:  0, receive: 0, length: 80, exceptions: 0) write errors:            0Non-2xx responses:       99985total transferred:      38694195 byteshtml transferred:        20796880 bytesRequests per second:     2196.94 [#/sec]  (mean) time per request:        455.178 [ms]  (mean) time per request:       0.455 [ms]  (Mean, across all  concurrent requests) transfer rate:           830.16 [kbytes/sec] receivedworker:concurrency level:       1000time taken for tests:   37.335 secondscomplete requests:       100000failed requests:        118     (connect: 0, receive: 0, length: 118, exceptions: 0) Write  errors:           0Non-2xx responses:       99998Total transferred:      38699226  Byteshtml transferred:       20799584 bytesrequests per  second:    2678.45 [#/sec]  (mean) time per request:       373.350  [ms]  (mean) time per request:       0.373 [ms]   (mean, across all concurrent requests) transfer rate:           1012.24 [Kbytes/sec] receivedevent:Concurrency Level:       1000Time taken for tests:   21.753  secondscomplete requests:      100000failed requests:         0Write errors:            0Non-2xx responses:      100000Total transferred:       38700000 bytesHTML transferred:        20800000 bytesRequests per second:    4597.15 [#/sec]  (mean) time per request:        217.526 [ms]  (mean) time per request:        0.218 [ms]  (mean, across all concurrent requests) transfer rate:          1737.40 [kbytes/sec]  Receivedprefork<worker<event


4, based on the 3-step process of the pressure measurement, through the script to achieve iptables automatically determine the source IP, and to make IP access denied, requiring access times of 1 seconds more than 10 times rejected.





5, based on the environment in 2, through the LVS to achieve load balancing, requires the use of Dr Mode, and can be part of the principle of their own understanding of the summary.

[[email protected] ~]# ip addr add 10.9.9.8/32 dev eno16777736 ## Configure vip[[email protected] ~]# ip route add 10.9.9.8 dev eno16777736[[ Email protected] ~]# echo 1 >/proc/sys/net/ipv4/ip_forward[[email protected]  ~]# ipvsadm -c[[email protected] ~]# ipvsadm -a -t 10.9.9.9:80  -p 5 -s rr[[email protected] ~]# ipvsadm -a -t 10.9.9.9:80  -r 10.9.9.1:80 -g[[email protected] ~]# ipvsadm -a -t  10.9.9.9:80 -r 10.9.9.2:80 -grs1:10.9.9.1[[email protected] ~]# ip addr  10.9.9.8/32 dev lo[[email protected] ~]# ip route add 10.9.9.8  dev lo[[email protected] ~]# echo 1>/proc/sys/net/ipv4/conf/lo/arp_ignore[[ Email protected] ~]# echo 1>/proc/sys/net/ipv4/conf/all/arp_ignore[[email protected] ~]# echo 2>/ proc/sys/net/ipv4/conf/lo/arp_announce[[email protected] ~]# echo 2>/proc/sys/net/ipv4/ Conf/all/arp_announcers1:10.9.9.2[[email protected] ~]# ip addr 10.9.9.8/32 dev  lo[[email protected] ~]# ip route add 10.9.9.8 dev lo[[email  protected] ~]# echo 1>/proc/sys/net/ipv4/conf/lo/arp_ignore[[email protected]  ~]# echo 1>/proc/sys/net/ipv4/conf/all/arp_ignore[[email protected] ~]# echo  2>/proc/sys/net/ipv4/conf/lo/arp_announce[[email protected] ~]# echo 2>/proc/ Sys/net/ipv4/conf/all/arp_announce

lvs-dr principle :

Based on the principle of ARP protocol communication in LAN, when the client's packet arrives at virtual server and modifies the second layer package address as real server, then forwards the packet to the host corresponding to the ARP table, and finally the real server processing request is sent back to the client directly;


Linux OPS Practice-March 4, 2016-March 19 course Assignments

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.