首页 文章 精选 留言 我的

精选列表

搜索[检查工具],共10016篇文章
优秀的个人博客,低调大师

是时候检查一下使用索引的姿势是否正确了!

索引,可以有效提高我们的数据库搜索效率,各种数据库优化八股文里都有相关的知识点可背,不过单纯的被条目其实很容易忘记。 所以松哥想通过几篇文章,和大家仔细聊一聊索引的正确使用姿势,结合一些具体的例子来帮助大家理解索引优化,这是一个小小的系列,可能会有几篇文章,今天先来第一篇。 1. 索引列独立 当我们将带有索引的列作为搜索的条件的时候,需要确保索引不在表达式中,索引中也不包含各种运算。 我举个简单例子,假设我有如下一张表: 一个 user 表,里边就四个字段,每个字段上都建了索引,现在有三条测试数据: 我们来比较如下两个查询: 可以看到: 第一个 type 为 ALL 表示全表扫描(没用上索引);第二个 type 为 ref 表示通过索引查找数据,一般出现等值匹配的时候,type 会为 ref。 第二个的 key 指明了 MySQL 使用哪个索引来优化查询;rows 则显示了 MySQL 为了找到所需的值而要读取的行数. 第一个的 Extra 为 Using where 表示这个搜索需要在 server 层进行判断(过滤),即存储引擎层无法返回满足条件的数据(当然这里也不需要回表,因为压根都没有用啥索引)。 从上面的分析中可以看到,虽然 age-1=98 与 age=99 虽然在逻辑上并无二致,但是 MySQL 却无法自动解析第一个表达式,进而导致第一个无法使用索引。所以,我们不要在 where 条件中写表达式,不仅仅是上面这种表达式,一些使用了自带函数的表达式也不能使用,我们要尽量简化 where 条件。 不过上面这个例子太牵强了,一般大家不会犯这种错误,但是下面这个例子就不一定了,可能会有小伙伴在上面栽跟头:查询最近一年出生的用户(birthday 列也是索引): 在这张图里,我给出了两种不同的查询思路: 对 birthday 做计算,如果 birthday 加上一年,得到的时间大于当前时间,那么说明该用户出生日期在最近一年一年之内。 对当前日期进行计算,如果当前日期减去一年得到的时间小于 birthday,说明 birthday 在一年之内。 根据上图 explain 的结果,很明显第一种方案没有用上索引,进行了全表扫描;而第二种方案则用上了索引,只读取了两行数据就可以了。究其原因,就是因为第一种方案在索引列上进行了函数运算,导致 MySQL 没法使用索引了。 2. 巧用覆盖索引 一般来说我们不建议在查询中直接使用 select *,使用 select * 有很多问题,其中一个问题就是无法利用索引覆盖扫描(覆盖索引)。 那这里需要大家首先明白什么是覆盖索引。 在什么是 MySQL 的“回表”?一文中,松哥和大家聊了,索引按照物理存储方式可以分为聚簇索引和非聚簇索引。 我们日常所说的主键索引,其实就是聚簇索引(Clustered Index);主键索引之外,其他的都称之为非主键索引,非主键索引也被称为二级索引(Secondary Index),或者叫作辅助索引。 对于主键索引和非主键索引,使用的数据结构都是 B+Tree,唯一的区别在于叶子结点中存储的内容不同: 主键索引的叶子结点存储的是一行完整的数据。 非主键索引的叶子结点存储的则是主键值以及索引列的值。 这是两者最大的区别。 所以,搜索时如果使用了非主键索引,那么一共会搜索两棵 B+Tree,第一次搜索 B+Tree 拿到主键值后再去搜索主键索引的 B+Tree,这个过程就是所谓的回表。但是,如果搜索的字段刚好就在二级索引的叶子结点上,那么是不是就不需要回表了?我们来验证下。 假设我有如下一张表: CREATE TABLE `user2` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `gender` varchar(4) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `username` (`username`,`address`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; id 是主键,username 和 address 是复合索引。 这表有三条记录: 我们来做个简单测试,先来看如下 SQL: explain select username,address from user2 where username='javaboy'; 这个查询 SQL,我们查询的字段是 username 和 address,由于这两个字段是复合索引,因此都保存在二级索引的 B+Tree 的叶子结点中,搜索到 username 后也就能拿到 address 的值了,因此不需要回表查询。大家注意最后 Extra 中的 Using index 就是这意思。 > Using index 表示使用索引覆盖扫描来返回记录,直接从索引中过滤不需要的记录并返回命中结果,这是在 MySQL 服务器层完成的,但是无须再回表查询记录。 相同的道理,id 的值也存在于二级索引中,按理说也不需要回表,所以我稍微修改一下查询 SQL,加入 id,大家来看下: explain select username,address,id from user2 where username='javaboy'; 可以看到跟我们想的一样。 那么我再加上 gender 呢?如果要查询的字段中包含 gender,由于 gender 并没有保存在二级索引的的叶子结点中,那么此时就需要回表查询了: explain select gender from user2 where username='javaboy'; 可以看到,此时 Extra 为空,同时用到了二级索引 username,那么此时就需要回表了。 这个就是覆盖索引,巧用覆盖索引,能避免回表,提高查询效率。那么此时就要尽量避免使用 select * 了(因为一般来说不太可能给所有字段都建立一个复合索引)。 好啦,不知道小伙伴看明白没有,下篇文章我们继续~

优秀的个人博客,低调大师

通过shell检查mysql主机和数据库,生成html报表的脚本

该脚本主要用于大致诊断MYSQL主机和数据库配置及性能收集,脚本部分功能展示如下: 实现该上述展示功能的shell脚本如下: file_output='os_mysql_summary.html' td_str='' th_str='' myuser="root" mypasswd="password" myip="192.168.11.101" myport="3307" mysql_cmd="mysql-u${myuser}-p${mypasswd}-h${myip}-P${myport}--protocol=tcp--silent" create_html_css(){ echo-e"<html> <head> <styletype="text/css"> body{font:12pxCourierNew,Helvetica,sansserif;color:black;background:White;} table,tr,td{font:12pxCourierNew,Helvetica,sansserif;color:Black;background:#FFFFCC;padding:0px0px0px0px;margin:0px0px0px0px;} th{font:bold12pxCourierNew,Helvetica,sansserif;color:White;background:#0033FF;padding:0px0px0px0px;} h1{font:bold12ptCourierNew,Helvetica,sansserif;color:Black;padding:0px0px0px0px;} </style> </head> <body>" } create_html_head(){ echo-e"<h1>$1</h1>" } create_table_head1(){ echo-e"<tablewidth="68%"border="1"bordercolor="#000000"cellspacing="0px"style="border-collapse:collapse">" } create_table_head2(){ echo-e"<tablewidth="100%"border="1"bordercolor="#000000"cellspacing="0px"style="border-collapse:collapse">" } create_td(){ td_str=`echo$1|awk'BEGIN{FS="|"}''{i=1;while(i<=NF){print"<td>"$i"</td>";i++}}'` } create_th(){ th_str=`echo$1|awk'BEGIN{FS="|"}''{i=1;while(i<=NF){print"<th>"$i"</th>";i++}}'` } create_tr1(){ create_td"$1" echo-e"<tr> $td_str </tr>">>$file_output } create_tr2(){ create_th"$1" echo-e"<tr> $th_str </tr>">>$file_output } create_tr3(){ echo-e"<tr><td> <prestyle=\"font-family:CourierNew;word-wrap:break-word;white-space:pre-wrap;white-space:-moz-pre-wrap\"> `cat$1` </pre></td></tr>">>$file_output } create_table_end(){ echo-e"</table>" } create_html_end(){ echo-e"</body></html>" } NAME_VAL_LEN=12 name_val(){ printf"%+*s|%s\n""${NAME_VAL_LEN}""$1""$2" } get_virtual(){ localfile="/var/log/dmesg" ifgrep-qi-e"vmware"-e"vmxnet"-e'paravirtualizedkernelonvmi'"${file}";then echo"VMWare"; elifgrep-qi-e'paravirtualizedkernelonxen'-e'Xenvirtualconsole'"${file}";then echo"Xen"; elifgrep-qi"qemu""${file}";then echo"QEmu"; elifgrep-qi'paravirtualizedkernelonKVM'"${file}";then echo"KVM"; elifgrep-q"VBOX""${file}";then echo"VirtualBox"; elifgrep-qi'hd.:Virtual..,ATA.*drive'"${file}";then echo"MicrosoftVirtualPC"; else echo"PhysicalMachine" fi } get_physics(){ name_val"Date""`date-u+'%F%TUTC'`(localTZ:`date+'%Z%z'`)" name_val"Hostname""`uname-n`" name_val"Uptime""`uptime`" name_val"System""`dmidecode-s"system-manufacturer""system-product-name""system-version""chassis-type"`" name_val"Service_num""`dmidecode-s"system-serial-number"`" name_val"Platform""`uname-s`" name_val"Release""`cat/etc/{oracle,redhat,SuSE,centos}-release2>/dev/null|sort-ru|head-n1`" name_val"Kernel""`uname-r`" name_val"Architecture""CPU=`lscpu|grepArchitecture|awk-F:'{print$2}'|sed's/^[[:space:]]*//g'`;OS=`getconfLONG_BIT`-bit" name_val"Threading""`getconfGNU_LIBPTHREAD_VERSION`" name_val"SELinux""`getenforce`" name_val"Virtualized""`get_virtual`" } get_cpuinfo(){ file="/proc/cpuinfo" virtual=`grep-c^processor"${file}"` physical=`grep'physicalid'"${file}"|sort-u|wc-l` cores=`grep'cpucores'"${file}"|head-n1|cut-d:-f2` model=`grep"modelname""${file}"|sort-u|awk-F:'{print$2}'` speed=`grep-i"cpuMHz""${file}"|sort-u|awk-F:'{print$2}'` cache=`grep-i"cachesize""${file}"|sort-u|awk-F:'{print$2}'` SysCPUIdle=`vmstat|sed-n'$p'|awk'{print$15}'` ["${physical}"="0"]&&physical="${virtual}" [-z"${cores}"]&&cores=0 cores=$((${cores}*${physical})); htt="" if[${cores}-gt0-a$cores-lt$virtual];thenhtt=yes;elsehtt=no;fi name_val"Processors""physical=${physical},cores=${cores},virtual=${virtual},hyperthreading=${htt}" name_val"Models""${physical}*${model}" name_val"Speeds""${virtual}*${speed}" name_val"Caches""${virtual}*${cache}" name_val"CPUIdle(%)""${SysCPUIdle}%" } get_meminfo(){ echo"Locator|Size|Speed|FormFactor|Type|TypeDetail">>/tmp/tmpmem3_h1_`date+%y%m%d`.txt dmidecode|grep-v"MemoryDeviceMappedAddress"|grep-A12-w"MemoryDevice"\ |egrep"Locator:|Size:|Speed:|FormFactor:|Type:|TypeDetail:"\ |awk-F:'/Size|Type|Form.Factor|Type.Detail|^[\t]+Locator/{printf("|%s",$2)}/^[\t]+Speed/{print"|"$2}'\ |grep-v"NoModuleInstalled"\ |awk-F"|"'{print$4,"|",$2,"|",$7,"|",$3,"|",$5,"|",$6}'>>/tmp/tmpmem3_t1_`date+%y%m%d`.txt free-glht>>/tmp/tmpmem2_`date+%y%m%d`.txt memtotal=`vmstat-s|head-1|awk'{print$1}'` avm=`vmstat-s|sed-n'3p'|awk'{print$1}'` name_val"Mem_used_rate(%)""`echo"100*${avm}/${memtotal}"|bc`%">>/tmp/tmpmem1_`date+%y%m%d`.txt } get_diskinfo(){ echo"Filesystem|Type|Size|Used|Avail|Use%|Mountedon|Opts">>/tmp/tmpdisk_h1_`date+%y%m%d`.txt df-ThP|grep-vtmpfs|sed'1d'|sort>/tmp/tmpdf1_`date+%y%m%d`.txt mount-l|awk'{print$1,$6}'|grep^/|sort>/tmp/tmpdf2_`date+%y%m%d`.txt join/tmp/tmpdf1_`date+%y%m%d`.txt/tmp/tmpdf2_`date+%y%m%d`.txt\ |awk'{print$1,"|",$2,"|",$3,"|",$4,"|",$5,"|",$6,"|",$7,"|",$8}'>>/tmp/tmpdisk_t1_`date+%y%m%d`.txt lsblk>>/tmp/tmpdisk1_`date+%y%m%d`.txt fordiskin`ls-l/sys/block|awk'{print$9}'|sed'/^$/d'|grep-vfd` do echo"${disk}"`cat/sys/block/${disk}/queue/scheduler`>>/tmp/tmpdisk2_`date+%y%m%d`.txt done pvs>>/tmp/tmpdisk3_`date+%y%m%d`.txt echo"================================================================">>/tmp/tmpdisk3_`date+%y%m%d`.txt vgs>>/tmp/tmpdisk3_`date+%y%m%d`.txt echo"================================================================">>/tmp/tmpdisk3_`date+%y%m%d`.txt lvs>>/tmp/tmpdisk3_`date+%y%m%d`.txt } get_netinfo(){ echo"interface|status|ipadds|mtu|Speed|Duplex">>/tmp/tmpnet_h1_`date+%y%m%d`.txt foripstrin`ifconfig-a|grep":flags"|awk'{print$1}'|sed's/.$//'` do ipadds=`ifconfig${ipstr}|grep-winet|awk'{print$2}'` mtu=`ifconfig${ipstr}|grepmtu|awk'{print$NF}'` speed=`ethtool${ipstr}|grepSpeed|awk-F:'{print$2}'` duplex=`ethtool${ipstr}|grepDuplex|awk-F:'{print$2}'` echo"${ipstr}""up""${ipadds}""${mtu}""${speed}""${duplex}"\ |awk'{print$1,"|",$2,"|",$3,"|",$4,"|",$5,"|",$6}'>>/tmp/tmpnet1_`date+%y%m%d`.txt done } get_topproc(){ #osload echo"osload1">>/tmp/tmpload_`date+%y%m%d`.txt sar-q15>>/tmp/tmpload_`date+%y%m%d`.txt echo"osload2">>/tmp/tmpload_`date+%y%m%d`.txt sar-b15>>/tmp/tmpload_`date+%y%m%d`.txt echo"osload3">>/tmp/tmpload_`date+%y%m%d`.txt vmstat15>>/tmp/tmpload_`date+%y%m%d`.txt #topcpu mpstat15>>/tmp/tmptopcpu_`date+%y%m%d`.txt echo"TOP10CPUResourceProcess">>/tmp/tmptopcpu_`date+%y%m%d`.txt psaux|head-1>>/tmp/tmptopcpu_`date+%y%m%d`.txt psaux|grep-vPID|sort-rn-k+3|head>>/tmp/tmptopcpu_`date+%y%m%d`.txt #top-bn1-o"%CPU"|sed-n'/PID/,17p' #topmem echo"TOP10MEMResourceProcess">>/tmp/tmptopmem_`date+%y%m%d`.txt psaux|head-1>>/tmp/tmptopmem_`date+%y%m%d`.txt psaux|grep-vPID|sort-rn-k+4|head>>/tmp/tmptopmem_`date+%y%m%d`.txt #top-bn1-o"%MEM"|sed-n'/PID/,17p' #topi/o iostat-cdmx23>>/tmp/tmptopio_`date+%y%m%d`.txt #iotop-botq-n3-d2 } my_base_info(){ ${mysql_cmd}-e"selectnow(),current_user(),version()\G" ${mysql_cmd}-e"showglobalvariableslike'autocommit';"|grep-i^auto|awk'{print$1,":",$2}' ${mysql_cmd}-e"showglobalvariables"|egrep-w"port|character_set_server|datadir|log_error|log_bin_basename|tx_isolation|binlog_format"|awk'{print$1,":",$2}' } my_stat_info(){ ${mysql_cmd}-estatus>>/tmp/tmpmy_stat_`date+%y%m%d`.txt } my_connip_info(){ echo"ipadds|conn_status|count">>/tmp/tmpmy_connip_h1_`date+%y%m%d`.txt netstat-an|grep${myport}|grep-viLISTEN|awk'{print$5,$6}'|sed's/::ffff://g'|sed's/:[0-9]*//g'|sed'1d'|sort|uniq-c|awk'{print$2,"|",$3,"|",$1}'>>/tmp/tmpmy_connip_t1_`date+%y%m%d`.txt } my_param_info(){ echo"Variable_name|Value">>/tmp/tmpmy_param_h1_`date+%y%m%d`.txt ${mysql_cmd}-e"showglobalvariables"|egrep-w"innodb_buffer_pool_size|innodb_file_per_table|innodb_flush_log_at_trx_commit|innodb_io_capacity|\ innodb_lock_wait_timeout|innodb_data_home_dir|innodb_log_file_size|innodb_log_files_in_group|log_slave_updates|long_query_time|lower_case_table_names|\ max_connections|max_connect_errors|max_user_connections|query_cache_size|query_cache_type|server_id|slow_query_log|slow_query_log_file|innodb_temp_data_file_path|\ sql_mode|gtid_mode|enforce_gtid_consistency|expire_logs_days|sync_binlog|open_files_limit|myisam_sort_buffer_size|myisam_max_sort_file_size"\ |awk'{print$1,"|",$2}'>>/tmp/tmpmy_param_t1_`date+%y%m%d`.txt } my_segm1_info(){ ${mysql_cmd}-H-e"selectTABLE_SCHEMA,concat(truncate(sum(data_length)/1024/1024/1024,2),'GB')asdata_size,\ concat(truncate(sum(index_length)/1024/1024/1024,2),'GB')asindex_size\ frominformation_schema.tablesgroupbyTABLE_SCHEMAorderbydata_lengthdesc;" } my_segm2_info(){ ${mysql_cmd}-H-e"selecttable_schema,table_name,table_rows,concat(truncate(data_length/1024/1024/1024,2),'GB')asdata_size,\ concat(truncate(index_length/1024/1024/1024,2),'GB')asindex_sizefrominformation_schema.tablesorderbydata_lengthdesclimit10;" } my_segm3_info(){ ${mysql_cmd}-H-e"selecttable_name,table_rows,concat(round(data_length/1024/1024,2),'MB')assize,data_free\ frominformation_schema.tableswheredata_free>0orderbydata_lengthdesc;" } my_obj1_info(){ ${mysql_cmd}-H-e"selecttable_schemaasdb,table_typeasobject_type,count(*)ascntfrominformation_schema.tablesgroupbytable_schema,table_typeunionall\ selectroutine_schemaasdb,routine_typeasobject_type,count(*)ascntfrominformation_schema.routinesgroupbyroutine_schema,routine_type;" } my_obj2_info(){ ${mysql_cmd}-H-e"selecttable_schema,engine,count(*)ascntfrominformation_schema.tablesgroupbytable_schema,engine;" } my_obj3_info(){ ${mysql_cmd}-H-e"selecttable_schema,table_namefrominformation_schema.tableswheretable_schemanotin('mysql','information_schema','performance_schema','sys')andtable_namenotin(\ selecttable_namefrominformation_schema.table_constraintstjoininformation_schema.key_column_usagekusing(\ constraint_name,table_schema,table_name)wheret.constraint_type='PRIMARYKEY'andtable_schemanotin('mysql','information_schema','performance_schema','sys'));" } my_lock_info(){ ${mysql_cmd}-H-e"SELECTr.trx_idwaiting_trx_id,r.trx_mysql_thread_idwaiting_thread,r.trx_querywaiting_query,\ b.trx_idblocking_trx_id,b.trx_mysql_thread_idblocking_thread,b.trx_queryblocking_query,\ bl.lock_idblocking_lock_id,bl.lock_modeblocking_lock_mode,bl.lock_typeblocking_lock_type,\ bl.lock_tableblocking_lock_table,bl.lock_indexblocking_lock_index,\ rl.lock_idwaiting_lock_id,rl.lock_modewaiting_lock_mode,rl.lock_typewaiting_lock_type,\ rl.lock_tablewaiting_lock_table,rl.lock_indexwaiting_lock_index\ FROMinformation_schema.INNODB_LOCK_WAITSw\ INNERJOINinformation_schema.INNODB_TRXbONb.trx_id=w.blocking_trx_id\ INNERJOINinformation_schema.INNODB_TRXrONr.trx_id=w.requesting_trx_id\ INNERJOINinformation_schema.INNODB_LOCKSblONbl.lock_id=w.blocking_lock_id\ INNERJOINinformation_schema.INNODB_LOCKSrlONrl.lock_id=w.requested_lock_id\G" } my_innodb_info(){ ${mysql_cmd}-e"showengineinnodbstatus\G" } my_user_info(){ ${mysql_cmd}-e"SELECTDISTINCTCONCAT('showgrantsfor''',user,'''@''',host,''';')ASqueryFROMmysql.user;">>/tmp/tmpmy_user_t_`date+%y%m%d`.txt whilereadline do echo"=================================================================">>/tmp/tmpmy_user_`date+%y%m%d`.txt echo"$line">>/tmp/tmpmy_user_`date+%y%m%d`.txt ${mysql_cmd}-e"$line">>/tmp/tmpmy_user_`date+%y%m%d`.txt done</tmp/tmpmy_user_t_`date+%y%m%d`.txt } create_html(){ rm-rf$file_output touch$file_output create_html_css>>$file_output create_html_head"OSBasicSummary">>$file_output create_table_head1>>$file_output get_physics>>/tmp/tmpos_summ_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpos_summ_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"CPUInfoSummary">>$file_output create_table_head1>>$file_output get_cpuinfo>>/tmp/tmp_cpuinfo_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmp_cpuinfo_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"MEMInfoSummary">>$file_output create_table_head1>>$file_output get_meminfo whilereadline do create_tr1"$line" done</tmp/tmpmem1_`date+%y%m%d`.txt create_table_end>>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmpmem2_`date+%y%m%d`.txt" create_table_end>>$file_output create_table_head1>>$file_output whilereadline do create_tr2"$line" done</tmp/tmpmem3_h1_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpmem3_t1_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"DiskInfoSummary">>$file_output create_table_head1>>$file_output get_diskinfo whilereadline do create_tr2"$line" done</tmp/tmpdisk_h1_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpdisk_t1_`date+%y%m%d`.txt create_table_end>>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmpdisk1_`date+%y%m%d`.txt" create_table_end>>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmpdisk2_`date+%y%m%d`.txt" create_table_end>>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmpdisk3_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"NetworkInfoSummary">>$file_output create_table_head1>>$file_output get_netinfo whilereadline do create_tr2"$line" done</tmp/tmpnet_h1_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpnet1_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"OSLoadSummary">>$file_output create_table_head1>>$file_output get_topproc create_tr3"/tmp/tmpload_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"TOPCPUSummary">>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmptopcpu_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"TOPMEMSummary">>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmptopmem_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"TOPIOSummary">>$file_output create_table_head1>>$file_output create_tr3"/tmp/tmptopio_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"BasicDatabaseInformation">>$file_output create_table_head1>>$file_output my_base_info>>/tmp/tmpmy_base_`date+%y%m%d`.txt sed-i-e'1d'-e's/:/|/g'/tmp/tmpmy_base_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpmy_base_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"RunningStatusofDatabase">>$file_output create_table_head1>>$file_output my_stat_info create_tr3"/tmp/tmpmy_stat_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"IPConnectionStatistics">>$file_output create_table_head1>>$file_output my_connip_info whilereadline do create_tr2"$line" done</tmp/tmpmy_connip_h1_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpmy_connip_t1_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"ImportantParameters">>$file_output create_table_head1>>$file_output my_param_info whilereadline do create_tr2"$line" done</tmp/tmpmy_param_h1_`date+%y%m%d`.txt whilereadline do create_tr1"$line" done</tmp/tmpmy_param_t1_`date+%y%m%d`.txt create_table_end>>$file_output create_html_head"Sizeofeachdatabase">>$file_output my_segm1_info>>$file_output create_html_head"TOP10SpaceTable">>$file_output my_segm2_info>>$file_output create_html_head"HighWaterLevelMeter">>$file_output my_segm3_info>>$file_output create_html_head"Objecttypestatistics">>$file_output my_obj1_info>>$file_output create_html_head"StorageEngineNumberStatistics">>$file_output my_obj2_info>>$file_output create_html_head"Tableswithoutprimarykeys">>$file_output my_obj3_info>>$file_output create_html_head"Lockinformation">>$file_output my_lock_info>>$file_output create_html_head"InnodbStatusInformation">>$file_output create_table_head1>>$file_output my_innodb_info>>/tmp/tmpmy_innodb_`date+%y%m%d`.txt create_tr3"/tmp/tmpmy_innodb_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"UserAuthorizationInformation">>$file_output create_table_head1>>$file_output my_user_info create_tr3"/tmp/tmpmy_user_`date+%y%m%d`.txt" create_table_end>>$file_output create_html_head"SlowSQLstatistics">>$file_output create_html_end>>$file_output sed-i's/BORDER=1/width="68%"border="1"bordercolor="#000000"cellspacing="0px"style="border-collapse:collapse"/g'$file_output rm-rf/tmp/tmp*_`date+%y%m%d`.txt } #Thisscriptmustbeexecutedasroot RUID=`id|awk-F\('{print$1}'|awk-F\='{print$2}'` ##OR#RUID=`id|cut-d\(-f1|cut-d\=-f2`#OR#ROOT_UID=0 if[${RUID}!="0"];then echo"Thisscriptmustbeexecutedasroot" exit1 fi PLATFORM=`uname` if[${PLATFORM}="HP-UX"];then echo"ThisscriptdoesnotsupportHP-UXplatformforthetimebeing" exit1 elif[${PLATFORM}="SunOS"];then echo"ThisscriptdoesnotsupportSunOSplatformforthetimebeing" exit1 elif[${PLATFORM}="AIX"];then echo"ThisscriptdoesnotsupportAIXplatformforthetimebeing" exit1 elif[${PLATFORM}="Linux"];then echo-e" ########################################################################################### ## #Makesurethatthefollowingparametersatthebeginningofthescriptarecorrect.# #myuser="root"(DatabaseAccount)# #mypasswd="password"(Databasepassword)# #myip="192.168.11.101"(DatabasenativeIP)# #myport="3307"(Databaseport)# #Otherwise,thescriptcannotbeexecutedproperly.# ## ########################################################################################### " #read-p"Thedatabaseconnectioninformationisconfiguredcorrectly.Pleaseexecute[yesory]:"SELECT #printf'\n' #if[$SELECT=="yes"-o$SELECT=="y"];then create_html #else #exit1 #fi fi

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册