前段时间有高人写了一篇《面对一个全新的环境,作为一个oracle dba,首先应该了解什么》,本文借花献佛,总结了一些思路,如何面对一个全新的mysql环境。
1、先要了解当前的mysql数据库的版本和平台以及字符集等相关信息
mysql> status
--------------
mysql ver 14.14 distrib 5.1.34, for unknown-linux-gnu (x86_64) using editline wrapper
connection id: 25874330
current database:
current user:
ssl: not in use
current pager: stdout
using outfile: ''
using delimiter: ;
server version: 5.1.34-log source distribution
protocol version: 10
connection: localhost via unix socket
server characterset: utf8
db characterset: utf8
client characterset: utf8
conn. characterset: utf8
unix socket: /tmp/mysql.sock
uptime: 13 days 14 hours 18 min 36 sec
threads: 7 questions: 190708290 slow queries: 19 opens: 57835 flush tables: 1
open tables: 84 queries per second avg: 162.344
--------------
2、其次要了解你的数据库中支持哪些存储引擎,5.1的话顺便查下插件情况。
mysql> show engines;
------------ --------- ---------------------------------------------------------------- -------------- ------ ------------
| engine | support | comment | transactions | xa | savepoints |
------------ --------- ---------------------------------------------------------------- -------------- ------ ------------
| innodb | yes | supports transactions, row-level locking, and foreign keys | yes | yes | yes |
| mrg_myisam | yes | collection of identical myisam tables | no | no | no |
| blackhole | yes | /dev/null storage engine (anything you write to it disappears) | no | no | no |
| csv | yes | csv storage engine | no | no | no |
| memory | yes | hash based, stored in memory, useful for temporary tables | no | no | no |
| federated | no | federated mysql storage engine | null | null | null |
| archive | yes | archive storage engine | no | no | no |
| myisam | default | default engine as of mysql 3.23 with great performance | no | no | no |
------------ --------- ---------------------------------------------------------------- -------------- ------ ------------
8 rows in set (0.00 sec)
mysql> show plugins;
------------ ---------- ---------------- --------- ---------
| name | status | type | library | license |
------------ ---------- ---------------- --------- ---------
| binlog | active | storage engine | null | gpl |
| partition | active | storage engine | null | gpl |
| archive | active | storage engine | null | gpl |
| blackhole | active | storage engine | null | gpl |
| csv | active | storage engine | null | gpl |
| federated | disabled | storage engine | null | gpl |
| memory | active | storage engine | null | gpl |
| innodb | active | storage engine | null | gpl |
| myisam | active | storage engine | null | gpl |
| mrg_myisam | active | storage engine | null | gpl |
------------ ---------- ---------------- --------- ---------
3、搞清楚这个环境是单机还是集群?
mysql> show variables like 'have_ndbcluster';
----------------- -------
| variable_name | value |
----------------- -------
| have_ndbcluster | no |
----------------- -------
1 row in set (0.00 sec)
4、是否配置了replication?
show slave status\g;
show master status\g;
5、查看mysql的日志模式,查看近期的慢查询日志和err日志。
mysql> show variables like 'log%';
--------------------------------- ----------------------
| variable_name | value |
--------------------------------- ----------------------
| log | off |
| log_bin | on |
| log_bin_trust_function_creators | off |
| log_bin_trust_routine_creators | off |
| log_error | /dir/hostname.err |
| log_output | file |
| log_queries_not_using_indexes | off |
| log_slave_updates | off |
| log_slow_queries | on |
| log_warnings | 1 |
--------------------------------- ----------------------
6、查看mysql当前有哪些触发器和存储过程
mysql> show triggers;
mysql> show procedure status;
7、是否支持分区,如果支持哪些使用了分区表
mysql> show variables like 'have_part%';
------------------- -------
| variable_name | value |
------------------- -------
| have_partitioning | yes |
------------------- -------
1 row in set (0.00 sec)
mysql> select table_name from information_schema.partitions where partition_name is not null;
8、有多少用户拥有超级权限,是否有密码为空(root密码默认为空),密码为空马上处理。
mysql> select * from information_schema.user_privileges where privilege_type='super';
mysql> select host,user,password from mysql.user where password='';
------------- ------ ----------
| host | user | password |
------------- ------ ----------
| localhost | root | |
| 127.0.0.1 | root | |
------------- ------ ----------
mysql> delete from mysql.user where password='';flush privileges;
9.show processlist
执行一会show processlist,看看 mysql 能有多少并发,一般都是什么sql。
10、更进一步,mysql的备份方法和策略是什么?网络环境的配置是如何的?
11、跑几个性能分析报告,看看最近系统的运行状态如何,例如用mysqlreport。
ok,以上信息基本上对你新接触的这个系统有了一个大概的了解,接下来你再慢慢的深入分析,然后制订出一套符合实际情况的运维规范来。
当然,这只是个人的一些心得和体会,每个人的认识的角度是不一样的,欢迎大家继续补充完善。