DBA面對新mysql環境

來源:互聯網
上載者:User

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;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
| PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
| MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
| CSV                | YES     | CSV storage engine                                                         | NO           | NO   | NO         |
| MRG_MYISAM         | YES     | Collection of identical MyISAM tables                                      | NO           | NO   | NO         |
| MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
6 rows in set (0.00 sec)

mysql>

 

1.3 瞭解mysql安裝了哪些外掛程式
mysql> show plugins;
+--------------------------------+--------+--------------------+--------------------+---------+
| Name                           | Status | Type               | Library            | License |
+--------------------------------+--------+--------------------+--------------------+---------+
| binlog                         | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
| mysql_native_password          | ACTIVE | AUTHENTICATION     | NULL               | GPL     |
| mysql_old_password             | ACTIVE | AUTHENTICATION     | NULL               | GPL     |
| MEMORY                         | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
| MyISAM                         | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
| CSV                            | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
| MRG_MYISAM                     | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
| InnoDB                         | ACTIVE | STORAGE ENGINE     | NULL               | GPL     |
......
......
| 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_master           | ACTIVE | REPLICATION        | semisync_master.so | GPL     |
+--------------------------------+--------+--------------------+--------------------+---------+
34 rows in set (0.00 sec)

mysql>

 

1.4 瞭解mysql是單機還是ndb叢集
mysql> show variables like 'have_ndbcluster';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| have_ndbcluster | NO    |
+-----------------+-------+
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_name                   | Value                                          |
+---------------------------------+------------------------------------------------+
| log                             | OFF                                            |
| log_bin                         | ON                                             |
| log_bin_trust_function_creators | OFF                                            |
| log_error                       | /data/mysql/usr/local/mysql/data/localhost.err |
| log_output                      | FILE                                           |
| log_queries_not_using_indexes   | OFF                                            |
| log_slave_updates               | OFF                                            |
| log_slow_admin_statements       | OFF                                            |
| log_slow_filter                 |                                                |
| log_slow_queries                | OFF                                            |
| log_slow_rate_limit             | 1                                              |
| log_slow_rate_type              | session                                        |
| log_slow_slave_statements       | OFF                                            |
| log_slow_sp_statements          | ON                                             |
| log_slow_verbosity              |                                                |
| log_warnings                    | 1                                              |
| 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';
+--------------------+---------------+----------------+--------------+
| GRANTEE            | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+--------------------+---------------+----------------+--------------+
| 'root'@'localhost' | def           | SUPER          | YES          |
| 'root'@'127.0.0.1' | def           | SUPER          | YES          |
| 'root'@'::1'       | def           | SUPER          | YES          |
| 'rep'@'%'          | def           | SUPER          | NO           |
| 'root'@'%'         | def           | SUPER          | NO           |
| 'skate'@'%'        | def           | SUPER          | NO           |
+--------------------+---------------+----------------+--------------+
6 rows in set (0.02 sec)

mysql> select host,user,password from mysql.user where password='';
+-----------+------+----------+
| host      | user | password |
+-----------+------+----------+
| 127.0.0.1 | root |          |
| ::1       | root |          |
| localhost |      |          |
+-----------+------+----------+
3 rows in set (0.00 sec)

mysql>

 

1.9 查看資料的存放目錄
mysql> show variables like '%datadir%';
+---------------+-----------------------------------+
| Variable_name | Value                             |
+---------------+-----------------------------------+
| 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的關係
資料庫的存在的意義就是為不同的業務提供服務,所以要更好的瞭解資料庫,就要瞭解業務和不同資料庫的關係,從下到上,再從上到下,這樣才能更好的做好資料庫管理工作。

 

 

 

------end------

 

 

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.