标签:virtual port ogr ctrl data ble centos6.5 www ctr
Keepalived+Nginx+tomcat实现系统的高可用
解压tomcat到/usr/local
配置tomcat的首页
vim /usr/local/apache-tomcat-7.0.84/webapps/ROOT/index.jsp
配置防火墙
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
启动tomcat
/usr/local/apache-tomcat-7.0.84/bin/startup.sh
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure&&make&&make install
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure&&make&&make install
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
./config --prefix=/usr/local/openssl && make && make install
cd /usr/local
wget http://nginx.org/download/nginx-1.9.0.tar.gz
或curl -O http://nginx.org/download/nginx-1.9.0.tar.gz . 下载
tar -zxvf nginx-1.9.0.tar.gz
cd nginx-1.9.0
./configure && make && make install
#相当于 先执行./configure 再执行make 最后执行make install
配置nginx反向代理两个tomcat服务器
vim /usr/local/nginx/conf/nginx.conf
1)配置location和里面的proxy_pass
2)配置upstream
3)将配置文件发送到另外一个nginx服务器上去,使用scp命令
scp /usr/local/nginx/conf/nginx.conf root@192.168.182.129:/usr/local/nginx/conf/
启动/usr/local/nginx/sbin/nginx
重启nginx的命令/usr/local/nginx/sbin/nginx -s reload
nginx的访问日志
tail -f /usr/local/nginx/logs/access.log
下载地址:https://pan.baidu.com/s/1G7sLL-YkZGSMu8G76yz1Rw 密码:adbw
./configure --prefix=/data/program/keepalived --sysconf=/etc
make && make install
或者通过yum安装keepalived
yum install keepalived -y
1)编辑keepalived配置文件
vim /etc/keepalived/keepalived.conf
--------------------------------------------------------------------------------------------------------
vrrp_instance VI_1 {
state MASTER # 配置为主MASTER为主,BACKUP为备
interface eno16777736 # 设置网卡
virtual_router_id 51 # 虚拟路由ID,全局唯一
priority 100 # 优先级,权重值
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.10.10.50 # VIP地址
}
}
---------------------------------------------------------------------------------------------------------
2)配置防火墙让keepalived可以组播进行心跳检测
centos 6下面修改防火墙
vi /etc/sysconfig/iptables
-A INPUT -p vrrp -d 192.168.182.128 -j ACCEPT
-A INPUT -p vrrp -d 192.168.182.129 -j ACCEPT
-A INPUT -p 112 -d 192.168.182.128 -j ACCEPT
-A INPUT -p 112 -d 192.168.182.129 -j ACCEPT
注意很多网上的会加上-i参数,-i表示你的网卡,比如-i eth0表示eth0这个网卡
#-p 112指定协议为112,也可-p vrrp即vrrp
centos7下面改防火墙
firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --in-interface enp4s0 --destination 192.168.182.128 --protocol vrrp -j ACCEPT
firewall-cmd --reload
启动keepalived
/etc/init.d/keepalived start
重启
/etc/init.d/keepalived restart
关闭keepalived
/etc/init.d/keepalived stop
查看keepalived的运行日志
tail -f /var/log/messages
查看keepalived进程
ps aux|grep keepalived
nginx支持大概每秒1万的并发,如果超过1万的并发的,就需要使用其他的方式来实现高可用了,比如:
LVS+Keepalived+Nginx
F5+Nginx
Vim复制一整行和复制多行
1、复制
1)单行复制
在命令模式下,将光标移动到将要复制的行处,按“yy”进行复制;
2)多行复制 在命令模式下,将光标移动到将要复制的首行处,按“nyy”复制n行;其中n为1、2、3……
2、粘贴
在命令模式下,将光标移动到将要粘贴的行处,按“p”进行粘贴
dd表示删除一行
u 撤销上一步的操作
Ctrl+r 恢复上一步被撤销的操作
vim跳到页首gg,跳到页尾G
跳到行首0,调到行尾$
重启防火墙
/etc/init.d/iptables restart
查看网卡上的ip地址
ip a show eth0
ip a show eth1
配置selinux
vim /etc/selinux/config
SELINUX=disabled #将该配置改为disabled,保存退出后reboot
Keepalived+Nginx+tomcat实现系统的高可用
标签:virtual port ogr ctrl data ble centos6.5 www ctr
原文地址:https://www.cnblogs.com/mkl34367803/p/10211628.html