老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

Redis集群實戰

                   redis基礎到集群實戰筆記

10年積累的成都網站建設、網站建設經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站設計后付款的網站建設流程,更有朝陽免費網站建設讓你可以放心的選擇與我們合作。

                                                                              

 

 

持久化存儲

redis介紹

redis是基于key-value的持久化數據庫存儲系統,redis和memcached服務很想,但是redis支持的數據存儲類型

服務更豐富

memcached支持value

redis支持string(字符)list(鏈表)  set(集合)  push、pop

redis比memcached服務性能好,但是比相對性的關系數據庫(如MySQL) 相對差

 

redis支持各種不同方式的排序,與memcached一樣,為了保存效率,數據都是緩存在內存中提供服務,但是redis會定時的將

數據存儲在磁盤當中,而且redis支持master-slave(主從)同步,這很類似MYSQL

 

 

redis優點

可以持久化存儲數據

性能很高:redis支持超過100k+秒的讀寫頻率。

豐富的數據類型:strings lists,hashes,Sets數據類型操作

redis支持主從復制

 

 

redis應用場景

傳統的MYSQL+MEMCACHED架構遇到的問題

MYSQL數據庫是適合進行海量數據存儲的,加上通過Memcached熱點數據放在內存cache中,隨著訪問量增長,就會出現

問題。

1需要不斷的對MYSQL拆庫拆表,Memcached也需要不斷地擴充,占據大量的運維時間

2Memcached和MYSQL數據一致性問題

3Memcached數據庫命中率低或當機,導致大量的訪問直接穿透數據庫,導致mysql無法支持訪問

4跨級方cache同步一致性問題

 

 

redis最佳應用場景

1Redis最佳使用場景全部數據是in-memory(內存)

2Redis更多的場景作為Memcached替代

3當需要除key/value之外的更多數據類型支持的時候,使用Redis更合適

4支持持久化

5需要負載均衡的場景(redis主從同步)

 

 

 

 

redis部署搭建

MASTER 192.168.2.1

SLAVE  192.168.2.4

 

 

MASTER:

[root@localhost ~]# ls

anaconda-ks.cfg  bbs  boke  install.log  install.log.syslog  mysql-5.5.32-linux2.6-x86_64.tar.gz  redis-3.0.2.tar.gz  test.sh  www

[root@localhost ~]# tar zxf redis-3.0.2.tar.gz

[root@localhost ~]# cd redis-3.0.2

[root@localhost redis-3.0.2]# make  MALLOC=jemalloc

[root@localhost redis-3.0.2]# make PREFIX=/application/redis install  指定安裝路徑

 

 

 

SLAVE

[root@localhost ~]# ls

anaconda-ks.cfg  bbs  boke  install.log  install.log.syslog  mysql-5.5.32-linux2.6-x86_64.tar.gz  redis-3.0.2.tar.gz  test.sh  www

[root@localhost ~]# tar zxf redis-3.0.2.tar.gz

[root@localhost ~]# cd redis-3.0.2

[root@localhost redis-3.0.2]# make  MALLOC=jemalloc

[root@localhost redis-3.0.2]# make PREFIX=/application/redis install  指定安裝路徑

裝完后bin有5個命令

[root@localhost bin]# ls

redis-benchmark  redis-check-aof  redis-check-dump  redis-cli  redis-sentinel  redis-server

 

redis-benchmark redis性能測試工具

redis-check-aof 更新日志檢查

redis-check-dump

redis-cli Redis命令操作工具

redis-sentinel 用于本地數據庫檢查

redis-server Redis服務的啟動程序

 

 

要想啟動Redis要做環境變量

[root@localhost redis]# export PATH=/application/redis/bin/:$PATH

[root@localhost redis]# which  redis-server

/application/redis/bin/redis-server

永久生效修改文件

[root@localhost redis]# vim /etc/profile

export PATH=/application/redis/bin/:$PATH

[root@localhost redis]# . /etc/profile

redis配置

[root@localhost redis-3.0.2]# mkdir /application/redis/conf

[root@localhost redis-3.0.2]# cp redis.conf  /application/redis/conf/

 

啟動Redis

[root@localhost redis-3.0.2]# redis-server  /application/redis/conf/redis.conf

5522:M 18 Feb 05:02:08.448 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 3.0.2 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 5522

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               

 

5522:M 18 Feb 05:02:08.463 # Server started, Redis version 3.0.2

