搜索
Redis主从搭建Jun 07, 2016 pm 04:03 PM
redredis初识安装搭建方法

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
es和redis区别es和redis区别Jul 06, 2019 pm 01:45 PM

Redis是现在最热门的key-value数据库,Redis的最大特点是key-value存储所带来的简单和高性能;相较于MongoDB和Redis,晚一年发布的ES可能知名度要低一些,ES的特点是搜索,ES是围绕搜索设计的。

一起来聊聊Redis有什么优势和特点一起来聊聊Redis有什么优势和特点May 16, 2022 pm 06:04 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于redis的一些优势和特点,Redis 是一个开源的使用ANSI C语言编写、遵守 BSD 协议、支持网络、可基于内存、分布式存储数据库,下面一起来看一下,希望对大家有帮助。

实例详解Redis Cluster集群收缩主从节点实例详解Redis Cluster集群收缩主从节点Apr 21, 2022 pm 06:23 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis Cluster集群收缩主从节点的相关问题,包括了Cluster集群收缩概念、将6390主节点从集群中收缩、验证数据迁移过程是否导致数据异常等,希望对大家有帮助。

Redis实现排行榜及相同积分按时间排序功能的实现Redis实现排行榜及相同积分按时间排序功能的实现Aug 22, 2022 pm 05:51 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,希望对大家有帮助。

详细解析Redis中命令的原子性详细解析Redis中命令的原子性Jun 01, 2022 am 11:58 AM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了关于原子操作中命令原子性的相关问题,包括了处理并发的方案、编程模型、多IO线程以及单命令的相关内容,下面一起看一下,希望对大家有帮助。

一文搞懂redis的bitmap一文搞懂redis的bitmapApr 27, 2022 pm 07:48 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了bitmap问题,Redis 为我们提供了位图这一数据结构,位图数据结构其实并不是一个全新的玩意,我们可以简单的认为就是个数组,只是里面的内容只能为0或1而已,希望对大家有帮助。

实例详解Redis实现排行榜及相同积分按时间排序功能的实现实例详解Redis实现排行榜及相同积分按时间排序功能的实现Aug 26, 2022 pm 02:09 PM

本篇文章给大家带来了关于redis的相关知识,其中主要介绍了Redis实现排行榜及相同积分按时间排序,本文通过实例代码给大家介绍的非常详细,下面一起来看一下,希望对大家有帮助。

redis error什么意思redis error什么意思Jun 17, 2019 am 11:07 AM

redis error就是redis数据库和其组合使用的部件出现错误,这个出现的错误有很多种,例如Redis被配置为保存数据库快照,但它不能持久化到硬盘,用来修改集合数据的命令不能用。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

功能强大的PHP集成开发环境

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。