首页 数据库 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)

centos redis如何配置Lua脚本执行时间 centos redis如何配置Lua脚本执行时间 Apr 14, 2025 pm 02:12 PM

在CentOS系统上,您可以通过修改Redis配置文件或使用Redis命令来限制Lua脚本的执行时间,从而防止恶意脚本占用过多资源。方法一:修改Redis配置文件定位Redis配置文件:Redis配置文件通常位于/etc/redis/redis.conf。编辑配置文件:使用文本编辑器(例如vi或nano)打开配置文件:sudovi/etc/redis/redis.conf设置Lua脚本执行时间限制:在配置文件中添加或修改以下行,设置Lua脚本的最大执行时间(单位:毫秒)

Debian如何提升Hadoop数据处理速度 Debian如何提升Hadoop数据处理速度 Apr 13, 2025 am 11:54 AM

本文探讨如何在Debian系统上提升Hadoop数据处理效率。优化策略涵盖硬件升级、操作系统参数调整、Hadoop配置修改以及高效算法和工具的运用。一、硬件资源强化确保所有节点硬件配置一致,尤其关注CPU、内存和网络设备性能。选择高性能硬件组件对于提升整体处理速度至关重要。二、操作系统调优文件描述符和网络连接数:修改/etc/security/limits.conf文件,增加系统允许同时打开的文件描述符和网络连接数上限。JVM参数调整:在hadoop-env.sh文件中调整

HDFS配置CentOS需要哪些步骤 HDFS配置CentOS需要哪些步骤 Apr 14, 2025 pm 06:42 PM

在CentOS系统上搭建Hadoop分布式文件系统(HDFS)需要多个步骤,本文提供一个简要的配置指南。一、前期准备安装JDK:在所有节点上安装JavaDevelopmentKit(JDK),版本需与Hadoop兼容。可从Oracle官网下载安装包。环境变量配置:编辑/etc/profile文件,设置Java和Hadoop的环境变量,使系统能够找到JDK和Hadoop的安装路径。二、安全配置:SSH免密登录生成SSH密钥:在每个节点上使用ssh-keygen命令

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

从 Redis 官方源下载源码包编译安装,保证最新稳定版本,可个性化定制。具体步骤如下:更新软件包列表创建 Redis 目录下载 Redis 源码包解压源码包编译安装配置并修改 Redis 配置启动 Redis检查启动状态

Debian Hadoop任务执行流程是什么 Debian Hadoop任务执行流程是什么 Apr 13, 2025 am 11:24 AM

Hadoop任务执行流程主要包括以下几个步骤:提交作业:用户在客户端机器上使用Hadoop提供的命令行工具或API,构建任务的执行环境并将任务提交到YARN(Hadoop的资源管理器)。资源申请:YARN收到任务提交请求后,会根据任务所需资源(如内存、CPU等)向集群中的节点申请资源。任务启动:一旦资源分配完成,YARN会将任务的启动命令发送给相应的节点。在节点上,NodeMana

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

Debian上TigerVNC共享文件方法 Debian上TigerVNC共享文件方法 Apr 13, 2025 am 11:45 AM

本文介绍如何在Debian系统上使用TigerVNC共享文件。你需要先安装TigerVNC服务器,然后进行配置。一、安装TigerVNC服务器打开终端。更新软件包列表:sudoaptupdate安装TigerVNC服务器:sudoaptinstalltigervnc-standalone-servertigervnc-common二、配置TigerVNC服务器设置VNC服务器密码:vncpasswd启动VNC服务器:vncserver:1-localhostno

centos redis如何配置慢查询日志 centos redis如何配置慢查询日志 Apr 14, 2025 pm 04:54 PM

在CentOS系统上启用Redis慢查询日志,提升性能诊断效率。以下步骤将指导您完成配置:第一步:定位并编辑Redis配置文件首先,找到Redis配置文件,通常位于/etc/redis/redis.conf。使用以下命令打开配置文件:sudovi/etc/redis/redis.conf第二步:调整慢查询日志参数在配置文件中,找到并修改以下参数:#慢查询阈值(毫秒)slowlog-log-slower-than10000#慢查询日志最大条目数slowlog-max-len

See all articles