国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

redis主從配置

zhaot / 1873人閱讀

摘要:下載檢查一下看有沒有問題安裝完之后,會在目錄下生成幾個可執(zhí)行文件,分別是。其中是啟動服務(wù)的,是進(jìn)入客戶端的。

1、下載redis3.2.3

wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar -zxvf redis-3.2.3.tar.gz
cd redis-3.2.3
make
make test //檢查一下 看有沒有問題
make install

安裝完之后,會在src目錄下生成幾個可執(zhí)行文件,分別是mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server。其中redis-server是啟動Redis服務(wù)的,redis-cli是進(jìn)入Redis客戶端的。

mkdir etc
mkdir bin
mv redis.conf etc/
mv sentinel.conf etc/
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-sentinel redis-server redis-trib.rb redis-cli ../bin
cp -R /usr/local/jenkins/redis/redis-3.2.3                                  /usr/local/jenkins/redis/redis-master-3.2.3
   cp -R /usr/local/jenkins/redis/redis-3.2.3     /usr/local/jenkins/redis/redis-slave-3.2.3

2、配置主從redis

cd  /usr/local/jenkins/redis/redis-master-3.2.3/etc/
cp redis.conf master.conf
cd  /usr/local/jenkins/redis/redis-slave-3.2.3/etc/
cp redis.conf slave_6380.conf
cp redis.conf slave_6381.conf
mkdir  /usr/local/jenkins/redis/redis-master-3.2.3/logs
mkdir  /usr/local/jenkins/redis/redis-master-3.2.3/run
mkdir  /usr/local/jenkins/redis/redis-slave-3.2.3/logs
mkdir  /usr/local/jenkins/redis/redis-slave-3.2.3/run

修改主配置文件master.conf

port 6379
pidfile /usr/local/jenkins/redis/redis-master-3.2.3/run/redis_6379.pid
# slaveof  
logfile "/usr/local/jenkins/redis/redis-master-3.2.3/logs/redis.master.log"
requirepass 123456
daemonize yes
bind 0.0.0.0
masterauth 123456

修改從配置文件slave_6380.conf(slave_6381.conf)

port 6380
pidfile /usr/local/jenkins/redis/redis-slave-3.2.3/run/redis_6380.pid
slaveof 127.0.0.1 6379
logfile "/usr/local/jenkins/redis/redis-slave-3.2.3/logs/redis.slave6380.log"
requirepass 123456
daemonize yes
bind 0.0.0.0
masterauth 123456

3、啟動redis

./redis-server /usr/local/jenkins/redis/redis-master-3.2.3/etc/master.conf 

./redis-server /usr/local/jenkins/redis/redis-slave-3.2.3/etc/slave_6380.conf 
./redis-server /usr/local/jenkins/redis/redis-slave-3.2.3/etc/slave_6381.conf

主redis打印的日志

啟動哨兵

 ./redis-sentinel /usr/local/jenkins/redis/redis-slave-3.2.3/etc/sentinel_26379.conf
 ./redis-sentinel /usr/local/jenkins/redis/redis-slave-3.2.3/etc/sentinel_26380.conf
 ./redis-sentinel /usr/local/jenkins/redis/redis-slave-3.2.3/etc/sentinel_26381.conf

sentinel_26379.conf配置文件

port 26379
dir /usr/local/jenkins/redis/redis-sentinel-3.2.3/tmp26379
daemonize yes
logfile "/usr/local/jenkins/redis/redis-sentinel-3.2.3/logs/redis.sentinel26379.log"
sentinel monitor mymaster 192.168.1.135 6379 1
sentinel auth-pass mymaster 123456
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 180000

查看信息:

redis-cli -h 127.0.0.1 -p 6379 -a 123456 info replication
redis-cli -h 127.0.0.1 -p 6380 -a 123456 info replication

用redis-cli工具登錄其中一個哨兵

./redis-cli -p 26379

連接成功后運(yùn)行如下命令

sentinel master mymaster

4、測試
登錄主redis

 ./redis-cli -h 127.0.0.1 -p 6379 -a 123456
set name zhangsan
set addr shanghai
set curTime 2016-07-11

登錄從reids

./redis-cli -h 127.0.0.1 -p 6380
get name
get addr
get curTime

5、測試主redis宕機(jī),切換從reids為主
關(guān)閉主redis

./redis-cli  -h 127.0.0.1 -p 6379 -a 123456 shutdown

切換從reids為主reids

./redis-cli -p 6380 -a 123456 slaveof NO ONE

測試從redis是否切換從主redis是否成功

./redis-cli -h 127.0.0.1 -p 6380 -a 123456
set name zhangsan

更多技術(shù)文章:

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/70794.html

相關(guān)文章

  • Redis主從復(fù)制以及主從復(fù)制原理

    摘要:前者稱為主節(jié)點(diǎn),后者稱為從節(jié)點(diǎn)數(shù)據(jù)的復(fù)制是單向的,只能由主節(jié)點(diǎn)到從節(jié)點(diǎn)。主從復(fù)制的作用數(shù)據(jù)冗余主從復(fù)制實(shí)現(xiàn)了數(shù)據(jù)的熱備份,是持久化之外的一種數(shù)據(jù)冗余方式。檢測主節(jié)點(diǎn)當(dāng)前是否可接受處理命令。 showImg(https://segmentfault.com/img/bVboOAF?w=1772&h=591); Redis是一個開源的使用ANSI C語言編寫、支持網(wǎng)絡(luò)、可基于內(nèi)存亦可持久化...

    snowLu 評論0 收藏0
  • 那一天,我被Redis主從架構(gòu)支配的恐懼

    摘要:面試官要不你來講講你最近在看的點(diǎn)唄可以拉出來一起討論下今天我也不知道要問什么候選者最近在看相關(guān)的內(nèi)容面試官嗯,我記得已經(jīng)問過的基礎(chǔ)和持久化了面試官要不你來講講你公司的是什么架構(gòu)的咯候選者我前公司的架構(gòu)是分片集群,使用的是層來對進(jìn)行分流到不同面試官:要不你來講講你最近在看的點(diǎn)唄?可以拉出來一起討論下(今天我也不知道要問什么)候選者:最近在看「Redis」相關(guān)的內(nèi)容面試官:嗯,我記得已經(jīng)問過Re...

    curried 評論0 收藏0

發(fā)表評論

0條評論

zhaot

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<