久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

MySQL中關(guān)于Tablecache該如何設(shè)置-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)MySQL中關(guān)于Table cache該如何設(shè)置,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站設(shè)計制作、網(wǎng)站制作、漾濞網(wǎng)絡(luò)推廣、小程序設(shè)計、漾濞網(wǎng)絡(luò)營銷、漾濞企業(yè)策劃、漾濞品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們大的嘉獎;成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供漾濞建站搭建服務(wù),24小時服務(wù)熱線:028-86922220,官方網(wǎng)址:sd-ha.com

因為今天突然有個凌晨5點值班任務(wù),隨意翻起同事的書來,看到表對象緩存,這個跟自己平時理解,稍微有差異。所以整理了一下table_definition_cache,table_open_cache和table_open_cache_instances。

先看看官網(wǎng)怎么說:

1.table_definition_cache

the number of table definitions (from .frm files) that can be stored in the definition cache. If you use a large number of tables, you can create a large table definition cache to speed up opening of tables. The table definition cache takes less space and does not use file descriptors, unlike the normal table cache.

理解下來,就是控制總frm文件的數(shù)量,還是個hash表,內(nèi)部維護(hù)。如果打開的表實例的數(shù)量超過了table_definition_cache設(shè)置,

LRU機(jī)制將開始標(biāo)記表實例以進(jìn)行清除,并最終將它們從數(shù)據(jù)字典緩存中刪除。

簡單通俗點frm文件有多少,就設(shè)置多少了。

2.table_open_cache

The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires. You can check whether you need to increase the table cache by checking the Opened_tables status variable

所有線程打開的表的數(shù)量。增加這個值會增加mysqld需要的文件描述符的數(shù)量??梢酝ㄟ^檢查Opened_tables狀態(tài)變量來檢查是否需要增加表緩存。

是不是可以理解為ibd/MYI/MYD 文件,打開數(shù)量了。但mysql內(nèi)部需要對表進(jìn)行操作的時候,第一需要找到最上層文件的句柄信息,table_open_cache_instances是能提供的,之后對應(yīng)的尋找ibd,MYI,MYD文件。官網(wǎng)對于這部分沒有明確說明

3.table_open_cache_instances

The number of open tables cache instances. To improve scalability by reducing contention among sessions, the open tables cache can be partitioned into several smaller cache instances of size table_open_cache / table_open_cache_instances . A session needs to lock only one instance to access it for DML statements. This segments cache access among instances, permitting higher performance for operations that use the cache when there are many sessions accessing tables.

打開的表緩存實例的數(shù)量。為了通過減少會話間的爭用來提高可伸縮性,可以將打開的表緩存劃分為幾個大小為table_open_cache / table_open_cache_instances的較小緩存實例。一個會話只需要鎖定一個實例就可以訪問DML語句。寫到這里就已經(jīng)大致了解到 如下關(guān)系:

table_definition_cache > table_open_cache_instances > table_open_cache

4.table相關(guān)的限制有哪些?

mysql是多線程,對于并發(fā)同一個文件,不同數(shù)據(jù)的情況下,會打開多個文件,會存在哪些限制呢?下面是源代碼里邏輯是怎樣

1)table_definition_cache

.frm文件其實大值只能到2000,跟官網(wǎng)給得大值沒關(guān)系

MySQL中關(guān)于Table cache該如何設(shè)置

MySQL中關(guān)于Table cache該如何設(shè)置

Max值和說明有沖突,實際確認(rèn)下來就是2000

2)open_files_limit

MySQL中關(guān)于Table cache該如何設(shè)置

limit_1= 10 + max_connections + table_cache_size * 2;

limit_2= max_connections * 5;

limit_3= open_files_limit ? open_files_limit : 5000;

可以看出max_connections有關(guān),需要借助于table open file 的信息

3)max_connections超出打開文件數(shù)量的伐值的時候,也跟table_open_cache有關(guān)

