本文源码: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单台和哨兵集群环境的更多相关文章

  1. Centos7下ELK+Redis日志分析平台的集群环境部署记录

    之前的文档介绍了ELK架构的基础知识,日志集中分析系统的实施方案:- ELK+Redis- ELK+Filebeat - ELK+Filebeat+Redis- ELK+Filebeat+Kafka+ ...

  2. linux系统centOS7下搭建redis集群中ruby版本过低问题的解决方法

    问题描述: 在Centos7中,通过yum安装ruby的版本是2.0.0,但是如果有些应用需要高版本的ruby环境,比如2.2,2.3,2.4... 那就有点麻烦了,譬如:我准备使用redis官方给的 ...

  3. redis哨兵集群环境搭建

    一.哨兵的介绍 哨兵(sentinal)是redis集群架构中非常重要的一个组件,主要功能如下: 集群监控,负责监控redis master和slave进程是否正常工作 消息通知,如果某个redis实 ...

  4. 搭建Redis三主三从集群

    Redis三主三从集群规划 10.0.128.19   使用端口 7000  7001 10.0.128.22   使用端口 7002  7003 10.0.128.23   使用端口 7004  7 ...

  5. redis内存分配管理与集群环境下Session管理

    ##################内存管理############### 1.Redis的内存管理 .与memcache不同,没有实现自己的内存池 .在2..4以前,默认使用标准的内存分配函数(li ...

  6. Redis高可用-主从,哨兵,集群

    主从复制 Master-Slave主从概念 同时运行多个redis服务端,其中一个作为主(master),其他的一个或多个作为从(slave),主从之间通过网络进行通讯,slave通过复制master ...

  7. Hadoop(二)CentOS7.5搭建Hadoop2.7.6完全分布式集群

    一 完全分布式集群(单点) Hadoop官方地址:http://hadoop.apache.org/ 1  准备3台客户机 1.1防火墙,静态IP,主机名 关闭防火墙,设置静态IP,主机名此处略,参考 ...

  8. CentOS7.5搭建Hadoop2.7.6完全分布式集群

    一 完全分布式集群搭建 Hadoop官方地址:http://hadoop.apache.org/ 1  准备3台客户机 1.2 关闭防火墙,设置静态IP,主机名 关闭防火墙,设置静态IP,主机名此处略 ...

  9. linux系统下对网站实施负载均衡+高可用集群需要考虑的几点

    随着linux系统的成熟和广泛普及,linux运维技术越来越受到企业的关注和追捧.在一些中小企业,尤其是牵涉到电子商务和电子广告类的网站,通常会要求作负载均衡和高可用的Linux集群方案. 那么如何实 ...

随机推荐

  1. 3.Android-ADT之helloworld项目结构介绍

    1.helloworld项目结构如下图所示: src 放项目的源代码的.而MainActivity.java文件则对应helloworld界面代码,代码如下所示: gen BuildConfig.ja ...

  2. 微信公众号:Mysticbinary

    愿你有绝对自由.每周会写一篇哲学类文章.

  3. distcc 的使用

    在项目的开发过程中,经常出现多个开发人员集中在某个 linux 内网开发机上统一开发的情况,随着开发人员越来越多.项目编译得越来越频繁,开发机的压力越来越大,所以考虑用代码交叉编译的方式来缓解开发机的 ...

  4. oopday01(面向对象-类&private&this)

    面向对象基本概述.封装 01_面向对象(面向对象思想概述) * A:面向过程思想概述    * 第一步    * 第二步 * B:面向对象思想概述    * 找对象(第一步,第二步) * C:举例   ...

  5. Sql Server数据库常用Transact-SQL脚本

    数据库 1.创建数据库 USE master ; GO CREATE DATABASE Sales ON ( NAME = Sales_dat, FILENAME = 'C:\Program File ...

  6. 写完代码就去吃饺子|The 10th Henan Polytechnic University Programming Contest

    河南理工大学第十届校赛 很久没有组队打比赛了,好吧应该说很久没有写题了, 三个人一起玩果然比一个人玩有趣多了... 前100分钟过了4题,中途挂机100分钟也不知道什么原因,可能是因为到饭点太饿了?, ...

  7. Java 包(package)的概念及实例

    包的作用 1.把功能相似或相关的类或接口组织在同一个包中,方便类的查找和使用. 2.如同文件夹一样,包也采用了树形目录的存储方式.同一个包中的类名字是不同的,不同的包中的类的名字是可以相同的,当同时调 ...

  8. C#/.Net开发入门篇(2)——第一个控制台应用程序

    相信看了上一篇文章的小伙伴已经安装好自己的开发工具了VS了,这一篇文章就教大家怎么创建第一个应用程序. 下面大家跟着我的操作一起来创建自己的第一个应用程序吧 一.打开VS工具点击左上角的文件→新建→项 ...

  9. 关于华为模拟器eNSP-防火墙USG6000V怎么重装镜像

    一.首先关闭eNSP软件 二.打开Oracle VM VirtualBox 三.单击VirtualBox “管理 - 虚拟介质管理”,将vfw_usg.vdi下面的子链接释放然后删除 四.最后回到主界 ...

  10. 在cnetos7上搭建mysql主从服务

    本文主要是介绍在centos上搭建mysql的主从服务器.如果没有搭建过的,可以查看我以前的博客,里面有详细的安装centos和在centos上安装mysql的说明. 一.安装从虚拟机: 1.右键—& ...