黑松山资源网 Design By www.paidiu.com

首先说明下我们的配置文件,都是类似格式的,假如内网是192.168.0.3,外网是123.123.123.123,配置文件如下:

$db['salver']['hostname'] = '192.168.0.3:3306';
//$db['salver']['hostname'] = '123.123.123.123:3306';

这个时候就是外网是注释的状态。走的是内网。
说下思路,就是一个配置文件,复制出来2分放到别的地方,这两份一个里面设置的是内网,一个里面设置的是外网,如果内网不通的情况下,判断当前用的是内网还是外网,如果是内网的情况下,就把外网的配置文件复制到网站文件里,如果内网通了,就把内网的配置文件再复制到网站文件里。就相当于是内网IP是主,外网IP是备一样。把这个脚本放在计划任务里,1分钟执行一次。

复制代码 代码如下:
#!/bin/bash
#主从数据库的内外网IP
master_IP_N=
master_IP_W=
salver_IP_N=
salver_IP_W=
#mongo的内外网IP
mongo_IP_W=
mongo_IP_N=
#redis的主从内外网IP
redis_master_IP_W=
redis_master_IP_N=
redis_slave_IP_W=
redis_slave_IP_N=
#sphinx的内外网IP
sphinx_IP_W=
sphinx_IP_N=
#网站配置文件的位置
database_path=/home/caoy/database.php
mongo_path=/home/caoy/over_sea_stock.php
redis_path=/home/caoy/Rediska_connector.php
sphinx_path=/home/caoy/SphinxConnector.php
config_path=/data/check_ip_config/
#检测当前使用的网卡
function check_ip(){
IP_config=`cat $1  |grep $2 | cut -c1-2`
if [ "$IP_config" == "//" ];then
        ip_status=1
else
        ip_status=0
fi
}
#判断内网网卡是否故障
function check_network(){
nmap -sP $1 | grep "1 host up" >/dev/null || (sleep 5 ; nmap -sP $1) | grep "1 host up" >/dev/null
#ping $1 -c 5 > /dev/null
if [[ "$?" == "1" ]]; then
        check_ip $database_path $1
        if [[ "$ip_status" == "0" ]];then
                cp -r $config_path/database_w.php $database_path
                echo "cp database_w.php is ok!"
        fi
        check_ip $mongo_path $1
        if [[ "$ip_status" == "0" ]];then
                cp -r $config_path/over_sea_stock_w.php $mongo_path
                echo "cp over_sea_stock_w.php is ok!"
        fi
        check_ip $redis_path $1
        if [[ "$ip_status" == "0" ]];then
                cp -r $config_path/Rediska_connector_w.php $redis_path
                echo "cp Rediska_connector_w.php is ok!"
        fi
        check_ip $sphinx_path $1
        if [[ "$ip_status" == "0" ]];then
                cp -r $config_path/SphinxConnector_w.php $sphinx_path
                echo "cp SphinxConnector_w.php is ok!"
        fi
else
        check_ip $database_path $1
        if [[ "$ip_status" == "1" ]];then
                cp -r $config_path/database_n.php $database_path
                echo "cp database_n.php is ok!"
        fi
        check_ip $mongo_path $1
        if [[ "$ip_status" == "1" ]];then
                cp -r $config_path/over_sea_stock_n.php $mongo_path
                echo "cp over_sea_stock_n.php is ok!"
        fi
        check_ip $redis_path $1
        if [[ "$ip_status" == "1" ]];then
                cp -r $config_path/Rediska_connector_n.php $redis_path
                echo "cp Rediska_connector_n.php is ok!"
        fi
        check_ip $sphinx_path $1
        if [[ "$ip_status" == "1" ]];then
                cp -r $config_path/SphinxConnector_n.php $sphinx_path
                echo "cp SphinxConnector_n.php is ok!"
        fi
fi
}
#检测各个网卡是否通畅
check_network $master_IP_N
check_network $salver_IP_N
check_network $mongo_IP_N
check_network $redis_master_IP_N
check_network $redis_slave_IP_N
check_network $sphinx_IP_N

黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com

P70系列延期,华为新旗舰将在下月发布

3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。

而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?

根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。