安裝centos
centos7---vs
centos6---RS1、RS2
centos6---client
最小化安裝centos,配置yum源萧锉;
cd /etc/yum.repos.d/
rm-rf *
vi base.repo
[base]
baseurl=file:///mnt
gpgcheck=0
#yum repolist
#yum makecache
#yum install vim
#yum install autofs
chkconfig autofs on
service autofs start
#vim base.repo
[base]
baseurl=file:///misc/cd
gpgcheck=0
設(shè)置ip地址驼唱,設(shè)置為靜態(tài)ip;
使用VMware 僅主機(jī)和自定義模式(僅主機(jī))
1驹暑、vs外網(wǎng)網(wǎng)卡設(shè)置為自定義模式玫恳;ip;192.168.183.151
vs內(nèi)網(wǎng)網(wǎng)卡設(shè)置為僅主機(jī)模式;ip:192.168.226.151
2优俘、RS1京办;僅主機(jī)模式,ip;192.168.226.140
RS2帆焕;僅主機(jī)模式惭婿,ip;192.168.226.141
3、client;自定義模式叶雹;ip;192.168.183.130
關(guān)閉防火墻及SElinux設(shè)置财饥;
centos6;
#chkconfig iptables off
#chkconfig list iptables
#vim /etc/selinux/conf
#setenforce 0
#getenforce
centos7;
systemctl enable firewalld
systemctl stop firewalld
#vim /etc/selinux/conf
#setenforce 0
#getenforce
1、VS(centos7)安裝ipvsadm折晦;
設(shè)置VS服務(wù)模式钥星;
設(shè)置VS的算法;
開(kāi)啟ipv4轉(zhuǎn)發(fā)功能满着;
2谦炒、RS(centos6)安裝httpd;
設(shè)置簡(jiǎn)單的網(wǎng)頁(yè);
將RS網(wǎng)關(guān)指向VS(192.168.226.151)风喇;
3宁改、client客戶(hù)端訪問(wèn)vs端網(wǎng)頁(yè);
1魂莫、VS (centos 7)上安裝ipvsadm还蹲,設(shè)置/etc/sysctl.conf配置文件、設(shè)置VS服務(wù)模式及算法;
#yum install ipvsadm
#Vim /etc/sysctl.conf
Net.ipv4.ip_forward=1
#ipvsadm -A -t 192.168.183.151:80 -s rr---模式
#ipvsadm -a -t 192.168.183.151:80 -r 192.168.226.140 -m ---算法
#ipvsadm -a -t 192.168.183.151:80 -r 192.168.226.141 -m
2、RS服務(wù)器將網(wǎng)關(guān)指向VS服務(wù)器谜喊,安裝httpd并啟用鲸沮;
RS1;
# vim /etc/sysconfig/network-scripts
DEVICE=eth0
IPADDR=192.168.226.140
PREFIX=24
GATEWAY=192.168.226.151
RS2;
# vim /etc/sysconfig/network-scripts
DEVICE=eth0
IPADDR=192.168.226.141
PREFIX=24
GATWAY=192.168.226.151
#yum install httpd
#service httpd start
#chkconfig httpd on
創(chuàng)建簡(jiǎn)單的網(wǎng)頁(yè);
echo RS1 SERVER >/var/www/html/index.html
echo RS2 SERVER >/var/www/html/index.html
3锅论、client客戶(hù)端訪問(wèn)網(wǎng)頁(yè),檢測(cè)是否成功;
#curl 192.168.183.151
#if i in {1..10};do curl 192.168.183.151;done
[root@client ~]#for i in {1..10};do curl 192.168.183.151;sleep 1;done
RS1 SERVICE
RS2 SERVICE
RS1 SERVICE
RS2 SERVICE
RS1 SERVICE
RS2 SERVICE
RS1 SERVICE
RS2 SERVICE
RS1 SERVICE
RS2 SERVICE
4楣号、在vs上查看連接狀態(tài)最易;
#Ipvsadm -Ln
[root@VS1 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.183.151:80 rr
-> 192.168.226.140:80 Masq 1 0 8
-> 192.168.226.141:80 Masq 1 0 8
5、測(cè)試性能炫狱;
[root@client ~]#ab -c 100 -n 10000 http://192.168.183.151/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.183.151 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: Apache/2.2.15
Server Hostname: 192.168.183.151
Server Port: 80
Document Path: /
Document Length: 12 bytes
Concurrency Level: 100
Time taken for tests: 4.102 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 2785829 bytes
HTML transferred: 120036 bytes
Requests per second: 2437.62 [#/sec] (mean)
Time per request: 41.024 [ms] (mean)
Time per request: 0.410 [ms] (mean, across all concurrent requests)
Transfer rate: 663.16 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 8 9.4 6 188
Processing: 5 33 16.7 30 231
Waiting: 3 32 16.2 30 231
Total: 22 40 19.1 39 240
Percentage of the requests served within a certain time (ms)
50% 39
66% 41
75% 42
80% 42
90% 44
95% 45
98% 48
99% 56
100% 240 (longest request)
6藻懒、查看誰(shuí)在訪問(wèn);
Cat /var/log/httpd/access_log
7视译、查看誰(shuí)訪問(wèn)的數(shù)量嬉荆;
[root@RS1 network-scripts]#cut -d" " -f1 /var/log/httpd/access_log |sort - nr|uniq -c|sort -n
1 192.168.226.140
3 192.168.226.151
10 ::1
102 192.168.183.151
10328 192.168.183.130
8、查看每秒鐘的訪問(wèn)數(shù)據(jù)平均速度酷含;
[root@VS1 ~]# ipvsadm -Ln --rate
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port CPS InPPS OutPPS InBPS OutBPS
-> RemoteAddress:Port
TCP 192.168.183.151:80 1 5 5 447 545
-> 192.168.226.140:80 0 3 2 223 272
-> 192.168.226.141:80 0 3 2 224 273
9鄙早、更改vs算法,更改RS權(quán)數(shù)椅亚;
Ipvsadm -E -t 192.168.183.151:80 -s wrr
Ipvsadm -e -t 192.168.183.151:80 -r 192.168.226.141 -m -w 3
再次訪問(wèn)時(shí)會(huì)有變化限番;
[root@client ~]#for i in {1..100};do curl 192.168.183.151;sleep 1;done
RS2 SERVICE
RS1 SERVICE
RS2 SERVICE
RS2 SERVICE
RS2 SERVICE
RS1 SERVICE
刪除網(wǎng)卡模塊;
/etc/udev/rules.d/70-persistent-ipoib.rules
- 卸載模塊
- Rmmod e1000
- Modprobe e1000
添加ip地址
ip a add 192.168.226.151/24 dev eth0
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者