Sybase 資料庫啟停指令碼
Sybase 資料庫啟停指令碼
前言:上週五去機房給客戶部署Sybase ASE雙機熱備,最後在SUSE HA測試過程中,啟停指令碼出現一些問題,後來經過修改,問題解決。那天晚上在機房待到23:50分左右才離開,到家已經是凌晨1點多了,總結原因還是自己經驗不足,準備不充分。下面把在本地測試相關指令碼貼出來,供參考:
SYBASE:/home/huyong/sybase/scripts # vi sybase.sh
#!/bin/bash
statusSYBASE(){
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/showserver" |grep /home/huyong/sybase/ASE-15_0/bin/dataserver 1>/dev/null 2>&1
if [ $? -eq 0 ] ; then
return 0
else
return 1
fi
}
startSYBASE(){
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang" 1>/dev/null 2>&1
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS" 1>/dev/null 2>&1
declare -i startRETRY=0
while [ $startRETRY -lt 30 ] ; do
statusSYBASE
if [ $? -eq 0 ] ; then
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang" 1>/dev/null 2>&1
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS" 1>/dev/null 2>&1
return 0
fi
sleep 1
startRETRY=`expr $startRETRY + 1`
done
return 1
}
stopSYBASE(){
/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/dataserver >/dev/null 2>&1
/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/backupserver >/dev/null 2>&1
declare -i stopRETRY=0
while [ $stopRETRY -lt 30 ] ; do
su - huyong -c "isql -Usa -Phbang123 -Shbang <
use master
go
checkpoint
go
shutdown SYB_BACKUP
go
shutdown with nowait
go
exit
EOF" 1>/dev/null 2>&1
su - huyong -c "kill -9 `/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/dataserver |awk '{print $4}'`" 1>/dev/null 2>&1
su - huyong -c "kill -9 `/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/backupserver |awk '{print $4}'`" 1>/dev/null 2>&1
statusSYBASE
if [ $? -ne 0 ] ; then
return 0
fi
sleep 1
stopRETRY=`expr $stopRETRY + 1`
done
return 1
}
if [ $# -ne 1 ] ; then
echo "Usage $0 {start|stop|status}"
exit 123
fi
case $1 in
start)
startSYBASE
if [ $? -eq 0 ] ; then
echo "Start hbang Sybase succeed."
exit 0
else
echo "Start hbang Sybase failed!"
exit 1
fi
;;
stop)
statusSYBASE
if [ $? -ne 0 ] ; then
echo "hbang Sybase have been sopped."
exit 0
fi
stopSYBASE
if [ $? -eq 0 ] ; then
echo "Stop hbang Sybase succeed."
exit 0
else
echo "Stop hbang Sybase failed!"
exit 1
fi
;;
status)
statusSYBASE
if [ $? -eq 0 ] ; then
echo "hbang Sybase is running..."
exit 0
else
echo "hbang Sybase is dead!"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 123
;;
esac
測試過程如下:
--正常情況
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh status ;echo $?
SYBASE Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh start ;echo $?
Start SYBASE Sybase succeed.
0
前言:上週五去機房給客戶部署Sybase ASE雙機熱備,最後在SUSE HA測試過程中,啟停指令碼出現一些問題,後來經過修改,問題解決。那天晚上在機房待到23:50分左右才離開,到家已經是凌晨1點多了,總結原因還是自己經驗不足,準備不充分。下面把在本地測試相關指令碼貼出來,供參考:
SYBASE:/home/huyong/sybase/scripts # vi sybase.sh
#!/bin/bash
statusSYBASE(){
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/showserver" |grep /home/huyong/sybase/ASE-15_0/bin/dataserver 1>/dev/null 2>&1
if [ $? -eq 0 ] ; then
return 0
else
return 1
fi
}
startSYBASE(){
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang" 1>/dev/null 2>&1
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS" 1>/dev/null 2>&1
declare -i startRETRY=0
while [ $startRETRY -lt 30 ] ; do
statusSYBASE
if [ $? -eq 0 ] ; then
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang" 1>/dev/null 2>&1
su - huyong -c "/home/huyong/sybase/ASE-15_0/install/startserver -f /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS" 1>/dev/null 2>&1
return 0
fi
sleep 1
startRETRY=`expr $startRETRY + 1`
done
return 1
}
stopSYBASE(){
/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/dataserver >/dev/null 2>&1
/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/backupserver >/dev/null 2>&1
declare -i stopRETRY=0
while [ $stopRETRY -lt 30 ] ; do
su - huyong -c "isql -Usa -Phbang123 -Shbang <
use master
go
checkpoint
go
shutdown SYB_BACKUP
go
shutdown with nowait
go
exit
EOF" 1>/dev/null 2>&1
su - huyong -c "kill -9 `/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/dataserver |awk '{print $4}'`" 1>/dev/null 2>&1
su - huyong -c "kill -9 `/home/huyong/sybase/ASE-15_0/install/showserver|grep /home/huyong/sybase/ASE-15_0/bin/backupserver |awk '{print $4}'`" 1>/dev/null 2>&1
statusSYBASE
if [ $? -ne 0 ] ; then
return 0
fi
sleep 1
stopRETRY=`expr $stopRETRY + 1`
done
return 1
}
if [ $# -ne 1 ] ; then
echo "Usage $0 {start|stop|status}"
exit 123
fi
case $1 in
start)
startSYBASE
if [ $? -eq 0 ] ; then
echo "Start hbang Sybase succeed."
exit 0
else
echo "Start hbang Sybase failed!"
exit 1
fi
;;
stop)
statusSYBASE
if [ $? -ne 0 ] ; then
echo "hbang Sybase have been sopped."
exit 0
fi
stopSYBASE
if [ $? -eq 0 ] ; then
echo "Stop hbang Sybase succeed."
exit 0
else
echo "Stop hbang Sybase failed!"
exit 1
fi
;;
status)
statusSYBASE
if [ $? -eq 0 ] ; then
echo "hbang Sybase is running..."
exit 0
else
echo "hbang Sybase is dead!"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 123
;;
esac
測試過程如下:
--正常情況
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh status ;echo $?
SYBASE Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh start ;echo $?
Start SYBASE Sybase succeed.
0
SYBASE:/home/huyong/sybase/scripts # ps -ef|grep hbang
huyong 5538 1 0 11:04 ? 00:00:00 /bin/sh /home/huyong/sybase/ASE-15_0/install/RUN_hbang
huyong 5540 5538 80 11:04 ? 00:00:20 /home/huyong/sybase/ASE-15_0/bin/dataserver -d/home/huyong/sybase/data/master.dat -e/home/huyong/sybase/ASE-15_0/install/hbang.log -c/home/huyong/sybase/ASE-15_0/hbang.cfg -M/home/huyong/sybase/ASE-15_0 -shbang
huyong 5567 1 0 11:04 ? 00:00:00 /bin/sh /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS
huyong 5570 5567 0 11:04 ? 00:00:00 /home/huyong/sybase/ASE-15_0/bin/backupserver -e/home/huyong/sybase/ASE-15_0/install/hbang_BS.log -N25 -C20 -M/home/huyong/sybase/ASE-15_0/bin/sybmultbuf -Shbang_BS
root 5694 2426 0 11:04 pts/1 00:00:00 grep hbang
SYBASE:/home/huyong/sybase/scripts #
huyong 5538 1 0 11:04 ? 00:00:00 /bin/sh /home/huyong/sybase/ASE-15_0/install/RUN_hbang
huyong 5540 5538 80 11:04 ? 00:00:20 /home/huyong/sybase/ASE-15_0/bin/dataserver -d/home/huyong/sybase/data/master.dat -e/home/huyong/sybase/ASE-15_0/install/hbang.log -c/home/huyong/sybase/ASE-15_0/hbang.cfg -M/home/huyong/sybase/ASE-15_0 -shbang
huyong 5567 1 0 11:04 ? 00:00:00 /bin/sh /home/huyong/sybase/ASE-15_0/install/RUN_hbang_BS
huyong 5570 5567 0 11:04 ? 00:00:00 /home/huyong/sybase/ASE-15_0/bin/backupserver -e/home/huyong/sybase/ASE-15_0/install/hbang_BS.log -N25 -C20 -M/home/huyong/sybase/ASE-15_0/bin/sybmultbuf -Shbang_BS
root 5694 2426 0 11:04 pts/1 00:00:00 grep hbang
SYBASE:/home/huyong/sybase/scripts #
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh stop ;echo $?
Stop SYBASE Sybase succeed.
0
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh status ;echo $?
SYBASE Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ps -ef|grep hbang
root 6002 2426 0 11:05 pts/1 00:00:00 grep hbang
SYBASE:/home/huyong/sybase/scripts #
Stop SYBASE Sybase succeed.
0
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh status ;echo $?
SYBASE Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ps -ef|grep hbang
root 6002 2426 0 11:05 pts/1 00:00:00 grep hbang
SYBASE:/home/huyong/sybase/scripts #
--異常情況
huyong@SYBASE:~/sybase> pwd
/home/huyong/sybase
huyong@SYBASE:~/sybase> mv data/ data.dat --啟動之前模擬資料檔案丟失
huyong@SYBASE:~/sybase> pwd
/home/huyong/sybase
huyong@SYBASE:~/sybase> mv data/ data.dat --啟動之前模擬資料檔案丟失
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh status ;echo $?
hbang Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh start ;echo $?
Start hbang Sybase failed!
1
-------END-------------
hbang Sybase is dead!
1
SYBASE:/home/huyong/sybase/scripts # ./sybase.sh start ;echo $?
Start hbang Sybase failed!
1
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29634949/viewspace-1715892/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Sybase資料庫安全資料庫
- sybase資料庫恢復資料庫
- Tomcat的啟停指令碼原始碼解析Tomcat指令碼原始碼
- Linu部署服務啟停指令碼指令碼
- 大資料叢集服務啟停指令碼/常用埠/時間同步大資料指令碼
- 啟停無線網路卡bat指令碼BAT指令碼
- Sybase 常用指令
- 4.1.3 使用 Oracle Restart 元件啟停資料庫OracleREST元件資料庫
- Sybase ASE資料庫恢復,Sybase資料恢復,資料誤刪除恢復工具READSYBDEVICE資料庫資料恢復dev
- SYBASE資料庫dbcc命令詳解(zt)資料庫
- 資料庫備份指令碼資料庫指令碼
- ORACLE 12C RAC資料庫的啟停Oracle資料庫
- 教小白搭建sybase資料庫環境資料庫
- Sybase或SQLServer資料庫分批歸檔方案SQLServer資料庫
- 呼叫中心資料入庫指令碼指令碼
- MySQL匯出資料庫指令碼MySql資料庫指令碼
- mssql生成資料庫字典指令碼-MarkDownSQL資料庫指令碼
- Flyway版本化管理資料庫指令碼資料庫指令碼
- 針對Sybase資料庫無法啟動的情況,我有話要說資料庫
- 【SCRIPT】Oracle資料庫基本資訊收集指令碼Oracle資料庫指令碼
- MySQL資料庫備份的shell指令碼MySql資料庫指令碼
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- oracle 資料庫徹底清除目錄指令碼Oracle資料庫指令碼
- Bash 指令碼安裝 MySQL-8.0.20 資料庫指令碼MySql資料庫
- 通過shell指令碼批量操作mysql資料庫指令碼MySql資料庫
- Liunx備份mysql資料庫的shell指令碼MySql資料庫指令碼
- python 建立mysql資料庫腳(執行sql)指令碼程式碼PythonMySql資料庫指令碼
- sqlserver資料庫還原儲存過程指令碼SQLServer資料庫儲存過程指令碼
- Shell多執行緒備份資料庫的指令碼執行緒資料庫指令碼
- mssql sqlserver 使用sql指令碼 清空所有資料庫表資料的方法分享SQLServer指令碼資料庫
- 補錄資料指令碼指令碼
- Sybase SQL Anywhere(ASA)資料庫恢復,ASA資料恢復,資料誤刪除恢復工具ReadASADBSQL資料庫資料恢復
- SQL Server2019資料庫備份與還原指令碼,資料庫可批量備份SQLServer資料庫指令碼
- openresty+redis配合 lua指令碼封停 IPRESTRedis指令碼
- 一種SYBASE資料庫錯誤DBSQL_SQL_ERROR的解決方式資料庫SQLError
- redis-13.資料庫通用指令Redis資料庫
- 自動定時備份 mysql 資料庫 的 shell 指令碼MySql資料庫指令碼
- 資料庫建表和上線指令碼常見規範資料庫指令碼
- MOGDB/openGauss資料庫gs_dump備份指令碼及清理資料庫指令碼