加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server_check.sh 21.75 KB
一键复制 编辑 原始数据 按行查看 历史
gohou 提交于 2024-01-31 20:53 . 新修改删除共享的函数
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
#!/usr/bin/env bash
set -e
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# Function :CentOS7.X Mysql/Oracle 服务检查
# Platform :RedHatEL7.x Based Platform
# Version :1.01
# Date :2023-11-04
# Author :mugoLH
# Contact :hxsaj@126.com
# Company :
# depend on:
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# 脚本引用 Import the script
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# 变量列表 List of common variables
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
v_time=$(date "+%Y-%m-%d %H:%M:%S")
v_path=$(pwd)
# 函数列表 Function list
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# 提示
info_p(){ printf "\t\e[1;32;40m%-12s %-1s\n\e[0m" "${1}" "${2}" >&1 ;}
tips_p(){ printf "\t\e[1;36;40m%-5s %-1s\n\e[0m" "${1}" "${2}" >&1 ;}
error_p(){ printf "\t\e[1;35;40m%-12s %-1s\n\e[0m" "${1}" "${2}" >&1 ;}
#【主菜单】
main_menu(){
info_p " 安 装 检 查 主 菜 单 "
info_p "【1】- oracle服务器检查"
info_p "【2】- oracle数据库检查"
info_p "【3】- mysql服务器检查"
info_p "【4】- mysql数据库检查"
info_p "【5】- 退 出 脚 本"
}
#【oracle服务器检查菜单】
ora_mich_ck(){
info_p " oracle服务器检查 "
info_p "【1】- 磁盘性能检查"
info_p "【2】- 服务器参数检查"
info_p "【3】- 磁盘空间检查"
info_p "【4】- 时钟检查"
info_p "【5】- 返 回 主 菜 单"
}
#【oracle数据库检查菜单】
ora_db_ck(){
info_p " oracle数据库检查 "
info_p "【1】- 数据库字符集检查 "
info_p "【2】- 内存参数检查 "
info_p "【3】- 日志大小检查 "
info_p "【4】- 进程大小检查 "
info_p "【5】- 会话数大小检查 "
info_p "【6】- 归档日志是否打开检查 "
info_p "【7】- 返 回 主 菜 单 "
}
#【mysql服务器检查菜单】
mysql_mich_ck(){
info_p " Mysql服务器检查 "
info_p "【1】- 磁盘性能检查"
info_p "【2】- 磁盘空间检查"
info_p "【3】- 时钟检查"
info_p "【4】- 返 回 主 菜 单"
}
#【mysql数据库检查菜单】
mysql_db_ck(){
info_p " Mysql服务器检查 "
info_p "【1】- 磁盘性能检查"
info_p "【2】- 磁盘空间检查"
info_p "【3】- 时钟检查"
info_p "【4】- 返 回 主 菜 单"
}
#【函数:磁盘性能检查】
disk_performance(){
info_p " ************磁盘性能检查结果************* "
info_p "******提示:一般性能磁盘测试需五分钟*****"
info_p "【2】- 磁盘空间检查"
info_p "【3】- 时钟检查"
info_p "【4】- 返 回 主 菜 单"
echo -e "\e[43;34m \t\t\t************磁盘性能检查结果*************\t\t\t \e[0m"
echo "******提示:一般性能磁盘测试需五分钟*****"
echo "dd bs=32k count=20k if=/dev/zero of=test oflag=dsync" > ${v_path}/test_disk.sh
chmod +x ${v_path}/test_disk.sh
nohup ${v_path}/test_disk.sh &
sleep 300
if [ ! -s "${v_path}/nohup.out" ]; then
echo "磁盘性能较差,测试中...耐性等待"
sleep 600
if [ ! -s "${v_path}/nohup.out" ]; then
echo "磁盘性能太差,测试中...耐性等待"
sleep 600
if [ ! -s "${v_path}/nohup.out" ]; then
echo "建议更换磁盘"
exit
else
disk_speed=`cat ${v_path}/nohup.out|tail -1|awk -F\MB '{print $2}'|awk '{print $NF}'|grep -Eo '[0-9.]+'|awk '{print int($0)}'`
if [ ${disk_speed} -lt 2 ];then
echo "磁盘的写性能太差,实时值为${disk_speed}MB/秒,会严重影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 2 ] && [ ${disk_speed} -lt 6 ];then
echo "磁盘的写性能较差,实时值为${disk_speed}MB/秒,会影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 6 ] && [ ${disk_speed} -lt 12 ];then
echo "磁盘的写性能一般,实时值为${disk_speed}MB/秒"
else
echo "磁盘的写性能良好,实时值为${disk_speed}MB/秒"
fi
fi
else
disk_speed=`cat ${v_path}/nohup.out|tail -1|awk -F\MB '{print $2}'|awk '{print $NF}'|grep -Eo '[0-9.]+'|awk '{print int($0)}'`
if [ ${disk_speed} -lt 2 ];then
echo "磁盘的写性能太差,实时值为${disk_speed}MB/秒,会严重影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 2 ] && [ ${disk_speed} -lt 6 ];then
echo "磁盘的写性能较差,实时值为${disk_speed}MB/秒,会影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 6 ] && [ ${disk_speed} -lt 12 ];then
echo "磁盘的写性能一般,实时值为${disk_speed}MB/秒"
else
echo "磁盘的写性能良好,实时值为${disk_speed}MB/秒"
fi
fi
else
disk_speed=`cat ${v_path}/nohup.out|tail -1|awk -F\MB '{print $2}'|awk '{print $NF}'|grep -Eo '[0-9.]+'|awk '{print int($0)}'`
if [ ${disk_speed} -lt 2 ];then
echo "磁盘的写性能太差,实时值为${disk_speed}MB/秒,会严重影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 2 ] && [ ${disk_speed} -lt 6 ];then
echo "磁盘的写性能较差,实时值为${disk_speed}MB/秒,会影响数据加载和流的运行,建议升级硬件或者再次测试"
elif [ ${disk_speed} -gt 6 ] && [ ${disk_speed} -lt 12 ];then
echo "磁盘的写性能一般,实时值为${disk_speed}MB/秒"
else
echo "磁盘的写性能良好,实时值为${disk_speed}MB/秒"
fi
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle服务器参数检查】
ora_mic_parm(){
echo -e "\e[43;34m \t\t\t/etc/security/limits.conf服务器参数检查结果\t\t\t \e[0m"
#oracle_soft_nproc检查
oracle_soft_nproc=`grep oracle /etc/security/limits.conf|grep soft|grep nproc|awk '{print $4}'`
#oracle_hard_nproc检查
oracle_hard_nproc=`grep oracle /etc/security/limits.conf|grep hard|grep nproc|awk '{print $4}'`
#oracle_soft_nofile检查
oracle_soft_nofile=`grep oracle /etc/security/limits.conf|grep soft|grep nofile|awk '{print $4}'`
#oracle_hard_nofile检查
oracle_hard_nofile=`grep oracle /etc/security/limits.conf|grep hard|grep nofile|awk '{print $4}'`
if [ ${oracle_soft_nproc} -lt 16384 ];then
echo "/etc/security/limits.conf里面oracle soft nproc 建议设置为16384或者65536"
else
echo "/etc/security/limits.conf里面oracle soft nproc 设置正常"
fi
if [ ${oracle_hard_nproc} -lt 16384 ];then
echo "/etc/security/limits.conf里面oracle hard nproc 建议设置为16384或者65536"
else
echo "/etc/security/limits.conf里面oracle hard nproc 设置正常"
fi
if [ ${oracle_soft_nofile} -lt 65536 ];then
echo "/etc/security/limits.conf里面oracle soft nofile 建议设置为65536"
else
echo "/etc/security/limits.conf里面oracle soft nofile 设置正常"
fi
if [ ${oracle_hard_nofile} -lt 65536 ];then
echo "/etc/security/limits.conf里面oracle hard nofile 建议设置为65536"
else
echo "/etc/security/limits.conf里面oracle hard nofile 设置正常"
fi
echo -e "\e[43;34m \t\t\t/etc/sysctl.conf服务器参数检查结果\t\t\t \e[0m"
fs_aio_max_nr=`grep fs.aio-max-nr /etc/sysctl.conf|awk -F\= '{print $2}'`
fs_file_max=`grep fs.file-max /etc/sysctl.conf|awk -F\= '{print $2}'`
kernel_shmall=`grep kernel.shmall /etc/sysctl.conf|awk -F\= '{print $2}'`
kernel_shmmax=`grep kernel.shmmax /etc/sysctl.conf|awk -F\= '{print $2}'`
MEM_TOTAL=`grep MemTotal /proc/meminfo | awk '{print $2}'`
PAGE_SIZE=`getconf PAGE_SIZE`
SHMALL=$(echo "$MEM_TOTAL * 1024 * 1024 / ${PAGE_SIZE}"| bc)
shmmax_min_temp=$(echo "${MEM_TOTAL} * 1024 * 1024 *0.5"| bc)
shmmax_min=`echo ${shmmax_min_temp}|awk '{print int($0)}'`
shmmax_max=$(echo "${MEM_TOTAL} * 1024 * 1024"| bc)
if [ ${fs_aio_max_nr} -ne 1048576 ];then
echo "/etc/sysctl.conf里面fs.aio-max-nr 建议设置为1048576"
else
echo "/etc/sysctl.conf里面fs.aio-max-nr 设置正常"
fi
if [ ${fs_file_max} -ne 6815744 ];then
echo "/etc/sysctl.conf里面fs.file-max 建议设置为6815744"
else
echo "/etc/sysctl.conf里面fs.file-max 设置正常"
fi
if [ ${kernel_shmall} -ne ${SHMALL} ];then
echo "/etc/sysctl.conf里面kernel.shmall 建议设置为${SHMALL}\t\t\t \e[0m"
else
echo -e "\e[43;34m \t\t\t/etc/sysctl.conf里面kernel.shmall 设置正常\t\t\t \e[0m"
fi
if [ ${kernel_shmmax} -gt ${shmmax_min} ] && [ ${kernel_shmmax} -lt ${shmmax_max} ];then
echo -e "\e[43;34m \t\t\t/etc/sysctl.conf里面kernel.shmmax 设置正常\t\t\t \e[0m"
else
echo -e "\e[43;34m \t\t\t/etc/sysctl.conf里面kernel.shmmax 建议设置为${shmmax_min}-${shmmax_max}之间\t\t\t \e[0m"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:磁盘空间】
disk_space_check(){
echo -e "\e[43;34m \t\t\t磁盘空间值检查结果\t\t\t \e[0m"
THRESHOLD=85
# 获取磁盘使用率
disk_usage=`df -h | awk '{print $5}' | grep -v Use |grep -v 已用| sed 's/%//g'`
[ -f ${v_path}/disk_space.txt ]&& rm -rf ${v_path}/disk_space.txt
# 循环检查每个磁盘使用率
for usage in $disk_usage; do
if [ $usage -gt $THRESHOLD ]; then
echo "有磁盘使用率超过${THRESHOLD}%,请注意,使用df -h命令检查" >>${v_path}/disk_space.txt
fi
done
if [ ! -s "${v_path}/disk_space.txt" ];then
echo "磁盘空间均小于85%,正常"
else
cat ${v_path}/disk_space.txt
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:时钟】
check_clock(){
echo -e "\e[43;34m \t\t\t时钟检查结果\t\t\t \e[0m"
echo "请检查当前的服务器的时间与北京时间是否一致,是否是 `date`
如果不一致,请使用root用户,date -s调整;
另外,请注意检查DS服务器和应用服务器,是否三台服务器时钟都正常;
检查方式:登陆各台服务器,使用date指令,然后回车,输出服务器当前时间"
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle数据库字符集】
oracle_character(){
echo -e "\e[43;34m \t\t\tOracle数据库字符集检查结果\t\t\t \e[0m"
character=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET';
EXIT;
EOF
)
if [ ${character} != "ZHS16GBK" ];then
echo "检查当前数据库字符集为${character},标准版数据库环境字符集ZHS16GBK,建议数据库字符集必须为ZHS16GBK"
else
echo "数据库字符集为ZHS16GBK正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:Mysql数据库字符集】
mysql_character(){
echo -e "\e[43;34m \t\t\tMysql数据库字符集检查结果\t\t\t \e[0m"
echo "请输入数据库root密码"
read passwd
v_character=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'character_set_database'"|awk '{print $2}'`
character=`echo ${v_character}|awk '{print $2}'`
if [ ${character} == "utf8mb4" ];then
echo "字符集正确,是utf8mb4"
else
echo "字符集异常,请设置为utf8mb4"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle内存参数检查】
oracle_mem_check(){
echo -e "\e[43;34m \t\t\tOracle内存参数检查结果\t\t\t \e[0m"
sga_target_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select value/1024/1024/1024 from v\$parameter t where name like '%sga_target%';
EXIT;
EOF
)
sga_max_size_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select value/1024/1024/1024 from v\$parameter t where name like '%sga_max_size%';
EXIT;
EOF
)
pga_aggregate_target_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select value/1024/1024/1024 from v\$parameter t where name like '%pga_aggregate_target%';
EXIT;
EOF
)
MEM_TOTAL=`grep MemTotal /proc/meminfo | awk '{print $2/1024/1024}'`
sga_min_union_temp=$(echo "$MEM_TOTAL * 0.8 * 0.5" | bc)
sga_min_union=`echo ${sga_min_union_temp}|awk '{print int($0)}'`
sga_max_union_temp=$(echo "$MEM_TOTAL * 0.8 * 0.8" | bc)
sga_max_union=`echo ${sga_max_union_temp}|awk '{print int($0)}'`
pga_min_union_temp=$(echo "$MEM_TOTAL * 0.7 * 0.1" | bc)
pga_min_union=`echo ${pga_min_union_temp}|awk '{print int($0)}'`
pga_max_union_temp=$(echo "$MEM_TOTAL * 0.7 * 0.3" | bc)
pga_max_union=`echo ${pga_max_union_temp}|awk '{print int($0)}'`
if [ ${sga_target_parameter} -lt ${sga_min_union} ]||[ ${sga_target_parameter} -gt ${sga_max_union} ];then
echo "请根据大B端网址的方法设置SGA大小,提升数据库性能,建议SGA值在${sga_min_union}${sga_max_union}之间"
else
echo "SGA设置正常"
fi
if [ ${pga_aggregate_target_parameter} -lt ${pga_min_union} ]||[ ${pga_aggregate_target_parameter} -gt ${pga_max_union} ];then
echo "请根据大B端网址的方法设置PGA大小,提升数据库性能,建议PGA值在${pga_min_union}${pga_max_union}之间"
else
echo "PGA设置正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:Mysql内存参数检查】
mysql_mem_check(){
echo -e "\e[43;34m \t\t\tMysql内存参数检查结果\t\t\t \e[0m"
echo "请输入数据库root密码"
read passwd
v_innodb_buffer_pool_size=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'innodb_buffer_pool_size'"|grep innodb_buffer_pool_size|awk '{print $2/1024/1024/1024}'`
MEM_TOTAL=`grep MemTotal /proc/meminfo | awk '{print $2/1024/1024}'`
min_line_innodb_buffer_pool_tmp=$(echo "$MEM_TOTAL * 0.7" | bc)
min_line_innodb_buffer_pool=`echo ${min_line_innodb_buffer_pool_tmp}|awk '{print int($0)}'`
max_line_innodb_buffer_pool_tmp=$(echo "$MEM_TOTAL * 0.85" | bc)
max_line_innodb_buffer_pool=`echo ${max_line_innodb_buffer_pool_tmp}|awk '{print int($0)}'`
if [ ${v_innodb_buffer_pool_size} -lt ${min_line_innodb_buffer_pool} ];then
echo "内存参数可以适当提高到内存的70%,参考值为${min_line_innodb_buffer_pool}G"
elif [ ${v_innodb_buffer_pool_size} -gt ${max_line_innodb_buffer_pool} ];then
echo "内存参数设置过高,建议为内存的70%,参考值为${min_line_innodb_buffer_pool}G"
else
echo "数据库内存参数设置正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle日志大小】
oracle_redo_check(){
echo -e "\e[43;34m \t\t\toracle日志大小参数检查结果\t\t\t \e[0m"
redo_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF;
select bytes/1024/1024 from v\$log where rownum=1;
exit
EOF
)
echo "${redo_parameter}"
if [ ${redo_parameter} -le 1024 ];then
echo "redo大小建议为6组大小1G,当前值为${redo_parameter}M"
else
echo "检查redo大小设置正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:Mysql日志大小】
mysql_redo_check(){
echo -e "\e[43;34m \t\t\tMysql日志大小参数检查结果\t\t\t \e[0m"
echo "请输入数据库root密码"
read passwd
v_redo_size=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'innodb_log_file_size'"|grep innodb_log_file_size|awk '{print int($2/1024/1024/1024)}'`
v_redo_num=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'innodb_log_files_in_group'"|grep innodb_log_files_in_group|awk '{print int($2)}'`
if [ ${v_redo_size} -ge 1 ] && [ ${v_redo_num} -ge 5 ];then
echo "日志大小设置正确,建议至少设置为innodb_log_file_size=1G,innodb_log_files_in_group=5"
else
echo "日志大小设置异常,建议至少设置为innodb_log_file_size=1G,innodb_log_files_in_group=5"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle进程大小】
oracle_process_check(){
echo -e "\e[43;34m \t\t\toracle进程大小参数检查结果\t\t\t \e[0m"
process_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select value from v\$parameter t where name='processes';
EXIT;
EOF
)
if [ ${process_parameter} -le 2000 ];then
echo "数据库进程数建议设置大小为2000-3000,当前值为${process_parameter}"
else
echo "检查数据库进程数设置正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:oracle会话数大小】
oracle_session_check(){
echo -e "\e[43;34m \t\t\toracle会话数大小参数检查结果\t\t\t \e[0m"
session_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select value from v\$parameter t where name='sessions';
EXIT;
EOF
)
if [ ${session_parameter} -le 3000 ];then
echo "数据库会话数建议设置大小为3000-4000,当前值为${session_parameter},如果小于1000后续可能会有会话数不足异常"
else
echo "检查数据库会话数设置正常"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数:Mysql会话数大小】
mysql_session_check(){
echo -e "\e[43;34m \t\t\tMysql会话数大小参数检查结果\t\t\t \e[0m"
echo "请输入数据库root密码"
read passwd
session_parameter=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'max_connections'"|grep max_connections|awk '{print int($2)}'`
if [ ${session_parameter} -ge 2000 ];then
echo "数据库会话数大小设置正确,建议至少设置为max_connections=2000"
else
echo "数据库会话数大小设置异常,当前值为:${session_parameter};建议至少设置为max_connections=2000"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数: oracle归档日志是否打开】
oracle_archivelog_check(){
echo -e "\e[43;34m \t\t\toracle归档日志参数检查结果\t\t\t \e[0m"
archivelog_parameter=$(sqlplus -S / as sysdba <<EOF
SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
select log_mode from v\$database;
EXIT;
EOF
)
if [ ${archivelog_parameter} != "NOARCHIVELOG" ];then
echo "数据库已经打开归档模式,建议生产打开归档,非生产关闭"
else
echo "数据库为打开归档日志模式,建议生产打开归档,非生产关闭"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#【函数: Mysql归档日志是否打开】
mysql_archivelog_check(){
echo -e "\e[43;34m \t\t\tMysql归档日志binlog参数检查结果\t\t\t \e[0m"
echo "请输入数据库root密码"
read passwd
binlog_parameter=`mysql -uroot -p${passwd} -e"SHOW VARIABLES LIKE 'log_bin'"|grep log_bin|awk '{print $2}'`
if [ ${binlog_parameter} != "OFF" ];then
echo "数据库会binlog归档日志未关闭,请确认是否是生产系统,生产系统建议打开,非生产系统建议关闭"
else
echo "数据库会binlog归档日志关闭,请确认是否是生产系统,生产系统建议打开,非生产系统建议关闭"
fi
echo -e "\e[43;34m \t\t\t*****************************************************************\t\t\t \e[0m"
}
#------------------------------------------程序---------------------------------------------------------------
while :
do
clear
main_menu
read -p "请输入你的选择:【 1 / 2 / 3 / 4 / 5 】 " man_num
clear
if [ $man_num -eq 1 ]
then
clear
while :
do
ora_mich_ck
read -p "请输入你的选择:【 1 / 2 / 3 / 4 / 5 】 " num_1
case $num_1 in
1)
disk_performance
;;
2)
ora_mic_parm
;;
3)
disk_space_check
;;
4)
check_clock
;;
5)
clear
break
main_menu
;;
*)
clear
echo -e "\e[41;34m \t\t请按照提示输入正确的选项:【 例 如 数 字:1 】\t\t \e[0m"
;;
esac
done
elif [ $man_num -eq 2 ]
then
clear
while :
do
ora_db_ck
read -p "请输入你的选择:【 1 / 2 / 3 / 4 / 5 / 6 / 7 】 " num_2
case $num_2 in
1)
oracle_character
;;
2)
oracle_mem_check
;;
3)
oracle_redo_check
;;
4)
oracle_process_check
;;
5)
oracle_session_check
;;
6)
oracle_archivelog_check
;;
7)
break
main_menu
;;
*)
clear
echo -e "\e[41;34m \t\t请按照提示输入正确的选项:【 例 如 数 字:1 】\t\t \e[0m"
;;
esac
done
elif [ $man_num -eq 3 ]
then
clear
while :
do
mysql_mich_ck
read -p "请输入你的选择:【 1 / 2 / 3 / 4 】 " num_3
case $num_3 in
1)
disk_performance
;;
2)
disk_space_check
;;
3)
check_clock
;;
4)
clear
break
main_menu
;;
*)
clear
echo -e "\e[41;34m \t\t请按照提示输入正确的选项:【 例 如 数 字:1 】\t\t \e[0m"
;;
esac
done
elif [ $man_num -eq 4 ]
then
clear
while :
do
mysql_db_ck
read -p "请输入你的选择:【 1 / 2 / 3 / 4 / 5 / 6 】 " num_4
case $num_4 in
1)
mysql_character
;;
2)
mysql_mem_check
;;
3)
mysql_redo_check
;;
4)
mysql_session_check
;;
5)
mysql_archivelog_check
;;
6)
break
main_menu
;;
*)
clear
echo -e "\e[41;34m \t\t请按照提示输入正确的选项:【 例 如 数 字:1 】\t\t \e[0m"
;;
esac
done
elif [ $man_num -eq 5 ]
then
exit 0
else
clear
echo -e "\e[41;34m \t\t请按照提示输入正确的选项:【 例 如 数 字:1 】\t\t \e[0m"
fi
done
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化