去年做啥网站致富,中小企业营销型网站建设,莆田网站建设,黑龙江省网站前置审批网站目录 一、集群搭建
1.复制3份Tomcat
2.测试Tomcat
3. 配置nginx.conf配置文件
二、keeplived
1.什么是keeplived
2.keeplived特点
3.下载和安装
3.1下载 3.2安装
3.3配置keeplived.conf配置文件
3.4测试 一、集群搭建
集群的主要目的是解决并发的问题。 1.复制3…目录 一、集群搭建
1.复制3份Tomcat
2.测试Tomcat
3. 配置nginx.conf配置文件
二、keeplived
1.什么是keeplived
2.keeplived特点
3.下载和安装
3.1下载 3.2安装
3.3配置keeplived.conf配置文件
3.4测试 一、集群搭建
集群的主要目的是解决并发的问题。 1.复制3份Tomcat 修改名字 mv apache-tomcat-8.5.45 apache-tomcat-1 复制tomcat cp -r apache-tomcat-1 ./apache-tomcat-2 修改每个tomcat的端口 在每个tomcat的webapps中创建test1文件夹 mkdir test1 创建index.html文件 2.测试Tomcat 复制三份tomcat 启动每个tomcat 并测试 启动 ./apache-tomcat-3/bin/startup.sh ./apache-tomcat-3/bin/startup.sh ./apache-tomcat-3/bin/startup.sh 测试 192.168.67.13:8081/test1/index.html 192.168.67.13:8082/test1/index.html 192.168.67.13:8083/test1/index.html 3. 配置nginx.conf配置文件
upstream clustertomcat{server 192.168.67.13:8081 weight5;server 192.168.67.13:8082 weight1;server 192.168.67.13:8083 weight1;}server {listen 80; server_name localhost;//注意配置所放的位置修改完后要重新加载nginx//./nginx -s reload#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;proxy_pass httP://clustertomcat;}}在linux服务下解决session共享的方式加入如ip_hash这样不同IP主机就访问同一个tomcat
upstream clustertomcat{server 192.168.67.13:8081 weight5;server 192.168.67.13:8082 weight1;server 192.168.67.13:8083 weight1;ip_hash;}server {listen 80; server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;location / {root html;index index.html index.htm;proxy_pass httP://clustertomcat;}}4.测试
http://192.168.67.13(配置的虚拟机IP)/test1/index.html
二、keeplived
1.什么是keeplived Keepalived是一个开源软件用于管理集群环境中的高可用性。它提供了一种通用的方法可以确保多个服务器中的一个称为“master”在任何时候都是活动的而其他服务器称为“backup”则处于备用状态。如果“master”服务器出现故障或无法访问Keepalived会自动将另一个服务器切换为“master”从而确保服务的连续性。 Keepalived主要基于VRRP虚拟路由冗余协议协议它允许多个路由器共享一个虚拟IP地址以提供故障转移和负载均衡。通过使用Keepalived可以将这种高可用性和负载均衡的机制应用于各种应用和服务如Web服务器、数据库服务器等。 除了故障转移和负载均衡外Keepalived还提供了其他功能如健康检查、监控和通知等。它可以定期检查服务器的健康状况如果发现故障或异常就会触发故障转移动作并发送通知给管理员。这些功能使得Keepalived成为构建可靠和高可用的集群环境的重要工具之一。 2.keeplived特点 Keepalived的主要特点包括 高可用性Keepalived通过将多个服务器组成一个集群确保了在任何时候都有一个服务器处于活动状态从而提供了高可用性。 自动故障转移如果活动服务器master出现故障或不可用Keepalived会自动将备用服务器backup切换为活动状态以确保服务的连续性。 负载均衡Keepalived基于VRRP协议实现了负载均衡功能可以将请求均匀地分发到集群中的各个服务器以提高性能和可扩展性。 健康检查Keepalived可以定期检查服务器的健康状况包括网络连接、服务运行状态等如果发现故障或异常就会触发故障转移。 监控和通知Keepalived可以监控服务器的状态并在发生故障时发送通知给管理员以便及时采取措施解决问题。 灵活配置Keepalived提供了灵活的配置选项可以根据需求进行定制和优化包括虚拟IP地址、优先级设置、故障检测参数等。 3.下载和安装
3.1下载
Keepalived for Linuxhttps://www.keepalived.org/download.html 下载相关组件 yum -y install openssl-devel
yum -y install libnl libnl-devel
yum install -y libnfnetlink-devel 3.2安装 yum install keepalived -y命令进行安装 启动keepalived服务 systemctl start keepalived 查看版本 keepalived -version 查看安装位置和配置文件的位置 rpm -ql keepalived 3.3配置keeplived.conf配置文件 使用yum安装的会有一个默认配置文件模板 路径为/etc/keepalived/keepalived.conf 可以根据实际情况修改修改完成之后需要重启keepalived服务 从配置主机不要忘记修改nginx的配置文件 upstream clustertomcat{ server 192.168.67.22:8080 weight5;数字越大优先级越高 server 192.168.67.22:8081 weight1; server 192.168.67.22:8082 weight1; ip_hash; } 3.4测试 启动 systemctl start keepalived 测试 http://192.168.67.222(配置的虚拟机IP)/test1/index.html