5522:M 18 Feb 05:02:08.464 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

5522:M 18 Feb 05:02:08.470 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

5522:M 18 Feb 05:02:08.470 * The server is now ready to accept connections on port 6379

 

vm.overcommit_memory = 1提示這個錯誤

解決

[root@localhost redis-3.0.2]# sysctl  vm.overcommit_memory=1

vm.overcommit_memory = 1

 

[root@localhost redis-3.0.2]# redis-server  /application/redis/conf/redis.conf

5560:M 18 Feb 05:05:23.085 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 3.0.2 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 5560

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               

 

5560:M 18 Feb 05:05:23.087 # Server started, Redis version 3.0.2

5560:M 18 Feb 05:05:23.088 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

5560:M 18 Feb 05:05:23.088 * DB loaded from disk: 0.001 seconds

5560:M 18 Feb 05:05:23.088 * The server is now ready to accept connections on port 6379

 

成功!

 

 

測試redis

[root@localhost ~]# redis-cli

127.0.0.1:6379>

 

創建庫查看庫

127.0.0.1:6379> set  no002 xiaohu

OK

127.0.0.1:6379> get no002

"xiaohu"

 

不在命令行創建庫

[root@localhost ~]# redis-cli  -h 192.168.2.1 -p 6379 set no001 qi

OK

[root@localhost ~]# redis-cli  -h 192.168.2.1 -p 6379 get no001

"qi"

 

刪除數據庫

[root@localhost ~]# redis-cli   del no001

(integer) 1

[root@localhost ~]# redis-cli   get  no001

(nil)

 

 

redis類型

字符串類型

列表類型 列表是數組  對應

[root@localhost ~]# redis-cli  rpush messages "hello"

(integer) 1

[root@localhost ~]# redis-cli  rpush messages "hell"

(integer) 2

顯示

[root@localhost ~]# redis-cli  lrange messages 0 2

1) "hello"

2) "hell"

 

 

redis集合  這種將3個值集合在一個變量值上  對應標簽功能

127.0.0.1:6379> sadd myset a

(integer) 1

127.0.0.1:6379> sadd myset b

(integer) 1

127.0.0.1:6379> sadd myset c

(integer) 1

127.0.0.1:6379> smembers myset

1) "c"

2) "b"

3) "a"

 

 

 

redis 主從同步

MASTER 192.168.2.1

SLAVE  192.168.2.4

編輯slave的redis.conf

vim /application/redis/conf/redis.conf

在slaveof下面添加:

slaveof  192.168.2.1  6379 主庫地址和端口號

slave查看

[root@localhost redis-3.0.2]# redis-server  /application/redis/conf/redis.conf

6631:S 24 Mar 06:21:26.599 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 3.0.2 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 6631

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               

 

6631:S 24 Mar 06:21:26.611 # Server started, Redis version 3.0.2

6631:S 24 Mar 06:21:26.613 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

6631:S 24 Mar 06:21:26.613 * DB loaded from disk: 0.000 seconds

6631:S 24 Mar 06:21:26.613 * The server is now ready to accept connections on port 6379

6631:S 24 Mar 06:21:27.602 * Connecting to MASTER 192.168.2.1:6379

6631:S 24 Mar 06:21:27.602 * MASTER <-> SLAVE sync started  已經成功

6631:S 24 Mar 06:21:27.603 * Non blocking connect for SYNC fired the event.

6631:S 24 Mar 06:21:27.604 * Master replied to PING, replication can continue...

6631:S 24 Mar 06:21:27.606 * Partial resynchronization not possible (no cached master)

6631:S 24 Mar 06:21:27.611 * Full resync from master: 7a09e0f69c3888561658ec8a480d250d219c2444:1

6631:S 24 Mar 06:21:27.671 * MASTER <-> SLAVE sync: receiving 83 bytes from master

6631:S 24 Mar 06:21:27.671 * MASTER <-> SLAVE sync: Flushing old data

6631:S 24 Mar 06:21:27.671 * MASTER <-> SLAVE sync: Loading DB in memory

6631:S 24 Mar 06:21:27.672 * MASTER <-> SLAVE sync: Finished with success

 

 

MASTER查看

[root@localhost ~]# redis-server  /application/redis/conf/redis.conf

2178:M 19 Feb 03:22:56.204 * Increased maximum number of open files to 10032 (it was originally set to 1024).

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 3.0.2 (00000000/0) 64 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 2178

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               

 