MySQL中關(guān)于Table cache該如何設(shè)置

4)table_cache_size 計算方式

MySQL中關(guān)于Table cache該如何設(shè)置

備注:TABLE_OPEN_CACHE_MIN=table_open_cache

5.定期查看open table 情況,

MySQL中關(guān)于Table cache該如何設(shè)置

通過 show global status like ‘%Open%_table%’; 確認(rèn)是否調(diào)優(yōu)這個參數(shù)

6.常見故障應(yīng)對:

如:在運(yùn)行數(shù)據(jù)庫通過 show processlist 可看到大量的 Opening tables、closing tables狀態(tài),導(dǎo)致應(yīng)用端訪問操作。

需要確認(rèn) table_open_cache=大并發(fā)數(shù)表數(shù)量(join里可能用到2張表),時候滿足當(dāng)前配置

如:但并發(fā)線程數(shù)達(dá)到1000,假設(shè)這些并發(fā)連接中有40%是訪問2張表,其他都是單表,那么cache size就會達(dá)到(100040%2+100060%*1)=1400

建議定期監(jiān)控值:

Open_tables / Opened_tables >= 0.85 表的重復(fù)使用率

Open_tables / table_open_cache <= 0.95 緩存里存在已打開的表

1)5.7版本已經(jīng)支持在線動態(tài)改配置信息

set global table_definition_cache=2000;

set global table_open_cache=3000;

set global max_connection= 2000;

table_open_cache_instances參數(shù)修改需要重新啟動服務(wù)。

2)無法更改的時候,可通過flush操作,但存在問題

MySQL closes an unused table and removes it from the table cache under the following circumstances: When the cache is full and a thread tries to open a table that is not in the cache.When the cache contains more than table_open_cache entries and a table in the cache is no longer being used by any threads.When a table-flushing operation occurs. This happens when someone issues a FLUSH TABLES statement or executes a mysqladmin flush-tables or mysqladmin refresh command.

這里好奇FLUSH TABLE操作,有如下隱患:

關(guān)閉所有打開的表,強(qiáng)制關(guān)閉所有正在使用的表,并刷新查詢緩存和準(zhǔn)備好的語句緩存。FLUSH TABLES還會從查詢緩存中刪除所有查詢結(jié)果,比如RESET查詢緩存語句。

備注:

另外 table_definition_cache為每個表的表空間中可以同時打開的InnoDB文件的數(shù)量定義了一個軟限制,這也是由innodb_open_files控制的。

如果設(shè)置了table_definition_cache和innodb_open_files,則使用最高設(shè)置。如果兩個變量都沒有設(shè)置,則使用默認(rèn)值更高的table_definition_cache。

總結(jié):

Table緩存關(guān)于的參數(shù)table_definition_cache,table_definition_cache,table_open_cache_instances 按照實際環(huán)境和需求進(jìn)行設(shè)置外,還有跟max_connections也要設(shè)置合理。有些環(huán)境里發(fā)現(xiàn)max_connections過大,過小設(shè)置的問題,設(shè)置過大可能會存在等待的情況

這些參數(shù)控制不好,會給MySQL數(shù)據(jù)庫系統(tǒng)帶來性能上的瓶頸。如果把握不是很準(zhǔn),有個很保守的設(shè)置建議:把MySQL數(shù)據(jù)庫放在生產(chǎn)環(huán)境中試運(yùn)行一段時間,然后把參數(shù)的值調(diào)整得比Opened_tables的數(shù)值大一些,并且保證在比較高負(fù)載的極端條件下依然比Opened_tables略大。

關(guān)于MySQL中關(guān)于Table cache該如何設(shè)置就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

文章題目:MySQL中關(guān)于Tablecache該如何設(shè)置-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://sd-ha.com/article22/deiicc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、網(wǎng)站內(nèi)鏈、網(wǎng)頁設(shè)計公司、做網(wǎng)站、小程序開發(fā)、建站公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司