首頁 資料庫 mysql教程 Redis主从搭建

Redis主从搭建

Jun 07, 2016 pm 04:03 PM
red redis 初識 安裝 搭建 方法

redis安装方法见:初识Redis邂逅 安装环境: [root@localhost redis]# redis-server --versionRedis server v=2.8.7 sha=00000000:0 malloc=jemalloc-3.2.0 bits=32 build=df8b796b6fcf0127[root@localhost redis]# cat /proc/versionLinux version 2.6.18-9

redis安装方法见:初识Redis——邂逅

安装环境:
[root@localhost redis]# redis-server --version
Redis server v=2.8.7 sha=00000000:0 malloc=jemalloc-3.2.0 bits=32 build=df8b796b6fcf0127
[root@localhost redis]# cat /proc/version
Linux version 2.6.18-92.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 18:49:47 EDT 2008
登入後複製
1、复制配置文件
#master配置文件
cp redis.conf redis-master.conf
#slave配置文件
cp redis.conf redis-slave.conf
#备份配置文件
cp redis.conf redis-bak.conf
登入後複製
2、修改配置文件
#master配置文件
#保证PID文件区分,PID文件主要用于保证守护进程单例运行
pidfile /var/run/redis-master.pid
#区分LOG文件
logfile "/data/redis/6379/log/redis.log"
#区分持久化文件
dir /data/redis/6379/data
#区分端口
port 6379

