Linux系统:Centos7环境搭建Redis单台和哨兵集群环境
本文源码:GitHub·点这里 || GitEE·点这里
一、环境和版本
Linux:centos7 三台
三台Linux服务
192.168.72.129
192.168.72.130
192.168.72.131
Redis:redis-4.0.14
二、上传Redis软件
1、创建软件目录
[root@localhost local]# cd /usr/local/
[root@localhost local]# mkdir mysoft
2、Xftp上传软件,解压
[root@localhost mysoft]# cd /usr/local/mysoft/
[root@localhost mysoft]# ll
total 1704
-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz
[root@localhost mysoft]# tar -zxvf redis-4.0.14.tar.gz
3、编译项目
[root@localhost mysoft]# ll
total 1708
drwxrwxr-x. 6 root root 4096 Mar 19 00:23 redis-4.0.14
-rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz
[root@localhost mysoft]# cd redis-4.0.14/
[root@localhost redis-4.0.14]# make MALLOC=libc
4、安装Redis
[root@localhost redis-4.0.14]# cd src && make install
5、启动服务
[root@localhost redis-4.0.14]# cd src
[root@localhost src]# ./redis-server
6、配置进程启动
修改redis.conf
daemonize yes
7、进程查看关闭
[root@localhost redis-4.0.14]# ./src/redis-server redis.conf
11320:C 05 May 14:26:31.053 # Redis is starting
11320:C 05 May 14:26:31.053 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11320, just started
11320:C 05 May 14:26:31.053 # Configuration loaded
[root@localhost redis-4.0.14]# ps -aux |grep redis
root 11321 0.1 0.1 141840 2028 ? Ssl 14:26 0:00 ./src/redis-server *:6379
root 11338 0.0 0.0 112708 980 pts/1 S+ 14:27 0:00 grep --color=auto redis
[root@localhost redis-4.0.14]# kill -9 11321
三、配置开机启动
1、相关配置
[root@localhost init.d]# cd /etc
[root@localhost etc]# mkdir redis
[root@localhost etc]# cp /usr/local/mysoft/redis-4.0.14/redis.conf /etc/redis/6379.conf
[root@localhost etc]# cd redis/
[root@localhost redis]# ll
total 60
-rw-r--r--. 1 root root 58767 May 5 14:36 redis-6379.conf
[root@localhost redis]# cp /usr/local/mysoft/redis-4.0.14/utils/redis_init_script /etc/init.d/redisd
[root@localhost redis]# chkconfig redisd on # 开机启动命令
2、服务启动关闭
[root@localhost redis]# service redisd start
Starting Redis server...
3163:C 05 May 14:59:13.872 # Redis is starting
3163:C 05 May 14:59:13.872 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=3163, just started
3163:C 05 May 14:59:13.872 # Configuration loaded
[root@localhost redis]# service redisd stop
Stopping ...
Waiting for Redis to shutdown ...
Redis stopped
3、重启虚拟机查看Redis状态
[root@localhost ~]# ps -aux |grep redis
root 987 0.1 0.1 141836 2012 ? Ssl 15:02 0:00 /usr/local/bin/redis-server *:6379
root 2966 0.0 0.0 112712 980 pts/1 S+ 15:04 0:00 grep --color=auto redis
四、解决客户端连接问题
关闭防火墙,或者开放6379端口
firewalld的基本使用
启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld
开机禁用 : systemctl disable firewalld
开机启用 : systemctl enable firewalld
修改redis.conf 配置
注释掉:# bind 127.0.0.1
修改保护模式:protected-mode no
五、sentinel哨兵模式
1、基础配置
192.168.72.129 主服务
192.168.72.130 从服务
192.168.72.131 从服务
2、配置主服务 redis.conf
requirepass 123456
masterauth 123456
3、配置从服务 redis.conf
requirepass 123456
slaveof 192.168.72.129 6379
masterauth 123456
4、配置sentinel.conf
protected-mode no
# sentinel monitor代表监控
# mymaster代表服务器的名称,可以自定义,
# 192.168.72.129代表监控的主服务器,6379代表端口,
# 2 标识 >=2 哨兵认为主服务器不可用,执行failover操作。
sentinel monitor mymaster 192.168.72.129 6379 2
sentinel auth-pass mymaster 123456
5、启动服务
先主服务,后从服务
[root@localhost src]# ./redis-server ../redis.conf
[root@localhost src]# ./redis-sentinel ../sentinel.conf
没错,就是这样搭建完毕了!
六、源代码地址
GitHub·地址
https://github.com/cicadasmile/linux-system-base
GitEE·地址
https://gitee.com/cicadasmile/linux-system-base

