*(需要开启三台模拟机分别以1号,2号机,3号机命名,提前安装好nginx,软件包网卡统一)
1号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=200.0.0.10
GATEWAY=200.0.0.1 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#systemctl stop firewalld
2号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=200.0.0.20
GATEWAY=200.0.0.1 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#systemctl stop firewalld
3号机#
#vim /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
IPADDR=200.0.0.30
GATEWAY=200.0.0.1 (ESC:wq)保存退出
#ifdown ens33;ifup ens33
#systemctl stop firewalld
1号机#
拼通2号机,3号机)
#ping 200.0.0.20
#ping 200.0.0.30
#mount /dev/cdrom /mnt
#cd /etc/yum.repos.d/
#mv Centos-Base.repo Centos-Base.repo.bak
#vim Centos-Base.repo
[a]
baseurl=file:///mnt
gpgcheck=0 (ESC:wq)保存退出
#yum clean all
#yum -y install pcre-devel zlib-devel openssl-devel
#useradd -M -s /sbin/nologin www
#tar zxf /root/Desktop/nginx...tar.gz -C /usr/src
#cd /usr/src/nginx...../
#./configure --prefix=/usr/local/nginx --user=www --group=www --with-file-aio --with-http_stub_status_module && make && make install
#vim /usr/local/nginx/conf/nginx.conf
20行:upstream apache_server {
server 200.0.0.20:80 weight=1;
server 200.0.0.30:80 weight=1;
}
49行:必须在 } 里面 输入内容
proxy_pass http://apache_server;
} 内置的符号 (ESC:wq) 保存退出
2号机#
#mount /dev/cdrom /mnt
#cd /etc/yum.repos.d/
#mv Centos-Base.repo Centos-Base.repo.bak
#vim Centos-Base.repo
[a]
baseurl=file:///mnt
gpgcheck=0 (ESC:wq)保存退出
#yum clean all
#yum -y install httpd
#echo "web.200.0.0.20" > /var/www/html/index.html
#systemctl start httpd
3号机#
#mount /dev/cdrom /mnt
#cd /etc/yum.repos.d/
#mv Centos-Base.repo Centos-Base.repo.bak
#vim Centos-Base.repo
[a]
baseurl=file:///mnt
gpgcheck=0 (ESC:wq)保存退出
#yum clean all
#yum -y install httpd
#echo "web.200.0.0.30" > /var/www/html/index.html
#systemctl start httpd
1号机#
在浏览器输入200.0.0.10 交互式出现2号机和三号的网页
构建负载均衡的Nginx集群
584

被折叠的 条评论
为什么被折叠?