#slave配置文件
pidfile /var/run/redis-slave.pid
logfile "/data/redis/6380/log/redis.log"
dir /data/redis/6380/data
port 6380
slaveof 127.0.0.1 6379
#如果为yes,slave实例只读,如果为no,slave实例可读可写。默认
slave-read-only yes
登入後複製
3、启动
redis-server /etc/redis/redis-master.conf
redis-server /etc/redis/redis-slave.conf
登入後複製
4、验证 master启动日志
[root@localhost redis]# cat /data/redis/6379/log/redis.log
[24787] 13 Sep 10:39:45.143 * Max number of open files set to 10032
[24787] 13 Sep 10:39:45.145 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-``    `.  `_.  ''-._           Redis 2.8.7 (00000000/0) 32 bit
.-`` .-```.  ```\/    _.,_ ''-._
(    '      ,       .-`  | `,    )     Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
|    `-._   `._    /     _.-'    |     PID: 24787
`-._    `-._  `-./  _.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |           http://redis.io
`-._    `-._`-.__.-'_.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |
`-._    `-._`-.__.-'_.-'    _.-'
`-._    `-.__.-'    _.-'
`-._        _.-'
`-.__.-'
[24787] 13 Sep 10:39:45.146 # Server started, Redis version 2.8.7
[24787] 13 Sep 10:39:45.146 # 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.
[24787] 13 Sep 10:39:45.146 * The server is now ready to accept connections on port 6379
[24787] 13 Sep 10:40:54.342 * DB saved on disk
[24787] 13 Sep 10:42:50.581 * Slave asks for synchronization
[24787] 13 Sep 10:42:50.581 * Full resync requested by slave.
[24787] 13 Sep 10:42:50.581 * Starting BGSAVE for SYNC
[24787] 13 Sep 10:42:50.582 * Background saving started by pid 24816
[24816] 13 Sep 10:42:50.586 * DB saved on disk
[24816] 13 Sep 10:42:50.587 * RDB: 0 MB of memory used by copy-on-write
[24787] 13 Sep 10:42:50.673 * Background saving terminated with success
[24787] 13 Sep 10:42:50.673 * Synchronization with slave succeeded
[24787] 13 Sep 10:47:04.093 * DB saved on disk
登入後複製
slave 启动日志
[root@localhost redis]# cat /data/redis/6380/log/redis.log
[24813] 13 Sep 10:42:50.578 * Max number of open files set to 10032
[24813] 13 Sep 10:42:50.579 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-``    `.  `_.  ''-._           Redis 2.8.7 (00000000/0) 32 bit
.-`` .-```.  ```\/    _.,_ ''-._
(    '      ,       .-`  | `,    )     Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'|     Port: 6380
|    `-._   `._    /     _.-'    |     PID: 24813
`-._    `-._  `-./  _.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |           http://redis.io
`-._    `-._`-.__.-'_.-'    _.-'
|`-._`-._    `-.__.-'    _.-'_.-'|
|    `-._`-._        _.-'_.-'    |
`-._    `-._`-.__.-'_.-'    _.-'
`-._    `-.__.-'    _.-'
`-._        _.-'
`-.__.-'
[24813] 13 Sep 10:42:50.580 # Server started, Redis version 2.8.7
[24813] 13 Sep 10:42:50.580 # 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.
[24813] 13 Sep 10:42:50.580 * The server is now ready to accept connections on port 6380
[24813] 13 Sep 10:42:50.580 * Connecting to MASTER 127.0.0.1:6379
[24813] 13 Sep 10:42:50.580 * MASTER <-> SLAVE sync started
[24813] 13 Sep 10:42:50.580 * Non blocking connect for SYNC fired the event.
[24813] 13 Sep 10:42:50.581 * Master replied to PING, replication can continue...
[24813] 13 Sep 10:42:50.581 * Partial resynchronization not possible (no cached master)
[24813] 13 Sep 10:42:50.583 * Full resync from master: 9ef3d846e366f7643db9e9250b508d64a34c1079:1
[24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: receiving 31 bytes from master
[24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: Flushing old data
[24813] 13 Sep 10:42:50.673 * MASTER <-> SLAVE sync: Loading DB in memory
[24813] 13 Sep 10:42:50.674 * MASTER <-> SLAVE sync: Finished with success
[24813] 13 Sep 10:47:04.096 * DB saved on disk
登入後複製
数据同步验证:
[root@localhost redis]# redis-cli
127.0.0.1:6379> set name test
OK
127.0.0.1:6379> save
OK

[root@localhost redis]# redis-cli -p 6380
127.0.0.1:6380> keys *
1) "name"
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

centos7 如何安裝redis centos7 如何安裝redis Apr 14, 2025 pm 08:21 PM

從 Redis 官方源下載源碼包編譯安裝,保證最新穩定版本,可個性化定制。具體步驟如下:更新軟件包列表創建 Redis 目錄下載 Redis 源碼包解壓源碼包編譯安裝配置並修改 Redis 配置啟動 Redis檢查啟動狀態

使用DICR/YII2-Google將Google API集成在YII2中 使用DICR/YII2-Google將Google API集成在YII2中 Apr 18, 2025 am 11:54 AM

vProcesserazrabotkiveb被固定,мнелостольностьстьс粹餾標д都LeavallySumballanceFriablanceFaumDoptoMatification,Čtookazalovnetakprosto,kakaožidal.posenesko

HDFS配置CentOS需要修改哪些文件 HDFS配置CentOS需要修改哪些文件 Apr 14, 2025 pm 07:27 PM

在CentOS上配置Hadoop分佈式文件系統(HDFS)時,需要修改以下關鍵配置文件:core-site.xml:fs.defaultFS:指定HDFS的默認文件系統地址,例如hdfs://localhost:9000。 hadoop.tmp.dir:指定Hadoop臨時文件的存儲目錄。 hadoop.proxyuser.root.hosts和hadoop.proxyuser.ro

HDFS文件系統在CentOS上的使用技巧 HDFS文件系統在CentOS上的使用技巧 Apr 14, 2025 pm 07:30 PM

CentOS系統下HDFS文件系統的安裝、配置及優化指南本文將指導您如何在CentOS系統上安裝、配置和優化Hadoop分佈式文件系統(HDFS)。 HDFS安裝與配置Java環境安裝:首先,確保已安裝合適的Java環境。編輯/etc/profile文件,添加以下內容,並將/usr/lib/java-1.8.0/jdk1.8.0_144替換為您的實際Java安裝路徑:exportJAVA_HOME=/usr/lib/java-1.8.0/jdk1.8.0_144exportPATH=$J

如何利用Redis緩存方案高效實現產品排行榜列表的需求? 如何利用Redis緩存方案高效實現產品排行榜列表的需求? Apr 19, 2025 pm 11:36 PM

Redis緩存方案如何實現產品排行榜列表的需求?在開發過程中,我們常常需要處理排行榜的需求,例如展示一個�...

laravel8 的優化點 laravel8 的優化點 Apr 18, 2025 pm 12:24 PM

Laravel 8 針對性能優化提供了以下選項:緩存配置:使用 Redis 緩存驅動、緩存門面、緩存視圖和頁面片段。數據庫優化:建立索引、使用查詢範圍、使用 Eloquent 關係。 JavaScript 和 CSS 優化:使用版本控制、合併和縮小資產、使用 CDN。代碼優化:使用 Composer 安裝包、使用 Laravel 助手函數、遵循 PSR 標準。監控和分析:使用 Laravel Scout、使用 Telescope、監控應用程序指標。

REDIS的角色:探索數據存儲和管理功能 REDIS的角色:探索數據存儲和管理功能 Apr 22, 2025 am 12:10 AM

Redis在數據存儲和管理中扮演著關鍵角色,通過其多種數據結構和持久化機製成為現代應用的核心。 1)Redis支持字符串、列表、集合、有序集合和哈希表等數據結構,適用於緩存和復雜業務邏輯。 2)通過RDB和AOF兩種持久化方式,Redis確保數據的可靠存儲和快速恢復。

See all articles