8.12 LVS虚拟服务器

环境准备:5台虚拟机
DNS:192.168.1.21                        作用:域名解析
Web1:192.168.1.22                    作用:真实服务器
Web2:192.168.1.23                    作用:真实服务器
NAT:192.168.1.24(DIP)    192.168.10.24(VIP)    作用:负载均衡
客户机:192.168.1.20                    作用:访问测试

web1:

[root@web1 ~]# yum -y install nginx                    //yum下载
[root@web1 ~]# nginx                      //启动nginx
[root@web1 ~]# find / -name "nginx"         //找nginx的配置文件
[root@web1 ~]# echo "i am web1" > /usr/share/nginx/html/index.html 
[root@web1 ~]# systemctl stop firewalld
[root@web1 ~]# systemctl disable firewalld
[root@web1 ~]# setenforce 0
浏览器访问

web2:

[root@web2 ~]# yum -y install nginx
[root@web2 ~]# nginx
[root@web2 ~]# echo "i am web2" > /usr/share/nginx/html/index.html 
[root@web2 ~]# systemctl stop firewalld
[root@web2 ~]# systemctl disable firewalld
[root@web2 ~]# setenforce 0
浏览器访问

dns:

[root@localhost ~]# yum -y install bind
[root@localhost ~]# vim /etc/named.conf 
 listen-on port 53 { 127.0.0.1;any; };
 allow-query     { localhost;any; };
[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "tdr.com" IN {
        type master;
        file "tdr.com.zone";
        allow-update { none; };
}; 
[root@localhost ~]# cp -p /var/named/named.localhost /var/named/tdr.com.zone 
[root@localhost ~]# vim /var/named/yu.feng.zone
nat     A       192.168.1.24
ds      A       192.168.10.24
web1    A       192.168.1.22
web2    A       192.168.1.23
[root@localhost ~]# systemctl start named
[root@dns ~]# systemctl stop firewalld
[root@dns ~]# systemctl disable firewalld
[root@dns ~]# setenforce 0

客户机:

[root@client ~]# vim /etc/resolv.conf
nameserver 162.168.1.20
[root@client ~]# ping web2.tdr.com
PING web2.tdr.com (192.168.1.23) 56(84) bytes of data.
64 bytes from 192.168.1.68 (192.168.1.23): icmp_seq=1 ttl=64 time=0.759 ms
64 bytes from 192.168.1.68 (192.168.1.23): icmp_seq=2 ttl=64 time=0.503 ms

nat主机:做个时间同步,考虑到压力过大,所以不再创建新的虚拟机

[root@nat ~]# yum install -y ntpdate.x86_64 
[root@nat ~]# ntpdate cn.ntp.org.cn
12 Aug 14:12:05 ntpdate[4567]: adjust time server 106.75.185.63 offset 0.047541 sec
[root@nat ~]# crontab -e
* 2 * * * /usr/sbin/ntpdate cn.ntp.org.cn
[root@nat ~]# crontab -l
* 2 * * * /usr/sbin/ntpdate cn.ntp.org.cn
[root@nat ~]# yum -y install ntp
[root@nat ~]# systemctl start ntpd

//在其他主机都做下面的操作,同步时间
[root@localhost ~]# yum -y install ntpdate.x86_64
[root@localhost ~]# crontab -e                    
30 2 * * * /usr/sbin/ntpdate 192.168.1.24

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值