自動化運維管理平臺:
SQL> create user monmydb@localhost identified with mysql_native_password by XXXXX;
SQL> grant process on *.* to monmydb@localhost;
SQL> grant super on *.* to monmydb@localhost;
SQL> grant replication client on *.* to monmydb@localhost;
SQL> grant select on *.* to monmydb@localhost;
SQL>flush privileges;
SQL> show grants for monmydb@localhost;
percona-xtrabackup-2.4.7-Linux-x86_64.tar.gz
cd /mysql/dacp/mysql/mysqlbak/scripts
tar -zxvf percona-xtrabackup-2.4.7-Linux-x86_64.tar.gz
#!/bin/bash
Innobackupex_Path=/mysql/dacp/mysql/mysqlbak/scripts/percona-xtrabackup-2.4.7-Linux-x86_64/bin/xtrabackup
Mysql_Client=/mysql/dacp/mysql/soft/bin/mysql
Bak_Time=`date +%Y%m%d_%H%M%S`
Backup_Dir=/mysql/dacp/mysql/mysqlbak/data #備份主目錄
#Backup_Dir=/opt/backup/data/`data -I` #按日期生成備份主目錄
Fullbackup_Path=$Backup_Dir/full # 全庫備份的目錄
Incrbackup_Path=$Backup_Dir/incr # 增量備份的目錄
Log_Path=$Backup_Dir/logs #日志文件目錄
Keep_Fullbackup=2 #保留的全備份數量,此處要加1; 如要保留2個,此處要寫3
Mysql_Conf=/etc/my.cnf #mysql配置文件
export MYSQL_PWD=xxxxxxx
SOCK=/mysql/dacp/mysql/data/mysql.sock
Mysql_Opts="$Mysql_Client -s --host=localhost --user=root --password=$MYSQL_PWD -S$SOCK" #mysql的連接配置,按需修改
Error()
{
echo -e "e[1;31m$1e[0m" 1>&2
exit 1
}
Backup()
{
if [ $# = 2 ] ; then
$Innobackupex_Path --defaults-file=$Mysql_Conf -uroot -p$MYSQL_PWD --backup --parallel=3 --target-dir $1/full_$Bak_Time>$2 2>&1
elif [ $# = 3 ];then
$Innobackupex_Path --defaults-file=$Mysql_Conf -uroot -p$MYSQL_PWD --backup --target-dir $1/incr_$Bak_Time --incremental-basedir $2 >$3 2>&1
else
Error "Backup(): 參數不正確"
fi
}
Lastest_Dir()
{
if [ -d $1 ]; then
path=`ls -t $1 |head -n 1`
if [ $path ]; then
echo $path
else
Error "Lastest_Diri(): 目錄為空,沒有最新目錄"
fi
else
Error "Latest_Dir(): 目錄不存在或者不是目錄"
fi
}
Do_Inc()
{
if [ "$(ls -A $Incrbackup_Path)" ] ; then
Backup $Incrbackup_Path $Incrbackup_Path/`Lastest_Dir $Incrbackup_Path` $Log_Path/incr_$Bak_Time.log
else
Backup $Incrbackup_Path $Log_Path/incr_full_$Bak_Time.log
fi
}
Do_Full()
{
Backup $Fullbackup_Path $Log_Path/full_$Bak_Time.log
cd $Fullbackup_Path
ls -t |tail -n +$Keep_Fullbackup |xargs rm -rf
}
Check()
{
if [ ! -d $Fullbackup_Path ];then
mkdir -p $Fullbackup_Path
fi
if [ ! -d $Incrbackup_Path ];then
mkdir -p $Incrbackup_Path
fi
if [ ! -d $Log_Path ];then
mkdir -p $Log_Path
fi
if [ ! -f $Innobackupex_Path ];then
Error "未安裝xtradbbackup或xtradbbackup路徑不正確"
fi
if [ ! -f $Mysql_Client ];then
Error "未安裝mysql客戶端"
fi
if [ ! -f $Mysql_Conf ];then
Error "mysql配置文件路徑不正確"
fi
if [ `ps -ef |grep mysqld |grep -v grep |wc -l` = 0 ];then
Error "MySQL沒有運行"
fi
if ! `echo exit |$Mysql_Opts >/dev/null 2>&1` ; then
Error "提供的數據庫連接配置不正確!"
fi
}
case $1 in
full)
Check
Do_Full
;;
inc)
Check
Do_Inc
;;
*)
echo "full 全量備份"
echo "inc 增量備份"
;;
esac
腳本實現邏輯:
#!/bin/bash
unamesr="`uname -sr`"
case "$unamesr" in
AIX*)
AWK=awk
. $HOME/.profile
;;
SunOS 5*)
AWK=nawk
. $HOME/.profile
;;
HP*)
AWK=awk
. $HOME/.profile
;;
Linux*)
AWK=awk
. $HOME/.bash_profile
;;
esac
directory=$directory
sh_directory=$sh_directory
log_directory=$log_directory
user=$user
sudo su - $user < rm -rf $directory/mysqlbak/data/full/full*
rm -f ${log_directory}/*.log
EOF
tmp1=`df -mP |grep ${directory}|awk {print $4}`
tmp2=`df -mP |grep ${directory}|awk {print $3}`
if [[ ${tmp1} -gt ${tmp2} ]];then
echo "可執行備份"
sudo su - $user < sh $sh_directory/xtradump.sh full
EOF
sudo su - $user < cat ${log_directory}/*.log |grep completed OK |wc -l > /tmp/backup.log
chmod 775 /tmp/backup.log
EOF
backup=`cat /tmp/backup.log`
if [[ ${backup} = 1 ]];then
output=0
echo "備份成功"
else
output=1
echo "備份失敗,請檢查"
fi
else
echo "目錄空間不足,不可執行備份"
output=1
fi
exit 0
#!/bin/bash
data_directory="/mysql/dacp/mysql/mysqlbak/data/full"
sh_directory="/mysql/dacp/mysql/mysqlbak/scripts"
/usr/openv/netbackup/bin/bparchive -p MYSQL_DMP_ARC -s User_Archive -L $sh_directory/`date +%Y%m%d`.log -w $data_directory/full_*
find $sh_directory/ -name "*.log" -mtime +1 |xargs -i rm {}
#!/bin/bash
sh_directory="/mysql/dacp/mysql/mysqlbak/scripts"
ipa=`ip addr |grep inet|grep -v 127.0.0.1|grep -v inet6|awk {print $2}|tr -d "addr:"|grep 134.|head -n 1`
hostip=${ipa%/*}
cat $sh_directory/`date +%Y%m%d`.log|grep successfully |wc -l > /tmp/trscheck.log
check=`cat /tmp/trscheck.log`
if [[ ${check} = 1 ]];then
echo "$hostip `date +%F %T` 備份文件發送成功" >> $sh_directory/trscheck.log
else
cd $sh_directory
./mess.sh -b "`date +%F %T` $hostip ERROR: mysql備份文件發送失敗,請檢查 " -t 18974885939,15367933992
echo " `date +%F %T` $hostip mysql備份文件發送失敗,請檢查" >> $sh_directory/trscheck.log
fi
文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。
轉載請注明本文地址:http://specialneedsforspecialkids.com/yun/129242.html
摘要:是宜信公司大數據創新中心開發的開源平臺。為宜信大數據創新中心各個團隊提供了統一的測試和生產環境,簡化了服務的部署與上線流程,也降低了運維人員對系統管理的復雜度。基于容器技術,面向多樣化的技術棧,并且天然隔離系統和應用的依賴。 LAIN是宜信公司大數據創新中心開發的開源PaaS平臺。在金融的場景下,LAIN 是為解放各個團隊和業務線的生產力而設計的一個云平臺。LAIN 為宜信大數據創新中...
摘要:月日,極數云舟在北京互聯網金融中心重磅發布企業級云原生數據庫,致力于打造具有自主知識產權的核心數據庫產品,不斷推動中國數據庫產業的發展和提升國產化數據庫自主品牌國際影響力。是極數云舟基于思想自主研發的一款企業級云原生數據庫。4月19日,極數云舟在北京互聯網金融中心重磅發布企業級云原生數據庫ArkDB,致力于打造具有自主知識產權的核心數據庫產品,不斷推動中國數據庫產業的發展和提升國產化數據庫自...
摘要:基于云遷移的三個階段細分為八個主要步驟,評估階段主要包括項目啟動現狀梳理以及應用系統關聯關系分析三個步驟,設計階段包括云架構優化設計和云遷移方案設計,實施階段包括目標架構遷移演練及實施和試運行三個步驟。 在云計算市場規模不斷擴大的大背景下,云遷移的需求越來越大且面臨挑戰。云遷移不是一個遷移軟件工具,而是一種服務。前IBM資深架構師姜亞杰從云遷移的三個階段、四個維度到八個步驟的方法,簡述...
閱讀 1346·2023-01-11 13:20
閱讀 1684·2023-01-11 13:20
閱讀 1132·2023-01-11 13:20
閱讀 1858·2023-01-11 13:20
閱讀 4099·2023-01-11 13:20
閱讀 2704·2023-01-11 13:20
閱讀 1385·2023-01-11 13:20
閱讀 3594·2023-01-11 13:20