2178:M 19 Feb 03:22:56.224 # Server started, Redis version 3.0.2

2178:M 19 Feb 03:22:56.224 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

2178:M 19 Feb 03:22:56.224 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

2178:M 19 Feb 03:22:56.224 * DB loaded from disk: 0.000 seconds

2178:M 19 Feb 03:22:56.224 * The server is now ready to accept connections on port 6379

2178:M 19 Feb 03:37:57.011 * 1 changes in 900 seconds. Saving...

2178:M 19 Feb 03:37:57.014 * Background saving started by pid 2374

2374:C 19 Feb 03:37:57.046 * DB saved on disk

2374:C 19 Feb 03:37:57.046 * RDB: 6 MB of memory used by copy-on-write

2178:M 19 Feb 03:37:57.120 * Background saving terminated with success

2178:M 19 Feb 03:52:58.020 * 1 changes in 900 seconds. Saving...

2178:M 19 Feb 03:52:58.031 * Background saving started by pid 2546

2546:C 19 Feb 03:52:58.049 * DB saved on disk

2546:C 19 Feb 03:52:58.049 * RDB: 6 MB of memory used by copy-on-write

2178:M 19 Feb 03:52:58.138 * Background saving terminated with success

2178:M 19 Feb 04:09:04.556 * Slave 192.168.2.4:6379 asks for synchronization

2178:M 19 Feb 04:09:04.556 * Full resync requested by slave 192.168.2.4:6379

2178:M 19 Feb 04:09:04.556 * Starting BGSAVE for SYNC with target: disk

2178:M 19 Feb 04:09:04.557 * Background saving started by pid 2773

2773:C 19 Feb 04:09:04.580 * DB saved on disk

2773:C 19 Feb 04:09:04.581 * RDB: 6 MB of memory used by copy-on-write 主庫也接受到了

2178:M 19 Feb 04:09:04.620 * Background saving terminated with success

2178:M 19 Feb 04:09:04.620 * Synchronization with slave 192.168.2.4:6379 succeeded

 

 

 

 

 

在從庫做個監控,主庫寫數據驗證

[root@localhost ~]# redis-cli  主庫創建數據庫

127.0.0.1:6379> set t1 xiaohu01

OK

127.0.0.1:6379> get t1

"xiaohu01"

查看從庫同步

[root@localhost ~]# redis-cli  -h 192.168.2.4 get t1

"xiaohu01"

遠程連接到從庫查看數據同步了

 

 

[root@localhost ~]# redis-cli  -h localhost -p 6379 monitor 從庫開啟監控數據庫寫入

OK

1458772016.182626 [0 192.168.2.1:6379] "PING"

 

 

 

 

 


文章題目:Redis集群實戰
本文URL:http://www.xueling.net.cn/article/jjodsj.html

其他資訊

在線咨詢
服務熱線
服務熱線:028-86922220
TOP
主站蜘蛛池模板: 国产乱精品女同自线免费 | 精品国产香蕉在线观看 | 妞干网在线观看 | 国产91区 | 免费a级毛片在线观看 | 欧美精品福利视频 | 亚洲最大的免费观影网站 | 亚洲熟妇无码AV另类VR影视 | 天天干天天曰天天操 | 国产一区二区三区视频在线播放 | 久久国产免费观看 | 欧美视频亚洲色图 | 无码AV人片在线观看天堂 | 96国产精品 | 91黄色免费网站 | 欧美巨大丰满猛性社交 | 日韩免费观看 | 亚洲午夜精选 | 国产精品99久久久久久久 | 欧美激情视频一区二区三区 | 久久精品道一区二区三区 | 亚洲中文无码av永久不收费 | 亚洲国产精品视频一区 | 国产OO后高中生在线视频 | 亚洲大尺度专区无码浪潮AV | 男人自慰泄欲飞机GAY2022 | 久久久久国产综合AV天堂 | 野花社区www高清图片 | 亚洲aⅴ网站| 四虎影视WWW在线播放 | 一区二三区日韩精品 | 久久这里精品 | 在线观看的网站你懂的 | 国内色视频 | 免费观看老乱熟视频 | 亚洲成AV人片高潮喷水 | 成全视频免费观看在线看黑人 | 午夜影院免费 | 一区二区视 | 日韩国产一区二区 | 日韩福利视频在线 |