方法:可以利用crontab跑计划任务,也可以用shell脚本去执行icontrol来调用不同的pool,实现维护页面和正常页面的切换
1) 根据icontrol的API,创建XML请求的文件,soapreq_install_pool.txt为切换到维护页面
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:set_default_pool_name xmlns:m="urn:iControl:LocalLB/VirtualServer">
<virtual_servers type="tns:Common.StringSequence">
<virtual_server>web_vs</virtual_server>
</virtual_servers>
<default_pools type="tns:Common.StringSequence">
<default_pool>install_pool</default_pool>
</default_pools>
</m:set_default_pool_name>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
soapreq_web_pool.txt为切换到正常页面
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<m:set_default_pool_name xmlns:m="urn:iControl:LocalLB/VirtualServer">
<virtual_servers type="tns:Common.StringSequence">
<virtual_server>web_vs</virtual_server>
</virtual_servers>
<default_pools type="tns:Common.StringSequence">
<default_pool>web_pool</default_pool>
</default_pools>
</m:set_default_pool_name>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
2) 创建定时执行的shell脚本,autosetpool.sh,1点切换到维护页面,5点切换到正常页面,30秒执行一次循环。
while true; do
A=`date -d "1 minute" +%Y%m%d%H%M`
if [ $A -eq '201103200100' ]; then
curl --data-binary @soapreq_install_pool.txt https://admin:[email protected]/iControl/iControlPortal.cgi --insecure
elif [ $A -eq '201103200500' ]; then
curl --data-binary @soapreq_web_pool.txt https:// admin:[email protected]/iControl/iControlPortal.cgi --insecure
fi
sleep 30
done
3)设置后台执行脚本,不挂断的运行命令,
nohup ./autosetpool.sh >/dev/null 2>&1 &