天天看點

收藏的部落格 -- Redis學習

centos 7安裝和使用redis,授權遠端連接配接(★firecat推薦★) https://redis.io/ https://github.com/antirez/redis https://github.com/redis/hiredis -- make編譯,安裝路徑是/usr/local/lib/libhiredis.a https://github.com/acl-dev/acl/tree/master/lib_acl_cpp/include/acl_cpp/redis

Redis是REmoteDIctionaryServer(遠端字典伺服器)的縮寫,它以字典結構存儲資料,并允許其他應用通過TCP協定讀寫字典中的内容。同大多數腳本語言中的字典一樣,Redis字典中的鍵值除了可以是字元串,還可以是其他資料類型。到目前為止Redis支援的鍵值資料類型如下:

●字元串類型

●散列類型

●清單類型

●集合類型

●有序集合類型

1、黃建宏

http://huangz.me/ http://blog.huangz.me/ http://note.huangz.me/ https://github.com/huangz1990

Redis 設計與實作

Redis 指令參考

帶有詳細注釋的 Redis 3.0 代碼(annotated Redis 3.0 source code)

原版3.0:

https://github.com/antirez/redis/tree/3.0

, /src/version.h檔案有詳細的版本号

編譯方法:

[root@localhost redis_study]# chmod -R 777 redis-3.0-annotated-unstable

[root@localhost redis_study]# cd redis-3.0-annotated-unstable/

[root@localhost redis-3.0-annotated-unstable]# make

閱讀源碼的方法1:

在Qt Creator中使用make建構,運作,調試通用C/C++項目

閱讀源碼的方法2:

解壓,在redis-3.0-annotated-unstable檔案夾建立一個CMakeLists.txt檔案,内容如下:

cmake_minimum_required(VERSION 2.8)
 
project(redis_src)
 
aux_source_directory(./src DIR_SRCS)
aux_source_directory(./deps/hiredis DIR_DEPS_1)
aux_source_directory(./deps/jemalloc/src DIR_DEPS_2)
aux_source_directory(./deps/linenoise DIR_DEPS_3)
 
include_directories(./deps/hiredis)
include_directories(./deps/jemalloc/include)
include_directories(./deps/linenoise)
 
add_executable(${PROJECT_NAME} ${DIR_SRCS} ${DIR_DEPS_1} ${DIR_DEPS_2} ${DIR_DEPS_3})

      

--redis-3.0-annotated-unstable

   --CMakeLists.txt

   --src

   --deps

2、Redis開發與運維

https://cachecloud.github.io/ http://carlosfu.iteye.com/ http://hot66hot.iteye.com/ https://github.com/CodisLabs/codis

3、淺墨

http://0xffffff.org/

淺墨

https://github.com/hurley25/ANet

4、可視化用戶端

(1)Redis Desktop Manager

https://redisdesktop.com/ https://github.com/uglide/RedisDesktopManager/ https://blog.csdn.net/sailorhdx/article/details/81538131

(2)TreeNMS for Redis

http://www.treesoft.cn/dms.html

5、走在前往架構師的路上

http://blog.csdn.net/Androidlushangderen http://blog.csdn.net/Androidlushangderen/article/category/2647211

6、叢集與代理

由于單台redis伺服器的記憶體管理能力有限,使用過大記憶體redis伺服器的性能急劇下降,且伺服器發生故障将直接影響大面積業務。為了擷取更好的緩存性能及擴充型,我們将需要搭建redis叢集來滿足需求。因redis 3.0 beta支援的叢集功能不适合生産環境的使用,是以我們采用twitter正在使用的twemproxy來搭建redis緩存伺服器叢集,目前使用者包括Pinterest、Tumblr、Twitter、Vine、Kiip、Wuaki.tv、Wanelo、Kontera、Wikimedia、Bright、56.com、Snapchat、Digg、Gawkermedia、3scale.net等。 Twemproxy是memcached和redis協定的代理伺服器,并能有效減少大量連接配接對redis伺服器的性能影響。

redis的叢集方案對比(Codis對比Twemproxy)

Memcache/Redis叢集管理探索與實作:美圖開源PaaS平台資源網關 -- 美圖改造twemproxy

https://github.com/twitter/twemproxy https://github.com/meitu/twemproxy

-- 美圖,multi-process twemproxy,仿Nginx實作多程序網絡模型

7、他山之石,360開源的類Redis存儲系統:Pika

Pika 是 360 DBA 和基礎架構組聯合開發的類 Redis 存儲系統,完全支援 Redis 協定,使用者不需要修改任何代碼,就可以将服務遷移至 Pika。有維護 Redis 經驗的 DBA 維護 Pika 不需要學習成本。 Pika 主要解決的是使用者使用 Redis 的記憶體大小超過 50G、80G 等等這樣的情況,會遇到啟動恢複時間長,一主多從代價大,硬體成本貴,緩沖區容易寫滿等問題。Pika 就是針對這些場景的一個解決方案。

重點: Pika 的單線程的性能肯定不如 Redis,Pika 是多線程的結構,是以線上程數比較多的情況下,某些資料結構的性能可以優于 Redis。 Pika 肯定不是完全優于 Redis 的方案,隻是在某些場景下面更适合。是以目前公司内部 Redis,Pika 是共同存在的方案。DBA 會根據業務的場景挑選合适的方案。

https://github.com/Qihoo360/pika
下一篇: ESC體驗心得

繼續閱讀