驗證InnoDB和memcached安裝

3. 驗證InnoDB和memcached安裝



現在都安裝好了,你需要將InnoDB和memcached連接起來:

# Point memcached-related commands at the memcached attached to the mysqld process.
export MEMCACHED_SERVERS=127.0.0.1:11211
# Store the contents of a modestly sized text file in memcached, with the data passed
# to MySQL and stored in a table. The key is the basename of the file, 'mime.types'.
memcp /etc/apache2/mime.types
# Retrieve the data we just stored, from the memory cache.
memcat mime.types


這裏有一個通過ASCII協議,使用telnet來發送memcached命令,接收結果的示例:

telnet 127.0.0.1 11211
set a11 10 0 9
123456789
STORED
get a11
VALUE a11 0 9
123456789
END
quit



爲了說明同樣的數據已經存儲到MySQL,連接到MySQL服務器,並執行:

mysql> select * from test.demo_test;


現在,關閉MySQL服務,也同時關閉了集成的memcached服務。後面嘗試訪問memcached數據,失敗並返回連接錯誤。一般情況下,memcached數據這時會消失,你會寫應用程序邏輯來當memcached重啓後將數據導入到內存。但是MySQL / memcached集成自動化了這個過程:


? 重啓MySQL服務。


? 運行install plugin語句,再次啓動InnoDB memcached插件。


? 現在任何memcat命令或get操作再次返回你存儲在早期memcached會話中的鍵/值對。當請求鍵,而相應的值已經不在內存緩存中,它自動從MySQL表中查詢,默認test.demo_test。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章