shell监控脚本实例—监控mysql主从复制 分享一例shell脚本,用于监测mysql数据库的主从复制,有需要的朋友不妨参考学习下。 转自:http://www.jbxue.com/article/14103.html(转载请注明出处) 本节内容: 监控mysql主从复制的shell脚本。 说明: 监控脚本在 r
shell监控脚本实例—监控mysql主从复制分享一例shell脚本,用于监测mysql数据库的主从复制,有需要的朋友不妨参考学习下。
转自:http://www.jbxue.com/article/14103.html(转载请注明出处)
本节内容:
监控mysql主从复制的shell脚本。
说明:
监控脚本在 rhel5 下测试正常,其它版本的linux 系统请自行测试。
代码:?
复制代码代码如下: #监控mysql 主从复制cat chk_mysql_rep.sh?
#!/bin/bash?
#?
#script_name:chk_mysql_rep.sh?
#check mysql replication?
#?
#ssh root@xen "/usr/local/mysql/bin/mysql -uroot -pdongnan -e 'show slave status\G' -ss" | awk '/Running:/ {print $2}'?
#Yes?
#Yes?
#?
#variables?
ssh=/usr/bin/ssh?
sh_dir=/root/sh/?
crondir=${sh_dir}crontab?
source ${sh_dir}CONFIG?
hosts="$DB_SLAVE_HOSTS"
#main?
#主循环遍历机器 www.jbxue.com
for HOST in $hosts;do?
log=$crondir/log/mysql_replication_error.log?
key=$($ssh root@$HOST "/usr/local/mysql/bin/mysql -uroot -pdongnan -e 'show slave status\G' -ss" | awk '/Running:/ {printf $2}')?
??? #无法连接的主机,跳过本次循环?
??? test -z "$key" && continue?
??? #返回结果真?
??? if [ "$key" == "YesYes" ];then?
??????? #flag真,解除报警?
??????? if [ -f "${crondir}/log/$HOST.mysql" ];then?
??????????? #sms?
??????????? #for mobile in $MOBILES;do?
??????????????? #echo "$HOST replication ok" | /usr/local/bin/gammu --sendsms TEXT "$mobile" -unicode?
??????????? #done?
??????????? #mail?
??????????? for mail in $MAILS;do?
??????????????? echo "$HOST replication ok" | mail -s "$HOST replication ok" $mail?
??????????? done?
??????????? #flag?
??????????? rm -f "${crondir}/log/$HOST.mysql"?
??????? fi?
??? #返回结果假?
??? else???
check_date=$(date '+ %F %T')?
??????? #flag假,报警?
??????? if [ ! -f "${crondir}/log/$HOST.mysql" ];then?
??????????? #sms www.jbxue.com
??????????? #for mobile in $MOBILES;do?
??????????????? #echo "$HOST replication error" | /usr/local/bin/gammu --sendsms TEXT "$mobile" -unicode?
??????????? #done?
??????????? #mail?
??????????? for mail in $MAILS;do?
??????????????? echo "$HOST replication error" | mail -s "$HOST replication error" $mail?
??????????? done?
??????????? #flag?
??????????? echo "replication error" >"${crondir}/log/$HOST.mysql"?
??????????? #log?
??????????? echo "$check_date $HOST mysql replicaton error" >> $log?
??????? fi?
??? fi?
#?
done?
#

mysqlblobshavelimits:tinyblob(255bytes),blob(65,535 bytes),中間佈洛布(16,777,215個比例),andlongblob(4,294,967,967,295 bytes).tousebl觀察:1)考慮pperformance impactsandSandStorLageBlobSextern; 2)管理backbackupsandreplication carecration; 3)usepathsinst

自動化在MySQL中創建用戶的最佳工具和技術包括:1.MySQLWorkbench,適用於小型到中型環境,易於使用但資源消耗大;2.Ansible,適用於多服務器環境,簡單但學習曲線陡峭;3.自定義Python腳本,靈活但需確保腳本安全性;4.Puppet和Chef,適用於大規模環境,複雜但可擴展。選擇時需考慮規模、學習曲線和集成需求。

是的,YouCansearchInIdeAblobInMysqlusingsPecificteChniques.1)轉換theblobtoautf-8StringWithConvertFunctionWithConvertFunctionandSearchUsiseLike.2)forCompresseBlysBlobs,useuncompresseblobs,useuncompressbeforeconversion.3)expperformance impperformance imptactSandDataEcoding.4)

mysqloffersvariousStringDatatYpes:1)charforfixed Lengtth Strings,IdealforConsistLengthDatalikeCountryCodes; 2)varcharforvariable長度長,合適的forfieldslikenames; 3)texttypefesforepesforlargertext,forforlargertext,goodforforblogblogpostsbutcan impactcuctcuctcuctpercrance; 4)biland;

tomasterMysqlblobs,關注台詞:1)ChooseTheApprProbType(tinyBlob,blob,blob,Mediumblob,longblob)基於dongatasize.2)InsertDatausingload_fileforefice.3)

blobdatatypesinmysqlareusedforvorvoringlargebinarydatalikeimagesoraudio.1)useblobtypes(tinyblobtolonglongblob)基於dondatasizeneeds。 2)庫孔素pet petooptimize績效。 3)考慮Xternal Storage Forel Blob romana databasesizerIndimprovebackupe

toadDuserStomySqlfromtheCommandline,loginasroot,thenusecreateuser'username'@'host'host'Indessifiedby'password'; tocreateanewuser.grantpermissionswithgrantprantallprivilegesondatabase

mySqlofferSeightStringDatateTypes:char,varchar,二進制,二進制,varbinary,blob,文本,枚舉,枚舉和set.1)長度,理想的forconsistentDatatalIkeCountryCodes.2)varcharisvariable長度,長度,效率foriforitifforiticforiticforiticforiticforiticforitic forvaryingdatalikename.3)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

SublimeText3漢化版
中文版,非常好用

SublimeText3 Linux新版
SublimeText3 Linux最新版

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器