涂抹MySQL——跟著三思一步一步學MySQL
簡介
本書特色
前言
章節列表
精彩閱讀
下載資源
相關圖書
本書不是一本逐個介紹MySQL 命令的書,不是一本用戶幫助手冊,也不是這個功
能講完講那個功能的書。因為在寫作之初我就設定了一條主線,不是依次講特性,而要
依據用戶接觸和學習MySQL 的脈絡去把握內容的安排。
本書主要側重于MySQL 數據庫從無到有及其安裝、配置、管理、優化的過程,其
中穿插介紹數據導入導出,性能/狀態監控,備份恢復和優化方面等內容,同時還會談一
談MySQL 數據庫服務從單臺到多臺,從單實例到多實例集群的部署方案。
本書主要面向Web 應用的一線開發人員和對MySQL 數據庫較有興趣,希望使用或
正在使用的讀者。對于有志從事數據庫管理員相關職業的讀者,相信本書能夠幫助他們
快速找到入門的路徑;本書中提到的一些技巧類應用和擴展方案,即使對于具有一定技
術實力的有經驗的MySQL DBA,相信也會有一定的啟發;此外本書也可以作為大中專
院校相關專業師生的參考工具書和相關培訓機構的培訓教材。
●以前MySQL方面接觸的少,怎么安裝配置才合理?
●用戶和權限設計的這么靈活,怎么玩才安全?
●數據需要頻繁導入導出,怎么快速搞定?
●數據寫入時明明都是正常的,讀取出來顯示卻亂碼,到底怎么回事兒?
●MySQL自帶了那么多命令行工具,都能干點什么活?
●保存的數據越來越多,怎么保障它們的安全?
●數據庫運行的越來越慢,想讓它快一點點,應該怎么辦?
●單個實例承載的壓力太大,怎么將其擴展?
●管理的數據庫服務越來越多,怎樣輕松有效地監控數據庫狀態?
……
不煩不燥,不困不乏,不徐不疾,MySQL精髓,得之于手。
出任CTO,迎娶白富美,分分鐘的搞定!
這些年一直堅持在博客上發表系列文章,也出版過技術方面的書,在業內積累了那么一點點知名度,
就有很多朋友慕名而來跟我交流,要向我請教技術上的問題,咨詢學習的技巧,讓我推薦閱讀的圖書等。
朋友們的熱情讓我感到很是忐忑,我雖然寫過一些文章,但都是些通俗的東西,其實沒什么學問,而且老
實講,有些朋友提出的問題真是不容易回答,比如有朋友上來就問我怎么優化數據庫(這類問題恰恰是最
多的),也有人問我看什么書能達到我現在的水平等等。
我知道這其中有些人確實是喜歡并且希望從事DBA 這個職業的,他們當前只是沒有經驗才顯得迷茫,
其實我也是從這個階段走過來的。多年以前我曾寫過一篇文章《我想對初學Oracle 的朋友說》
(http://www.5ienet.com/note/html/stdstep/how-to-learn-in-oracle.shtml),其中的內容也是我有感而發。因為
了解DBA 成長道路上的艱辛,我不愿意隨口敷衍他們幾句,使他們走了彎路。可是因為自己的水平有限,
我又難以簡單幾句話就說明白,有時候拉拉扯扯說了一堆,反倒是提問者自己不耐煩,甚至還有朋友直接
了當地指責我不愿意分享(這個殺傷力太大,我的文章都白寫了嗎),整的我的心里也很受傷,對于這樣
的人,我當機立斷大喝一聲:“你是猴子搬來的救兵嗎?”。不過我知道,多數人還是希望通過不斷學習獲
得提高,看到他們就像看到曾經的我,我真心想幫助這些朋友。
說起讀書和學習,國內外不少前輩先賢都有論述的文章,先我們耳熟能詳的:“學而不思則罔,思而
不學則殆;知之為知之,不知為不知……”等出自《論語》的至理名言就已流傳千古,我一個剛及而立的
后學晚輩,竟然也敢以《論》起談,豈不是在自暴已丑,是要叫人笑掉大牙的嘛。但是我想,圣賢們的文
章高瞻遠矚,高屋建瓴,高處不勝寒哪,以至于應者寥寥,我基于自身實力水平,也想借這個場合,站在
稍低一層的層次,談一談這些年我學習過程中的一些感受。
先從一個典故開始吧。
春秋五霸之一的齊桓公,一次在堂上讀書,堂下一名叫輪扁的技工師傅看到了,就放下手上的工作,
走到堂上問桓公:“請問桓公在看什么書?”
齊桓公回答他說:“這是圣人的書。”
輪扁接著問:“圣人在哪呢?”
齊桓公回答:“圣人已經死了!”
輪扁說道:“那桓公所讀的,不過是古人留下來的糟粕罷了。”
輪扁斫輪(自序)
齊桓公聞之怒道:“寡人讀書,豈是你這個做車輪的工匠可以議論的嗎,今天你要是能說出道理還則
罷了,要是說不出來,明年的今天就是你的忌日(好吧,我承認武俠片看多了,這臺詞管不住自己都往外
蹦)。”
輪扁于是說道:“我是通過我平常工作觀察到的情況來理解的,給車做轱轆雖然不是高級崗位,但也
是個技術工種。在做車輪的時候,如果輪孔弄的太寬,那么雖然車輪能做的很光滑但用起來并不牢固,如
果輪孔弄的過緊,車輪又會很粗糙難以裝配;因此只有得心應手,不緊不松才能做出高端大氣上檔次的車
輪。可是要如何做到得心應手呢,我做輪子的時候知道存在這樣一種境界,但用嘴又說不清楚,我甚至都
沒辦法將這點技巧傳授給我的兒子,我的兒子也沒辦法從我這兒學到這一點,所以雖然我都七十多了還得
在這兒做輪子。因此我想說的是,古人和他們那些不能言傳的東西想必也早一起都死去了,所以桓公所讀
的,不過是古人留下來的糟粕而已!”
文中沒有寫明輪扁老師傅結局如何,但是想來老人家還是有極大的幾率繼續給桓公做車輪子的,輪扁
(當然其實是莊子老人家借輪扁的口)講的很有道理,找個熟練工不容易啊。
讀到這里,我估摸著有些朋友已經在暗自嘀咕:看我這意思,似乎是在宣揚讀書無用論了喲,出版社
負責審校的同學,恐怕也已準備著把我這段序文刪掉。都別著急,毛主席一直教導我們,要用辯證的眼光
看待問題。古人說的不一定都對,我覺著問題的關鍵不在于看還是不看書,關鍵點首先是所閱讀的圖書質
量,作者有沒有把要表達的意思闡述清楚,其次是讀者們有沒有認真閱讀,獨立思考,真正領會作者想要
表達的思想。
盡管時下寫文字有種種限制,但是得益于近些年出版行業發達,現如今世面上講經驗、談技巧、擺案
例類的圖書紛雜涌現,對于IT 技術領域這類圖書就更多了(因為IT 行業本就是門實踐性很強的技術)。
在書中應對案例中出現的故障,作者們自己往往駕輕就熟,揮灑之間數千字,似乎也講的透徹,但是初學
者朋友可能看的云里霧里似懂非懂而不自知。仿佛學到了什么,但真正應對故障時卻手忙腳亂,場景稍有
變化甚至都不知道從何處著手處理。這種情況若對應到《輪扁斫輪》這則典故,說明操作者還沒有達到“不
徐不疾,得之于手而應于心”的境界。
讀者朋友們認真看過書中的內容,可是實際工作中卻不能很好的應用,這究竟是什么緣故呢,我想大
概就是前面所說的兩點關鍵因素,詳細說來如下:
其一:可能作者沒有(想或不想)把真正的精髓寫出來。目前比較暢銷的IT 圖書,其作者大都
這則典故出自《莊子外篇·天道十三》,叫做《輪扁斫輪》,原文如下:“桓公讀書于堂上,輪扁
斫輪于堂下,釋椎鑿而上,問桓公曰:“敢問:公之所讀者,何言邪?”公曰:“圣人之言也。”曰:
“圣人在乎?”公曰:“已死矣。”曰:“然則君之所讀者,古人之糟粕已夫!”桓公曰:“寡人讀書,
輪人安得議乎!有說則可,無說則死!”輪扁曰:“臣也以臣之事觀之。斫輪,徐則甘而不固,疾則
苦而不入,不徐不疾,得之于手而應于心,口不能言,有數存焉于其間。臣不能以喻臣之子,臣之
子亦不能受之于臣,是以行年七十而老斫輪。古之人與其不可傳也死矣,然則君之所讀者,古人之
糟粕已夫!”
提 示
是來自一線的工程師,隨著這些年圖書出版門檻的降低,很多人有機會能將自己工作學習過程中
積累的經驗寫出來(我認為這也是國內IT 圖書中少見思想類圖書的原因)。優秀的IT 工程師都
是出色的實踐者,他們技術掌握的比較扎實,接觸面廣,經驗豐富,當遇到問題時,處理的方法
往往都是下意識的選擇,沒有為什么,就是要這么做。在寫作的時候也是下意識就將過程寫了出
來,而沒能把思路闡釋清楚。
其二:并非書寫的不好,可能由于讀者自身層次的原因,沒能正確理解作者表達的精髓。對于讀
者來說,找到一本好書難,讀透一本好書更難。過去有一種說法叫做:“書讀百遍,其意自現”,
我覺著這點在IT 技術領域的局限是很大的,雖然任誰也不能否認閱讀的作用是巨大的,可是,
正如我前面談到的,IT 行業是一門實踐性非常強的技術,按照過去的老話講,IT 工程師也是個
手藝人。因為行業的特點,看的懂和做的到是兩碼事,盡管每讀一遍都會有新的理解,但是這種
理解必須要與實踐相結合才能發揮最大的威力。
對此,莊子老人家其實也早已高度抽象地概括為:視而可見者,形與色也;聽而可聞者,名與聲也。
世人以形色名聲為足以得彼之情。夫形色名聲,果不足以得彼之情,則知者不言,言者不知,而世豈識
之哉!
要想學的好,首先所讀的書必須擁有比較高的質量,其次學習也必須能學到書中的精華,所以您瞧,
有多種因素可能會給學習的質量造成干擾。再舉這樣一個案例,DBA 管理的系統出現響應慢的情況,通
過分析發現是由于之前執行的某項操作,正是該操作占用了過多的資源才導致系統響應變慢,針對這種情
況怎么處理呢。一定有些資料中提到,要殺掉占用過多資源的進程,以釋放資源,提高系統的響應效率,
并且有實際的案例佐證此方案的有效。于是在這個場景中,DBA 為了緩解系統負載壓力,利用之前看過
的材料中提到的方法,手動殺掉了持有該操作的進程。
若僅把所執行的操作為獨立個體來看,這當然是個很好的案例,有可能系統負載立刻就得到了明顯下
降,但問題有沒有得到真正解決呢?深層次的根源究竟又是什么呢?如果沒有弄清楚這些情況,那么所做
的操作有可能不起效果(這就算好消息了),甚至有可能充滿了風險。因為不是所有占用較多資源的進程
都是不正常的,也不是所有進程都能隨便中止,不管遇到的是什么問題,能找出造成問題的關鍵所在最重
要。元芳,你怎么看!
不管要學習哪方面的知識,在學習過程中可參考的資料會有很多,在互聯網時代更是可以用浩瀚來形
容,這種現狀換個角度看反倒更令讀者們無所適從,不知道該選擇看哪些資料好。若讓我來選擇,首要推
薦的仍然是官方提供的技術文檔,對于Oralce 數據庫可以到tahiti.oracle.com 瀏覽,對于MySQL 數據庫
可以到dev.mysql.com/doc 瀏覽,官方文檔始終都是內容最權威、最全面的學習資料,恒久遠永流傳。對
于有一定經驗的朋友,可能會認為官方文檔的深度不夠,案例也少,對于這部分朋友,可以去看一些專門
的文章和圖書,在選擇圖書時只有一個準則,就是要讀有口碑的書。目前各大網絡商城都有評分和評論系
統,購買前先看一下其他用戶的意見作為參考會很有幫助。
我讀過的很多圖書,文章開篇總要吹些牛皮,吸引讀者的眼球,把讀者的胃口調起來,希望大家能有
興趣接著往后看(歡迎對號入座)。像三思這種開篇不僅自我貶低,且一槍打擊一大片的,怕著實不多見,
我想這跟我的性格有關—耿直(好吧!我承認其實是情商低),也跟我所從事的職業有關—技術,來
不得半點兒虛假。
好了,講到這里,是時候跟大家介紹下本書的內容了(分明是要開始王婆賣瓜自賣自夸),這并不是
一本逐個介紹MySQL 命令的書,不是一本用戶幫助手冊,不是這個功能講完講那個功能的書。在寫作之
初我就考慮要設定一條主線,不是依次講特性,而是依據用戶接觸和學習MySQL 的脈絡去把握,介紹
MySQL 數據庫從無到有,其安裝、配置、管理、優化的過程,在這個過程中再穿插數據導入導出、性能
/狀態監控、備份恢復和優化方面的內容,最后再談一談MySQL 數據庫服務從單臺到多臺,從單實例到
多實例集群的部署等稍顯高階的應用方案。
說起來,這其實是一本站在初學者的視角,描述他不斷學習和提高的路徑的圖書,在這個過程中,我
當然不可能面面俱到地講到所有的技術特性,不過在介紹某些知識點時,會有意地忽略一些細節,是希望
能讓讀者有思考的空間,既能看到優勢同時也學會看到不足,找出更適合自己的解決方案,逐漸形成自己
的操作思路,窺見“不徐不疾,得之于手而應于心”的境界。
最后,我想說的是,官方文檔也好,技術圖書也好,這些都是外在因素,最重要的因素仍然是自己,
是否真正喜歡所要學習的技術,是否確實愿意花費時間和精力去深入研究,是否能夠承受枯燥的應用和測
試。只要打好了基礎,看多了案例,精通了技能,學好了本領,明了方方面面前因后果,用不了多久,就
可以成為大拿,升職加薪,當上技術總監,出任CTO,迎娶白富美,登上人生頂峰!是不是想想都激動
啊!小伙伴兒們,那就從現在開始吧,翻開第一頁,MySQL 在向你招手。
1.1 開源軟件的故事 ·········································· 1
1.1.1 GNU 說,我代表著一個夢想 ··········· 3
1.1.2 FSF 說,兄弟我頂你 ·························· 4
1.1.3 兄弟,你是“自由軟件”嗎 ············· 4
1.1.4 GPL 說,持證上崗光榮 ····················· 5
1.1.5 開源軟件說,隊長別開槍,
咱們是一伙的 ······································ 6
1.2 MySQL 的悄然而至 ···································· 7
1.2.1 起源 ······················································· 7
1.2.2 根據地成立 ·········································· 9
1.2.3 快速發展,大踏步向前······················ 9
1.2.4 世事難料,不經歷風雨怎能
見彩虹 ················································· 12
1.2.5 向前向前向前 ···································· 14
1.2.6 以開源的心態學開源 ························ 15
第2 章 安裝MySQL 數據庫軟件 ··············· 17
2.1 Windows 平臺安裝 ···································· 18
2.1.1 安裝包方式安裝 ································ 19
2.1.2 壓縮包方式安裝 ································ 28
2.1.3 Windows 平臺的一些限制 ··············· 29
2.2 Linux 平臺安裝 ·········································· 30
2.2.1 RPM 包方式安裝 ······························ 31
2.2.2 源碼編譯方式安裝 ···························· 37
2.2.3 二進制包方式安裝 ···························· 40
第3 章 管理MySQL 數據庫服務 ·············· 45
3.1 Windows 平臺下的MySQL 服務 ············ 46
3.2 Linux 平臺下的MySQL 服務 ·················· 47
3.2.1 創建數據庫服務 ································ 47
3.2.2 啟動數據庫服務 ································ 51
3.2.3 配置MySQL 數據庫 ························· 51
3.3 MySQL 服務管理配置 ······························ 54
3.3.1 創建管理腳本····································· 55
3.3.2 開機自動啟動····································· 56
第4 章 管理MySQL 庫與表 ····················· 58
4.1 上帝說,要有庫 ········································· 58
4.1.1 說刪咱就刪 ········································· 60
4.1.2 說建咱就建 ········································· 61
4.2 上帝說,要有表 ········································· 64
4.2.1 想建咱就建 ········································· 66
4.2.2 想看咱就看 ········································· 71
4.2.3 想改咱就改 ········································· 74
4.2.4 想刪咱就刪 ········································· 78
第5 章 MySQL 數據庫中的權限體系 ········ 81
5.1 談談權限處理邏輯 ····································· 81
5.1.1 能不能連接 ········································· 81
5.1.2 能不能執行操作 ································ 82
目 錄
5.1.3 權限變更何時生效 ···························· 82
5.2 權限授予與回收 ········································ 83
5.2.1 創建用戶············································· 84
5.2.2 授予權限············································· 91
5.2.3 查看和收回用戶權限 ························ 95
5.2.4 刪除用戶············································· 98
5.3 權限級別 ····················································· 99
5.3.1 全局 ····················································· 99
5.3.2 數據庫 ··············································· 103
5.3.3 表 ······················································· 108
5.3.4 列 ······················································· 110
5.3.5 程序 ··················································· 112
5.4 賬戶安全管理 ··········································· 113
5.4.1 用戶與權限設定原則 ······················ 113
5.4.2 小心歷史文件泄密 ·························· 114
5.4.3 管理員口令丟失怎么辦·················· 115
第6 章 字符,還有個集 ·························· 118
6.1 基礎掃盲 ··················································· 118
6.1.1 關于字符集 ······································ 119
6.1.2 關于校對規則 ·································· 120
6.2 支持的字符集和校對規則 ······················ 120
6.3 指定字符集和校對規則 ·························· 123
6.3.1 服務端設置默認字符集·················· 124
6.3.2 連接時指定 ······································ 126
6.3.3 保存時指定 ······································ 132
6.4 字符集操作示例 ······································ 136
6.5 角落里的字符集設置 ······························ 139
6.5.1 字符串的字符集 ······························ 139
6.5.2 錯誤提示的字符集 ·························· 140
6.5.3 國家字符集 ······································ 142
第7 章 選擇對象的存儲引擎 ··················· 144
7.1 存儲引擎體系結構 ·································· 145
7.2 常見存儲引擎 ··········································· 148
7.2.1 MEMORY 存儲引擎 ·······················149
7.2.2 CSV 存儲引擎 ··································152
7.2.3 ARCHIVE 存儲引擎 ·······················153
7.2.4 BLACKHOLE 存儲引擎·················154
7.2.5 MERGE 存儲引擎 ···························157
7.2.6 FEDERATED 存儲引擎 ·················159
7.3 MyISAM 存儲引擎 ··································165
7.3.1 MyISAM 引擎特性··························167
7.3.2 MyISAM 引擎存儲格式 ·················169
7.4 InnoDB 存儲引擎 ·····································171
7.4.1 默認的存儲引擎 ······························173
7.4.2 InnoDB 引擎配置 ····························175
7.4.3 創建和使用InnoDB 表對象 ···········182
7.4.4 邏輯存儲結構···································185
7.4.5 多版本機制 ·······································188
7.4.6 聯機修改表對象結構 ······················189
7.4.7 InnoDB 表對象的限制條件 ············201
第8 章 MySQL 數據庫文件結構 ············· 204
8.1 初始化選項文件 ·······································204
8.2 錯誤日志文件 ···········································208
8.3 查詢日志文件 ···········································209
8.3.1 慢查詢日志 ·······································209
8.3.2 普通查詢日志···································211
8.3.3 配置查詢日志···································212
8.4 二進制日志文件 ·······································215
8.4.1 這個必須有 ·······································215
8.4.2 它不是隨便的人 ······························216
8.4.3 想說懂你不容易 ······························217
8.5 中繼日志及復制狀態文件 ······················219
8.6 表對象數據文件 ·······································221
8.7 其他文件 ···················································221
8.7.1 進程id 文件······································221
8.7.2 套接字文件 ·······································222
8.7.3 自動配置文件···································222
第9 章 數據導出與導入 ·························· 223
9.1 利用CSV 存儲引擎加載數據 ················ 223
9.2 mysqlimport 命令行工具導入數據 ········ 224
9.2.1 導入超簡單 ······································ 225
9.2.2 分列超輕松 ······································ 226
9.2.3 換行很容易 ······································ 228
9.3 SQL 語句導入數據 ·································· 229
9.3.1 快來認識下LOAD DATA INFILE · 230
9.3.2 字符集咋處理的吶 ·························· 232
9.3.3 要導入的數據文件放哪兒 ············· 234
9.3.4 數據文件的前N 行記錄不想導
咋辦 ··················································· 236
9.3.5 列和行的精確處理 ·························· 236
9.3.6 對象結構與數據文件不符咋整 ····· 246
9.4 SQL 語句導出數據 ·································· 249
9.4.1 這些知識,不學都會 ······················ 250
9.4.2 這些知識,一學就會 ······················ 251
第10 章 MySQL 數據備份和數據恢復 ····· 254
10.1 備份與恢復名詞解釋 ···························· 254
10.1.1 物理備份VS 邏輯備份 ················ 255
10.1.2 聯機備份VS 脫機備份 ················ 256
10.1.3 本地備份VS 遠程備份 ················ 257
10.1.4 完整備份VS 增量備份 ················ 257
10.1.5 完整恢復VS 增量恢復 ················ 258
10.2 備份工具知多少 ···································· 258
10.2.1 復制表對象相關文件的方式
創建備份集 ···································· 258
10.2.2 使用mysqlhotcopy 命令行工具
創建備份········································· 259
10.2.3 使用mysqldump 命令行工具
創建邏輯備份 ································ 259
10.2.4 使用SQL 語句創建備份 ·············· 260
10.2.5 冷復制方式創建物理備份 ··········· 260
10.2.6 二進制日志創建增量備份············260
10.2.7 第三方工具創建聯機備份············260
10.3 Hey Jude, Don't be afraid, 備份咱有
mysqldump ··············································261
10.3.1 單個數據庫的備份任務 ················261
10.3.2 備份多個數據庫 ····························263
10.3.3 輸出定界格式文件 ························263
10.3.4 恢復mysqldump 創建的備份集 ··265
10.3.5 多學些mysqldump 命令行參數 ··266
10.3.6 自動化備份策略 ····························272
10.4 冷備、增量備和備份恢復策略 ············275
10.4.1 創建冷備份·····································275
10.4.2 創建增量備份 ································276
10.4.3 備份和恢復策略 ····························278
10.5 XtraBackup 聯機備份 ····························280
10.5.1 關于XtraBackup ····························280
10.5.2 先試試xtrabackup 命令 ················282
10.5.3 再用用innobackupex 命令 ···········284
10.5.4 創建增量備份 ································287
10.5.5 執行恢復 ·········································290
10.5.6 打包和壓縮備份集 ························295
10.5.7 自動化備份腳本 ····························296
第11 章 MySQL 復制特性 ····················· 298
11.1 創建復制環境 ·········································300
11.1.1 最簡單的復制環境部署方法 ·······300
11.1.2 復制環境配置寶典 ························307
11.1.3 常用的復制環境管理命令············310
11.2 復制特性的實施原理和關鍵因素········315
11.2.1 復制格式 ·········································315
11.2.2 中繼日志文件和狀態文件············319
11.2.3 復制過濾規則 ································322
11.3 高級應用技巧 ·········································332
11.3.1 通過XtraBackup 創建Slave
節點 ·················································333
11.3.2 利用Slave 節點創建備份 ············ 336
11.3.3 部署級聯Slave 增強復制性能 ···· 340
11.3.4 半同步機制 ···································· 343
11.3.5 復制環境中的故障切換 ··············· 348
11.3.6 延遲復制 ········································ 352
第12 章 五花八門的MySQL 管理工具 ···· 354
12.1 這些年MySQL 提供的命令行工具 ···· 354
12.1.1 mysql_install_db—MySQL
建庫工具········································· 355
12.1.2 mysqld_safe—MySQL 啟動
工具 ················································· 356
12.1.3 mysqld—MySQL 主進程 ········· 357
12.1.4 mysqld_multi—MySQL 多實例
管理工具········································· 360
12.1.5 mysql—專業命令行工具 ········· 362
12.1.6 mysqladmin—管理工具 ··········· 368
12.1.7 其他常用命令 ································ 371
12.2 phpMyAdmin ·········································· 372
12.2.1 安裝phpMyAdmin ························ 372
12.2.2 配置phpMyAdmin ························ 376
12.2.3 試用phpMyAdmin ························ 379
12.3 MySQL Workbench ······························· 383
12.3.1 執行SQL 查詢 ······························ 384
12.3.2 數據建模 ········································ 386
12.3.3 服務管理 ········································ 391
12.4 其他第三方圖形管理工具 ···················· 394
第13 章 性能調優與診斷 ························ 396
13.1 測試方法 ················································· 397
13.1.1 關鍵性指標 ···································· 398
13.1.2 獲取關鍵性指標 ···························· 402
13.1.3 TPCC 測試 ····································· 411
13.2 數據庫參數配置優化 ···························· 416
13.2.1 連接相關參數 ································ 417
13.2.2 文件相關參數 ································418
13.2.3 緩存控制參數 ································420
13.2.4 MyISAM 專用參數························423
13.2.5 InnoDB 專用參數 ··························425
13.2.6 參數優化案例 ································428
13.3 分析慢查詢日志 ·····································432
13.3.1 mysqldumpslow 命令·····················433
13.3.2 mysqlsla 命令 ·································434
13.4 關注系統狀態 ·········································438
13.4.1 MySQL 服務在做什么 ··················438
13.4.2 MySQL 語句在做什么 ··················440
13.4.3 實戰優化案例 ································448
第14 章 部署MySQL 服務監控平臺 ······· 451
14.1 監控狀態,我用Nagios ························452
14.1.1 初始化環境·····································452
14.1.2 初識監控項·····································454
14.1.3 配置監控項·····································460
14.1.4 監控服務列表 ································462
14.2 監控性能,我有Cacti ···························464
14.2.1 初始化環境與安裝Cacti ··············466
14.2.2 配置MySQL 監控模板 ·················474
14.2.3 監控MySQL 實例 ·························478
第15 章 搭建MySQL 高可用體系 ·········· 483
15.1 追求更高穩定性的服務體系 ················483
15.1.1 可擴展性 ·········································484
15.1.2 高可用性 ·········································485
15.2 Slave+LVS+Keepalived 實現高可用 ···488
15.2.1 配置LVS ········································489
15.2.2 配置RealServer······························491
15.2.3 增加高可用能力 ····························494
15.3 Dual-Master 高可用環境 ·······················497
15.3.1 故障隨便切換 ································498
15.3.2 IP 自動飄移 ····································504
15.3.3 架構設計有講究 ···························· 510
15.4 DRBD,為Master 節點數據提供
更高保障 ················································· 512
15.4.1 基礎知識掃掃盲 ···························· 512
15.4.2 一個好漢多個幫 ···························· 515
15.5 官方集群正統MySQL Cluster ············· 518
15.5.1 Cluster 體系結構概述 ···················518
15.5.2 Cluster 安裝與配置························520
15.5.3 Cluster 應用初體驗························524
15.6 繼續擴展數據庫服務 ····························527
15.6.1 該拆分時要拆分 ····························528
15.6.2 處理策略得想清 ····························532
- 數據庫技術與應用實踐教程(SQL Server 2019) [主 編 嚴暉 周肆清]
- 數據庫原理與應用——基于SQL Server 2016 [主編 彭浩 黃勝 鄒競]
- Access數據庫基礎教程實驗指導與習題集 [主 編 饒拱維 楊貴茂 吳華光]
- Access 數據庫基礎教程 [主編 饒拱維 楊貴茂 郭其標]
- 數據庫原理及應用(MySQL版) [主編 高亮 韓玉民]
- 數據庫技術與應用(SQL Server 2008版)(第二版) [主編 嚴暉 王小玲]
- 數據庫技術與應用實踐教程(SQL Server 2008)(第二版) [主編 嚴暉 周肆清]
- Access 2010數據庫應用教程(第二版) [主編 李亞]
- Access 2010數據庫實用教程 [主編 張明 宣繼濤]
- 數據庫原理及應用——SQL Server 2012 [主編 賴玲 李祥琴 胡秀]
- 數據庫原理及應用上機指導與習題解答——SQL Server 2012 [主編 王婭紛 賴玲 李祥琴 胡]
- Visual FoxPro數據庫程序設計教程(第四版) [主編 王鳳領]
- 數據庫系統原理與應用 [主編 沈祥玖 張岳]
- Access 2010數據庫程序設計 [主編 紀澍琴 于雪晶]
- Access 2010實做教程 [主編 王益斌 趙欣]
- 數據庫系統原理與應用(第三版)(SQL Server 2012) [主編 劉淳]
- 數據庫技術(第二版)——Access 2010及其應用系統開發 [李禹生 李承犁 劉淵源 等編著]
- Access 2010數據庫技術基礎及應用 [主編 饒拱維 楊貴茂]
- 數據庫技術及應用開發學習輔導 [李云峰 李婷 編著]
- Access應用技術基礎教程(2010版) [主編 何春林 宋運康]
- Access應用技術實驗指導(2010版) [主編 何春林 宋運康]
- Access 2010數據庫技術與應用教程習題及實驗指導 [主編 陳朝華 肖東]
- Access 2010數據庫技術與應用教程 [主編 趙義霞 季軍杰]
- Visual FoxPro程序設計 [主編 何櫻]
- Visual FoxPro程序設計教程(第二版)習題集與解答 [主編 何振林 歐劍]
- Visual FoxPro程序設計教程(第二版) [主編 何振林 趙亮]
- 數據庫技術及應用開發 [李云峰 李 婷 編著]
- Access 數據庫案例教程(第二版) [主編 應紅]
- Access 2010數據庫應用教程 [主編 王迤冉 彭海云]
- 數據庫技術與應用(SQL Server 2008版)實踐教程 [主編 王小玲 嚴暉]