要求:
1、动静分离HTML交给Nginx本身去处理
2、客户端访问:www.bbb.com可以访问到博客
www.aaa.com可以访问的超市项目
本次实验需要9台虚拟机(不加DNS服务器)
添加DNS解析域名买一台服务器都需要加;在参考内容中有一样的命令无需 *** 作
echo ' 192.168.2.6 Slave1 192.168.2.7 Slave2 192.168.2.8 Master2 192.168.2.9 Master1 192.168.2.3 Monitor 192.168.2.10 bk 192.168.2.2 Tomcat 192.168.2.11 Nginx1 192.168.2.12 Nginx2 192.168.2.200 www.aaa.com 192.168.2.200 www.bbb.com'>> /etc/hosts
注意修改服务器名称
一、搭建mysql-mmm高可用群集参考:mysql-mmm高可用群集
搭建完成后测试主主复制主从复制
在 master1 上创建 user 库 mysql> create database user; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | user | +--------------------+ 5 rows in set (0.00 sec) ———————————————————————————————————————— master2 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | user | +--------------------+ 5 rows in set (0.00 sec) ———————————————————————————————————————— slave1 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | user | +--------------------+ 5 rows in set (0.00 sec) ———————————————————————————————————————— slave2 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | user | +--------------------+ 5 rows in set (0.00 sec) 在 Monitor 上查看状态 [root@monitor ~]# mmm_control show db1(192.168.2.9) master/ONLINE. Roles: writer(192.168.2.100) db2(192.168.2.8) master/ONLINE. Roles: db3(192.168.2.7) slave/ONLINE. Roles: reader(192.168.2.101) db4(192.168.2.6) slave/ONLINE. Roles: reader(192.168.2.102) 没有vip手动创建在mmm的文档中有二、部署超市项目和博客 1、部署博客
参考:Centos 7.4——LAMP架构分离部署+社区论坛部署
注意在参考内容中不做:(四)、安装phpMyAdmin
注意:授权用户和密码、和服务器地址
2、部署超市项目参考:Tomcat应用部署
使用:apache-tomcat-8.5.16.tar.gz 版本安装步骤相同
注意:指定的数据库地址
三、部署Ngixn高可用 1、安装nginx安装nginx参考:Nginx-简介及安装
注意:建议使用编译安装
Nginx1和Nginx2安装相同
配置ngixn后重启
ngixn1 配置 ———————————————————————————————————————————————————— vim /usr/local/nginx/conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { #虚拟主机1 listen 80; server_name www.ccc.com; location ~ .*.(html|htm|css)$ { root html; index index.html index.htm; } } server { #虚拟主机2 listen 80; server_name www.aaa.com; location / { proxy_pass http://192.168.2.2:8080/WebRoot; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } } server { #虚拟主机3 listen 80; server_name www.bbb.com; location / { proxy_pass http://192.168.2.10/sqlt/upload/forum.php; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } } } 保存 nginx -s reload ———————————————————————————————————————————————————————————————————————————————— ngixn2 配置 ————————————— vim /usr/local/nginx/conf/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { #虚拟主机1 listen 80; server_name www.ccc.com; location ~ .*.(html|htm|css)$ { root html; index index.html index.htm; } } server { #虚拟主机2 listen 80; server_name www.aaa.com; location / { proxy_pass http://192.168.2.2:8080/WebRoot; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } } server { #虚拟主机3 listen 80; server_name www.bbb.com; location / { proxy_pass http://192.168.2.10/sqlt/upload/forum.php; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } } } 保存 nginx -s reload2、keepalived高可用
在Nginx1和Nginx2 *** 作
安装及配置参考:七章——Keepalived双机热备(应用——linux防护与群集)
nginx高可用:只有nginx1宕机(或关机)VIP才会便宜到nginx2上
四、 测试注意:本机需要修改hosts文件:如192.168.2.200 www.aaa.com
访问 www.aaa.com 为超市管理系统
访问 www.bbb.com 是社区论坛
访问 www.ccc.com 是静态页面
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)