DBA面对新mysql环境

Posted by wukaiqiang; tagged with none

DBA面对新mysql环境
来源:http://blog.csdn.net/wyzxg/article/details/8491152

author:skate
time:2013/01/10

DBA面对新MySQL环境感悟

1.初识单个mysql服务器
2.初识生产环境mysql架构
3.初识cache层和mysql的关系
4.初识其他API(如消息队列)和mysql的关系
5.初识业务和mysql的关系

1.初识单个mysql服务器

1.1 一个全新的Mysql环境,要基本了解mysql版本、os平台、字符集等信息

mysql> status;

mysql Ver 14.12 Distrib 5.0.95, for redhat-Linux-gnu (x86_64) using readline 5.1

Connection id: 25
Current database: skate
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.5.24-log Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 12 days 13 min 7 sec

Threads: 3 Questions: 2100307 Slow queries: 0 Opens: 47 Flush tables: 1 Open tables: 39 Queries per second avg: 2.024

mysql>

1.2 了解mysql支持哪些存储引擎

mysql> show engines;
EngineSupportCommentTransactionsXASavepoints
InnoDBDEFAULTPercona-XtraDB, Supports transactions, row-level locking, and foreign keysYESYESYES
PERFORMANCE_SCHEMAYESPerformance SchemaNONONO
MyISAMYESMyISAM storage engineNONONO
CSVYESCSV storage engineNONONO
MRG_MYISAMYESCollection of identical MyISAM tablesNONONO
MEMORYYESHash based, stored in memory, useful for temporary tablesNONONO

6 rows in set (0.00 sec)

mysql>

1.3 了解mysql安装了哪些插件

mysql> show plugins;
NameStatusTypeLibraryLicense
binlogACTIVESTORAGE ENGINENULLGPL
mysql_native_passwordACTIVEAUTHENTICATIONNULLGPL
mysql_old_passwordACTIVEAUTHENTICATIONNULLGPL
MEMORYACTIVESTORAGE ENGINENULLGPL
MyISAMACTIVESTORAGE ENGINENULLGPL
CSVACTIVESTORAGE ENGINENULLGPL
MRG_MYISAMACTIVESTORAGE ENGINENULLGPL
InnoDBACTIVESTORAGE ENGINENULLGPL

......
......
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| rpl_semi_sync_slave | ACTIVE | REPLICATION | semisync_slave.so | GPL |

rpl_semi_sync_masterACTIVEREPLICATIONsemisync_master.soGPL

34 rows in set (0.00 sec)

mysql>

1.4 了解mysql是单机还是ndb集群

mysql> show variables like 'have_ndbcluster';
Variable_nameValue
have_ndbclusterNO

1 row in set (0.00 sec)

mysql>

1.5 了解是否配置REPLICATION
mysql> show slave status\G;
mysql> show master status\G;

1.6 查看Mysql的日志模式

mysql> show variables like 'log%';
Variable_nameValue
logOFF
log_binON
log_bin_trust_function_creatorsOFF
log_error/data/mysql/usr/local/mysql/data/localhost.err
log_outputFILE
log_queries_not_using_indexesOFF
log_slave_updatesOFF
log_slow_admin_statementsOFF
log_slow_filter
log_slow_queriesOFF
log_slow_rate_limit1
log_slow_rate_typesession
log_slow_slave_statementsOFF
log_slow_sp_statementsON
log_slow_verbosity
log_warnings1
log_warnings_suppress

17 rows in set (0.00 sec)

mysql>

1.7 查看Mysql当前有哪些触发器和存储过程
mysql> show triggers;
mysql> show procedure status;

mysql> select TABLE_NAME from information_schema.PARTITIONS where PARTITION_NAME is not null;

1.8 有多少用户拥有超级权限,是否有密码为空(ROOT密码默认为空),密码为空马上处理

mysql> select * from information_schema.USER_PRIVILEGES where PRIVILEGE_TYPE='SUPER';
GRANTEETABLE_CATALOGPRIVILEGE_TYPEIS_GRANTABLE
'root'@'localhost'defSUPERYES
'root'@'127.0.0.1'defSUPERYES
'root'@'::1'defSUPERYES
'rep'@'%'defSUPERNO
'root'@'%'defSUPERNO
'skate'@'%'defSUPERNO

6 rows in set (0.02 sec)

mysql> select host,user,password from mysql.user where password='';
hostuserpassword
127.0.0.1root
::1root
localhost

3 rows in set (0.00 sec)

mysql>

1.9 查看数据的存放目录

mysql> show variables like '%datadir%';
Variable_nameValue
datadir/data/mysql/usr/local/mysql/data/

1 row in set (0.00 sec)

mysql>

1.10 查看重要的内存参数
innodb_buffer_pool_size
innodb_log_file_size
innodb_log_buffer_size
innodb_log_files_in_group
max_connections
innodb_flush_log_trx_commit
innodb_max_dirty_pages_pct
innodb_flush_method
sync-binlog

1.11 执行一会show processlist,看看Mysql能有多少并发,一般都是什么sql。
1.12 更进一步,Mysql的备份方法和策略是什么?网络环境的配置是如何的?
1.13 跑几个性能分析报告,看看最近系统的运行状态如何,例如用mysqlreport。

os相关信息:

1.14 查看机器型号

dmidecode |grep "Product Name"

1.15 查看cpu型号,及逻辑cpu数量

cat /proc/cpuinfo |grep name| cut -f2 -d: |uniq -c

1.16 查看内存大小,存储大小
free,df

相关命令:
mysql> status;
mysql> show engines;
mysql> show plugins;
mysql> show variables like 'have_ndbcluster';
mysql> show slave status\G;
mysql> show master status\G;
mysql> show triggers;
mysql> show procedure status;
mysql> select * from information_schema.USER_PRIVILEGES where PRIVILEGE_TYPE='SUPER';
mysql> select host,user,password from mysql.user where password='';
mysql> show variables like '%datadir%';
mysql> show processlist

dmidecode |grep "Product Name"

cat /proc/cpuinfo |grep name| cut -f2 -d: |uniq -c

2.初识生产环境mysql架构

mysql单机环境通过个人就可以大概了解数据库的基本信息,如果数据库环境比较复杂,如下相关问题就要咨询相关同学,如果有
文档最好。

数据库如何横向、纵向的拆分
每个集群的容灾方式如何
是否有故障隔离
是否有优雅降级
数据库层是如何自我保护的
监控框架如何
备份框架如何
安全体系如何

3.初识cache层和mysql的关系

cache主要用于承载数据库存储层的大部分io,那我们就要对cache有一定的了解

那cache层和数据库存储层是什么关系?是应用来保证cache层数据库新鲜?还是数据库主动更新cache层数据?
cache层是用什么软件实现的?
cache层失效之后的数据预热是否对数据库存储层有冲击

4.初识其他API(如消息队列)和mysql的关系

不同的mysql之间(或mysql和其他组件之间)可能需要数据同步传输,这些依赖关系我们要了解。mysql之间的同步是通过什么技术?

5.初识业务和mysql的关系
数据库的存在的意义就是为不同的业务提供服务,所以要更好的了解数据库,就要了解业务和不同数据库的关系,从下到上,再从上到下,这样才能更好的做好数据库管理工作。