centos7安裝nacos集群


nacos的集群,需要后端的nginx代理,nginx需要做高可用,安裝keepalived做vip,mysql需要做主從配置

 nginx與keepalied的安裝,

yum -y install nginx keepalived

keepalied的配置

在主的配置

[root@lb01 keepalived]# ls
keepalived.conf keepalived.conf.bak keepalived.conf.bak01 nginx_check.sh

yunwei01-[root@yunwei01 keepalived]# cat keepalived.conf
global_defs {
router_id nginx_001
}

vrrp_script chk_nginx {
script "/etc/keepalived/nginx_check.sh"
interval 2
weight -20
}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 101
unicast_src_ip 192.168.174.174
unicast_peer {
192.168.174.90
}
priority 250
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.174.254
}
track_script {
chk_nginx
}
}

[root@lb01 keepalived]# cat nginx_check.sh
#!/bin/bash
A=`ps -C nginx --no-header | wc -l`
if [ $A -eq 0 ];then
systemctl start nginx #嘗試重新啟動nginx
sleep 2 #睡眠2秒
if [ `ps -C nginx --no-header | wc -l` -eq 0 ];then
#killall keepalived #啟動失敗,將keepalived服務殺死。將vip漂移到其它備份節點
systemctl stop keepalived #啟動失敗,將keepalived服務殺死。將vip漂移到其它備份節點
fi
fi

 

在備節點

[root@lb02 keepalived]# cat keepalived.conf
global_defs {
router_id nginx_001
}

vrrp_script chk_nginx {
script "/etc/keepalived/nginx_check.sh"
interval 2
weight -20
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 101
unicast_src_ip 192.168.174.90
unicast_peer {
192.168.174.174
}
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.174.254
}
track_script {
chk_nginx
}
}

[root@lb02 keepalived]# cat nginx_check.sh
#!/bin/bash
A=`ps -C nginx --no-header | wc -l`
if [ $A -eq 0 ];then
systemctl start nginx #嘗試重新啟動nginx
sleep 2 #睡眠2秒
if [ `ps -C nginx --no-header | wc -l` -eq 0 ];then
#killall keepalived #啟動失敗,將keepalived服務殺死。將vip漂移到其它備份節點
systemctl stop keepalived #啟動失敗,將keepalived服務殺死。將vip漂移到其它備份節點
fi
fi

啟動服務

systemctl restart keepalived

systemctl enable keepalived

 

主和備的nginx都配置

[root@lb02 conf.d]# cat tps-nacos.conf
upstream nacos{
server 192.168.174.87:8848;
server 192.168.174.88:8848;
server 192.168.174.99:8848;
}
server {
listen 8080;
server_name localhost;
index index.html;
location /{
proxy_pass http://nacos;
}
}

 

啟動nginx

systemctl restart nginx

systemctl enable nginx

 

naocs的安裝請見博客的https://www.cnblogs.com/hao-guo/p/12673841.html

mysql的安裝和主從的配置https://www.cnblogs.com/hao-guo/p/12557408.htmlhttps://www.cnblogs.com/hao-guo/p/12780169.html

不過naocs都要的cluster.conf需要配置

192.168.174.87:8848
192.168.174.88:8848
192.168.174.99:8848

 

導入sql文件后,直接訪問http://192.168.174.254:8080/nacos/,

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM