1. 程式人生 > >Redis 從下載安裝到 Redis sentinel 的高可用經驗總結

Redis 從下載安裝到 Redis sentinel 的高可用經驗總結

Step 1:Redis的下載安裝

官網下載redis 解壓並安裝:

[[email protected] ~]# cd /home/
[[email protected] home]# wget http://download.redis.io/releases/redis-4.0.11.tar.gz
[[email protected] home]# tar -zxvf -C redis-4.0.11.tar.gz
[[email protected] home]# cd redis-4.0.11/src
[[email protected] src]# make

編譯中....

....

CC setproctitle.o
CC hyperloglog.o
CC latency.o
CC sparkline.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
CC redis-check-dump.o
LINK redis-check-dump
CC redis-check-aof.o
LINK redis-check-aof

Hint: It’s a good idea to run ‘make test’ ;)


[
[email protected]
src]# make install 安裝中... ... 完成

安裝完成,可以看到此時,src資料夾下出現了一些綠色的檔案,這些檔案就是我們以後需要用到的命令檔案

Step 2:Redis 主從複製的配置

1.在 redis 目錄下建立 config 和 data 資料夾:config 用來存放 redis.conf/sentinel.conf 配置檔案, data 用來存放 .log 檔案和 .rdb 檔案

[[email protected] redis-4.0.11]# mkdir config
[[email protected]
redis-4.0.11]# mkdir data [[email protected] redis-4.0.11]# cd config/

2.配置 redis master  埠 7000 : 建立 redis_7000.conf

# Redis configuration file master.
#bind 127.0.0.1
####################   埠    #############################
port 7000
####################  是否以守護程序啟動    #################
daemonize yes
####################  程序id檔案   ##############
pidfile /var/run/redis_7000.pid
#######################     系統日誌   ###############
logfile "redis_7000.log"
######################   rdb資料檔案    #############
dbfilename dump_7000.rdb
######################    工作目錄    ###############
dir "/home/redis-4.0.11/data"
########################  密碼 #####################
requirepass 123456

######################    主要是以上的配置   #################
protected-mode no
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
loglevel notice
databases 16
always-show-logo yes
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

3.配置 redis slave  埠 7001/7002/7003 ...... : 建立 redis_7001.conf/redis_7002.conf/redis_7003.conf  .......

# Redis configuration file slave NO.1.
#bind 127.0.0.1
#######################  主從複製:複製127.0.0.1 的資料   埠7000
slaveof 123.45.57.14 7000
####################   埠    #############################
port 7001
####################  是否以守護程序啟動    #################
daemonize yes
####################  程序id檔案   ##############
pidfile "/var/run/redis_7001.pid"
#######################     系統日誌   ###############
logfile "redis_7001.log"
######################   rdb資料檔案    #############
dbfilename "dump_7001.rdb"
######################    工作目錄    ###############
dir "/home/redis-4.0.11/data"
########################  密碼 #####################
requirepass "123456"
# master 節點的密碼
masterauth "123456"

######################     主要是以上的  #################
protected-mode no
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
loglevel notice
databases 16
always-show-logo yes
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
slave-lazy-flush no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble no
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

3.分別啟動  master/slave 的 redis 服務:

[[email protected] redis-4.0.11]# cd src
[[email protected] src]# ./redis-server /home/redis-4.0.11/config/redis_7000.conf
[[email protected] src]# ./redis-server /home/redis-4.0.11/config/redis_7001.conf
[[email protected] src]# ./redis-server /home/redis-4.0.11/config/redis_7002.conf

 

這樣就啟動好了 redis 主從服務

Step 3:Sentinel 高可用配置

在 config 目錄下建立多個 sentinel.conf 檔案 :sentinel_26379.conf/sentinel_26380.conf/sentinel_26381.conf ....(埠號不同就行)

port 26379
daemonize yes
dir "/home/redis-4.0.11/data"
logfile "sentinel_26379.log"
sentinel myid ac633fe2e30979a6e63e5bc26199ab2ace08f242
sentinel monitor mymaster redis服務ip 7000 2
sentinel auth-pass mymaster 123456
sentinel config-epoch mymaster 1
protected-mode no
[[email protected] redis-4.0.11]# cd src
[[email protected] src]# ./redis-sentinel /home/redis-4.0.11/config/sentinel_26379.conf
[[email protected] src]# ./redis-sentinel /home/redis-4.0.11/config/sentinel_26380.conf
[[email protected] src]# ./redis-sentinel /home/redis-4.0.11/config/sentinel_26381.conf

完成此操作即實現了 Redis sentinel 高可用

ps:

1. master /slave 的 redis.conf 最好配置密碼(一定要配置密碼:否則 JedisSentinelPool 報錯) 

2. master /slave 的 redis.conf 最好配置的密碼相同

3. master /slave 的 redis.conf 配置 protected-mode no(sentinel.conf 裡面同樣需要配置)

相關推薦

Redis 下載安裝Redis sentinel可用經驗總結

Step 1:Redis的下載安裝 官網下載redis 解壓並安裝: [[email protected] ~]# cd /home/ [[email protected] home]# wget http://download.redis.io/r

【Linux(CentOS7)下應用的安裝部署】:八、搭建Redis+sentinel可用服務

Step 1:Redis的下載安裝 官網下載redis 解壓並安裝: [[email protected] ~]# cd /home/ [[email protected] home]# wget http://download.redis.io/r

Redis Sentinel 可用叢集搭建(redis4.0)

前言 什麼是哨兵 Redis Sentinel出生於2012年,Redis 2.4穩定後首次釋出,它是一個旨在管理Redis叢集的系統。 哨兵的任務 監控(Monitoring):Sentinel會不斷地檢查你的主伺服器和從伺服器是否運作正常 提醒

redis sentinel 可用(HA)方案部署,及python應用示例

簡介 介紹 redis sentinel(哨兵)叢集的部署,配置一主兩從的redis叢集,並通過 python 程式例項講解通過 redis sentinel 訪問叢集 什麼是哨兵(Sentinel)模式 Redis sentinel 為 Redis 叢集提供了高可

redis 系列25 哨兵Sentinel (可用演示 下)

服務端 查看進程 onf 只讀 usr cond set masters update 原文:redis 系列25 哨兵Sentinel (高可用演示 下)一. Sentinel 高可用環境準備   1.1 Sentinel 集群環境 環境 說明

redis下載到叢集化安裝

 yum install ruby ruby-devel rubygems rpm-build -y && gem install  redis --version 3.0.0  gem install redis  上面的步驟完事了,接下來執行一下redis-trib.rb

Redis Sentinel可用叢集Java客戶端

java客戶端Jedis在2.2.2及以上版本實現了對Sentinel的支援,只要是通過命令:redis-cli -h 192.168.110.71 -p 6000  sentinel get-master-addr-by-name shard_a1) "192.168.11

SDR(spring.data.redis)與Sentinel可用叢集Redis客戶端Jedis配置

依賴 <dependency> <groupId>junit</groupId> <artifactId>junit<

Redis|Sentinel 可用架構

一 前言 Redis-Sentinel是Redis官方推薦的高可用性(HA)解決方案,當用Redis做Master-slave的高可用方案時,假如master宕機了,Redis本身(包括它的很多客戶端)都沒有實現自動進行主備切換,而Redis-sentinel本身也是一個獨立執行的程序,它能監控多個maste

<小田吃餃子> LINUX:Contos7.0 / 7.2 LAMP+R 下載安裝Redis

php+redis pac apache ron 在一起 tor blank amp .cn 更新時間:2017-09-21 15:38 簡介 LAMP+R指Linux+Apache+Mysql+PHP+Redis是一組常用來搭建動態網站或者服務器的開源軟件,本身都是各自獨

W3School Redis教程(安裝/基本操作/級操作/命令)

redis force rdf get http redis教程 sch emca com 來自W3School的Memcached教程,基本上涵蓋了從安裝到狀態監控的教程。 W3School:https://www.gitbook.com/book/wizardforc

下載安裝Redis+使用

Window 下安裝 第一步:安裝 下載地址:https://github.com/MSOpenTech/redis/releases   第二步:解壓(碟符) 第三步:開啟一個 cmd 視窗 使用 cd 命令切換目錄到解壓的目錄執行: redis-serv

redis詳解(四)-- 可用分散式叢集

一,高可用 高可用(High Availability),是當一臺伺服器停止服務後,對於業務及使用者毫無影響。 停止服務的原因可能由於網絡卡、路由器、機房、CPU負載過高、記憶體溢位、自然災害等不可預期的原因導致,在很多時候也稱單點問題。 (1)解決單點問題主要有2種方

Redis 備份、容災及可用實戰

作者介紹 郝朝陽,宜搜科技,運維工程師,負責前端運維工作。專注於運維自動化的實現。致力於DevOps思想的推廣,幫助企業形成形成自有文化的運維體系建設。 一、Redis簡單介紹 Redis是一個高效能的key-value非關係型資料庫,由於其具有高效能的特性,支援高可用、持久化、多種資料結構、叢集

如何將Rancher 2.1.x 單節點安裝遷移到可用安裝

包含 之前 url參數 info 遇到 目錄 成功 recommend 參考 Rancher提供了兩種安裝方法,即單節點安裝和高可用安裝。單節點安裝可以讓用戶快速部署適用於短期開發或PoC的Rancher 2.x,而高可用部署則明顯更適合Rancher的長期部署。 要點須

python中Redis下載安裝

Redis 是完全開源免費的,是一個高效能的、遵守BSD協議的key-value資料庫。 Redis資料特點: 優點: 預設使用持久化資料方式; 體積小,使用方便 ;如果儲存資料量比較大的話,啟動速度很快 ;資料庫中的資料和記憶體的數  據可以相互訪問 缺點: 從安全性

keepalived 安裝配置(可用VIP),雙主模式

keepalived 高可用 雙主模式 郵件腳本 首先需要明白我們準備使用keepalived來做什麽,今天這裏只是給大家簡單安裝和配置下keepalived實現vip對外服務,防止單點故障。keepalived是高可用高可用高可用 而非負載非負載非負載。 下面我將使用keepalived部署雙主模模式,

centos7上安裝redis以及PHP安裝redis擴展(一)

對數 onf 服務 evel 路徑 system 命令 請求 物理內存 1.關閉防火墻:  systemctl stop firewalld.service #停止firewall  systemctl disable firewalld.service #禁止firewa

Redis中master/slave、sentinel、Cluster簡單總結;

因為工作需求需要將現有系統原來的Redis接入CacheClound來管理;需要了解以前系統的Redis節點配置,還需要在CaacheClound中分配對應的節點; 鞏固一下基礎知識;要 yuanwen 一、單節點例項   單節點例項還是比較簡單的,平時做個測試,寫個小程式如果需要用到快

Redis-Linux下安裝redis服務

一、下載 安裝之前我們先下載響應版本的redis。博主下載的是: 二、安裝 2.1、接下來就是使用winscp工具,將下載下來的tar.gz上傳到linux上。然後解壓並重命名,如下: # 解壓 tar -zxvf redis.5.0.0.tar.gz # 重新命名 mv