日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
CentOS6.564位下Redis主從復(fù)制配置

該文使用centos 6.5 64位  Redis3.2.8   

創(chuàng)新互聯(lián)建站是一家專注于成都網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),梁山網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:梁山等地區(qū)。梁山做網(wǎng)站價(jià)格咨詢:13518219792

主從復(fù)制

Redis的復(fù)制功能是支持多個(gè)數(shù)據(jù)庫(kù)之間的數(shù)據(jù)同步。一類是主數(shù)據(jù)庫(kù)(master)一類是從數(shù)據(jù)庫(kù)(slave),主數(shù)據(jù)庫(kù)可以進(jìn)行讀寫操作,當(dāng)發(fā)生寫操作的時(shí)候自動(dòng)將數(shù)據(jù)同步到從數(shù)據(jù)庫(kù),而從數(shù)據(jù)庫(kù)一般是只讀的,并接收主數(shù)據(jù)庫(kù)同步過(guò)來(lái)的數(shù)據(jù),一個(gè)主數(shù)據(jù)庫(kù)可以有多個(gè)從數(shù)據(jù)庫(kù),而一個(gè)從數(shù)據(jù)庫(kù)只能有一個(gè)主數(shù)據(jù)庫(kù)。通過(guò)redis的復(fù)制功能可以很好的實(shí)現(xiàn)數(shù)據(jù)庫(kù)的讀寫分離,提高服務(wù)器的負(fù)載能力。主數(shù)據(jù)庫(kù)主要進(jìn)行寫操作,而從數(shù)據(jù)庫(kù)負(fù)責(zé)讀操作。

Redis主從復(fù)制:主從復(fù)制可以允許多個(gè)slave server 擁有和master server相同的數(shù)據(jù)庫(kù)副本

1、Redis主從復(fù)制的特點(diǎn):

a、  master 可以有多個(gè)slave

b、  多個(gè)slave 可以鏈接同一個(gè)master外,還可以鏈接其他slave

c、  主從復(fù)制不會(huì)阻塞master,在數(shù)據(jù)同步的時(shí)候,master可以繼續(xù)處理client請(qǐng)求

d、  提高系統(tǒng)的伸縮性

2、Redis主從復(fù)制的過(guò)程:

a、  slave與master建立鏈接,發(fā)送sync同步請(qǐng)求。

b、  master會(huì)啟動(dòng)一個(gè)后臺(tái)進(jìn)程,將數(shù)據(jù)庫(kù)快照保存到文件中,同時(shí)master主進(jìn)程會(huì)開始收集新的寫命令并緩存。

c、  后臺(tái)完成保存后,就將此文件發(fā)送給slave

d、  Slave將此文件保存到硬盤上。

3、Redis 主從復(fù)制操作步驟

環(huán)境:

Redis主從結(jié)構(gòu)支持一主多從(所有從節(jié)點(diǎn)的配置都一樣)

master:192.168.6.190

slave:192.168.6.191

配置:

配置slave服務(wù)器,在slave服務(wù)器的配置文件中加入一下代碼

slaveof 192.168.222.1 6379 #指定master的ip和端口

################################# REPLICATION #################################

# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of slaves.
# 2) Redis slaves are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition slaves automatically try to reconnect to masters
#    and resynchronize with them.
#
# slaveof
slaveof 192.168.6.190 6379
# If the master is password protected (using the "requirepass" configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#
# masterauth

啟動(dòng)master服務(wù)器:

[root@localhost bin]# ./redis-server /usr/local/redis/etc/redis.conf

查看master配置信息:127.0.0.1:6379> info

# Replication
role:master
connected_slaves:1
slave0:ip=192.168.6.191,port=6379,state=online,offset=141,lag=0
master_repl_offset:141
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:2
repl_backlog_histlen:140

啟動(dòng)slave服務(wù)器:

[root@localhost bin]# ./redis-server /usr/local/redis/etc/redis.conf

查看slave配置信息:127.0.0.1:6379> info

# Replication
role:slave
master_host:192.168.6.190
master_port:6379
master_link_status:up
master_last_io_seconds_ago:1
master_sync_in_progress:0
slave_repl_offset:99
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

測(cè)試:

master:

slave:

配置時(shí)遇到錯(cuò)誤:master_link_status:down

1、確定master與slave的redis端口是開放的,未被防火墻攔截

2、修改 master redis.cnf 文件中bind 為bind 0.0.0.0


當(dāng)前標(biāo)題:CentOS6.564位下Redis主從復(fù)制配置
分享網(wǎng)址:http://www.dlmjj.cn/article/dpejiei.html