1 [root@k8s-master1 ~]# docker images 2 REPOSITORY TAG IMAGE ID CREATED SIZE 3 httpd latest 683a7aad17d3 4 months ago 138MB
1 [root@k8s-master1 ~]# curl 127.0.0.1:8080 2 <html><body><h1>It works!</h1></body></html> 3 [root@k8s-master1 ~]# curl 127.0.0.1:8081 4 <html><body><h1>It works!</h1></body></html>
[root@k8s-master1 ~]# docker exec -it http80 /bin/bash ……apache2# echo "This is 201:8080">/usr/local/apache2/htdocs/index.html ……apache2# exit
[root@k8s-master1 ~]# curl 127.0.0.1:8080 This is 201:8080 [root@k8s-master1 ~]# curl 127.0.0.1:8081 This is 201:8081
[root@k8s-master1 ~]# firewall-cmd --list-all FirewallD is not running
[root@CeOS7-64-1 ~]# curl 172.31.0.201:8080 This is 201:8080 [root@CeOS7-64-1 ~]# curl 172.31.0.201:8081 This is 201:8081
[root@OutGUI-Httpd-1 ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2021-05-20 00:21:15 CST; 3 days ago
[root@OutGUI-Httpd-1 ~]# ss -apn | grep httpd tcp LISTEN 0 128 *:80
[root@OutGUI-Httpd-1 ~]# curl 127.0.0.1 <h1 style="text-align:center;">Httpd,This is 135!</h1>
[root@GUI-HAporxy-1 ~]# firewall-cmd --add-port=8090/tcp success [root@GUI-HAporxy-1 ~]# firewall-cmd --add-port=8090/tcp --permanent success
frontend 20210424-test bind 172.31.0.137:8090 #监听端口已放行; # acl url_static path_beg -i /static /images /javascript /stylesheets # acl url_static path_end -i .jpg .gif .png .css .js use_backend 20210424-test # if url_static # default_backend app #--------------------------------------------------------------------- # static backend for serving up images, stylesheets and such #--------------------------------------------------------------------- backend 20210424-test balance roundrobin cookie ServID insert nocache # stick-table type ip size 5k expire 1m #取消粘滞会话保持; # stick on src # 2台主用服务器: server web135 172.31.0.135:80 cookie Serv135 weight 4 check inter 3s server web136 172.31.0.136:80 cookie Serv136 weight 2 check inter 3s # 以下是2台备用服务器: server web8080 172.31.0.201:8080 cookie Serv8080 weight 4 check inter 3s backup #备用服务器1; server web8081 172.31.0.201:8081 cookie Serv8081 weight 2 check inter 3s backup #备用服务器2;
[root@CeOS7-64-1 ~]# for i in {1..6};do curl 172.31.0.137:8090;done <h1 style="text-align:center;">Httpd,This is 135!</h1> <h1 style="text-align:center;">Httpd,This is 135!</h1> <h1 style="text-align:center;">Httpd,This is 136!</h1> <h1 style="text-align:center;">Httpd,This is 135!</h1> <h1 style="text-align:center;">Httpd,This is 135!</h1> <h1 style="text-align:center;">Httpd,This is 136!</h1>
[root@CeOS7-64-1 ~]# for i in {1..6};do curl 172.31.0.137:8090;done This is 201:8080 This is 201:8080 This is 201:8080 This is 201:8080 This is 201:8080 This is 201:8080
backend 20210424-test balance roundrobin cookie ServID insert nocache option allbackups #同时启用所有的备用服务器; # stick-table type ip size 5k expire 1m # stick on src server web135 172.31.0.135:80 cookie Serv135 weight 4 check inter 3s server web136 172.31.0.136:80 cookie Serv136 weight 2 check inter 3s server web8080 172.31.0.201:8080 cookie Serv8080 weight 4 check inter 3s backup server web8081 172.31.0.201:8081 cookie Serv8081 weight 2 check inter 3s backup
[root@CeOS7-64-1 ~]# for i in {1..6};do curl 172.31.0.137:8090;done This is 201:8080 This is 201:8080 This is 201:8081 This is 201:8080 This is 201:8080 This is 201:8081
原文:https://www.cnblogs.com/feifei6779/p/14907605.html