Linux系统:Centos7环境搭建Redis单台和哨兵集群环境的更多相关文章
- Centos7下ELK+Redis日志分析平台的集群环境部署记录
之前的文档介绍了ELK架构的基础知识,日志集中分析系统的实施方案:- ELK+Redis- ELK+Filebeat - ELK+Filebeat+Redis- ELK+Filebeat+Kafka+ ...
- linux系统centOS7下搭建redis集群中ruby版本过低问题的解决方法
问题描述: 在Centos7中,通过yum安装ruby的版本是2.0.0,但是如果有些应用需要高版本的ruby环境,比如2.2,2.3,2.4... 那就有点麻烦了,譬如:我准备使用redis官方给的 ...
- redis哨兵集群环境搭建
一.哨兵的介绍 哨兵(sentinal)是redis集群架构中非常重要的一个组件,主要功能如下: 集群监控,负责监控redis master和slave进程是否正常工作 消息通知,如果某个redis实 ...
- 搭建Redis三主三从集群
Redis三主三从集群规划 10.0.128.19 使用端口 7000 7001 10.0.128.22 使用端口 7002 7003 10.0.128.23 使用端口 7004 7 ...
- redis内存分配管理与集群环境下Session管理
##################内存管理############### 1.Redis的内存管理 .与memcache不同,没有实现自己的内存池 .在2..4以前,默认使用标准的内存分配函数(li ...
- Redis高可用-主从,哨兵,集群
主从复制 Master-Slave主从概念 同时运行多个redis服务端,其中一个作为主(master),其他的一个或多个作为从(slave),主从之间通过网络进行通讯,slave通过复制master ...
- Hadoop(二)CentOS7.5搭建Hadoop2.7.6完全分布式集群
一 完全分布式集群(单点) Hadoop官方地址:http://hadoop.apache.org/ 1 准备3台客户机 1.1防火墙,静态IP,主机名 关闭防火墙,设置静态IP,主机名此处略,参考 ...
- CentOS7.5搭建Hadoop2.7.6完全分布式集群
一 完全分布式集群搭建 Hadoop官方地址:http://hadoop.apache.org/ 1 准备3台客户机 1.2 关闭防火墙,设置静态IP,主机名 关闭防火墙,设置静态IP,主机名此处略 ...
- linux系统下对网站实施负载均衡+高可用集群需要考虑的几点
随着linux系统的成熟和广泛普及,linux运维技术越来越受到企业的关注和追捧.在一些中小企业,尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案. 那么如何实 ...
随机推荐
- python学习-文件创建读取
# 文件创建 # 读写# 文件存在?不存在?在操作系统上# 读 read r 写 write w# 打开一个文件# fs = open("xiaojian.txt",encodin ...
- mysql #1062 - Duplicate entry '2147483647' for key '*'
一.当我看到这报错的时候,第一眼是认为存在重复记录,但是找了很久没找到2147483647 二.一条条的插入数据(有一批数据),直到找到报错的数据,发现是长度超了,定义了int插入的值却有11位长,哭 ...
- Redis-API
Redis-API 简介 Redis 是一个基于内存的高效的键值行非关系型数据库,存取效率极高. python提供了两个类:分别为Redis和StrictRedis来实现Redis的命令操作.Redi ...
- 2019年12道RabbitMQ高频面试题你都会了吗?(含答案解析)
RabbitMQ 面试题 1.什么是 rabbitmq 2.为什么要使用 rabbitmq 3.使用 rabbitmq 的场景 4.如何确保消息正确地发送至 RabbitMQ? 如何确保消息接收方消费 ...
- 实验:使用GDB查看结构体在内存中的存储方式
结构体在内存中的表示形式是怎么样的? 结构体在内存中和普通变量存储没有太大的区别. 首先我们看看,计算机如何读取普通变量: 普通变量例如int是占据4个字节,计算机读内存的时候会从起始地址开始读, ...
- 【SHOI 2007】善意的投票
Problem Description 幼儿园里有 \(n\) 个小朋友打算通过投票来决定睡不睡午觉.对他们来说,这个问题并不是很重要,于是他们决定发扬谦让精神.虽然每个人都有自己的主见,但是为了照顾 ...
- 4.Android-adt安卓打包过程、adb指令学习
本章学习adt安卓打包过程.adb指令学习.并通过adb将打包的APK发给设备 1.打包 在eclipse中已经帮我们实现打包了. 具体打包流程如下: 最终一个APK包含了如下: classes.de ...
- ReactNative: 使用AppReistry注册类
一.简介 每一个应用程序的运行都有一个入口文件或者入口函数,例如iOS中的使用UIApplicationMain类完成入口函数的实现,在React-Native中,AppRegistry类就肩负着这个 ...
- webpack4 配置
package.json 开发环境/生产环境 webpack.config.js
- IT兄弟连 HTML5教程 CSS3属性特效 3D变换1
3D变换较2D变换多了一下的转换属性,3D转换属性及描述如表1: 表1 3D转换属性 3D的转换方法如表2: 表2 3D转换方法 1 transform-style transform- ...