一、Redis的安装

  1、从官网https://redis.io/download下载最新的stable版本(也可以下载unstable版本)redis-4.0.9.tar.gz。

  2、上传到CentOS 7服务器的 /data/目录

  3、解压缩文件到 /data/redis-4.0.9目录下

> cd /data
> tar -zxvf redis-4.0..tar.gz -C /data/redis-4.0.

  4、在centOs上安装编译必要的软件(根据自己机器情况,如果已有请忽略)

# yum install gcc gcc-c++
# yum -y install automake autoconf libtool

  5、开始编译Redis

# make

  编译过程中可能会出现这个错误,因为默认分配器是jemalloc,我机器没有,具体可以自行度娘 。。。。。

解决办法之一就是修改默认分配器(我使用的办法)

# make MALLOC=libc  //改为libc

没什么意外稍等一下就编译通过了

等等,我还遇到了一个问题,截图如下

因为一个文件没有执行权限,解决办法很简单

chmod  mkreleasehdr.sh

再次执行make命令 “# make MALLOC=libc” , 应该就没啥问题了

不过编译最后出现了一句话

Hint: It's a good idea to run 'make test' ;)

什么意思呢? 执行下make test 是个好主意

我真的执行了,结果如下

[root@vm82220 redis-4.0.9]# make test
cd src && make test
make[1]: Entering directory `/data/redis-4.0.9/redis-4.0.9/src'
/bin/sh: ./runtest: Permission denied
make[1]: *** [test] Error 126
make[1]: Leaving directory `/data/redis-4.0.9/redis-4.0.9/src'
make: *** [test] Error 2

继续添加权限  “chmod 777 runtest” ,再次执行 make test, 又出问题了

[root@vm82220 redis-4.0.9]# make test
cd src && make test
make[1]: Entering directory `/data/redis-4.0.9/redis-4.0.9/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/data/redis-4.0.9/redis-4.0.9/src'
make: *** [test] Error 2

看到红字了吧,需要8.5以上的版本

安装tcl

# yum install tcl

再make test  就没什么问题了

  6、安装Redis到指定地方

本人喜欢把常用服务放到喜欢地方,这次就放到/data/redis目录下吧

# mkdir /data/redis

执行安装命令

# make PREFIX=/data/redis/ install

其实/data/redis 下只有一个bin目录,里面有几个命令文件

为了后续方面使用命令,可以把bin文件夹放到环境变量中,也可以把这几个命令连接到/usr/local/bin中,我采用后者

//软连接一定要是有全路径哦,否则可能出现错误
# ln -s /data/redis/bin/redis-server /usr/local/bin/redis-server
# ln -s /data/redis/bin/redis-server /usr/local/bin/redis-sentinel
# ln -s /data/redis/bin/redis-benchmark^Cusr/local/bin/redis-sentinel
# ln -s /data/redis/bin/redis-benchmark /usr/local/bin/redis-benchmark
# ln -s /data/redis/bin/redis-check-aof /usr/local/bin/redis-check-aof
# ln -s /data/redis/bin/redis-check-rdb /usr/local/bin/redis-check-rdb

至此,安装就完成了

二、Redis配置

  1、打开端口:6379 , Redis默认端口就是6379,可以在配置文件中修改

firewall-cmd --permanent --zone=public --add-port=/tcp
firewall-cmd --reload

  2、修改配置文件

把配置文件/data/redis-4.0.9/redis.conf复制到/data/redis/conf文件夹中,修改配置

protected-mode no   //打开其他机器连接
port //端口
daemonize yes //启用守护进程
pidfile /data/redis/run/redis_6379.pid //运行时
logfile /data/redis/log/redis_6379.log //日志
dir /data/redis/dir //数据文件夹
dbfilename dump_6379.rdb //数据文件

还有很多配置信息,建议仔细阅读一遍,满满干活啊  。。。。

  

  3、启动Redis

redis-server /data/redis/config/redis.conf

  4、登陆测试一下

# redis-cli

  单机的Redis安装配置完成

三、Redis-Sentinel的配置

  下面说一下单机中哨兵HA的配置

  哨兵模式中至少需要三个redis节点启用,一个主节点,两个从节点,我们分别使用6379(主)、6380(从)、6381(从)端口启动三个redis服务。

  1、部署redis主从模式

  创建文件夹/data/redis/conf,把redis.conf 分别复制三份 redis_6379.conf、redis_6380.conf、redis_6381.conf,vi打开redis_6380.conf修改

#端口
port 6380 #运行时
pidfile /data/redis/run/redis_6380.pid #日至
logfile /data/redis/log/redis_6380.log #数据
dbfilename dump_6380.rdb #指定master
slaveof 10.60.82.220 6379

redis_6381.conf把端口改为6381,其他也做类似修改

  2、启动redis服务

  先启动主服务

# redis-server redis_6379.conf  //主服务

  再分别启动两个从服务

# redis-server redis_slave_6380.conf //从服务
# redis-server redis_slave_6381.conf //从服务

查看进程状态

登陆主节点

# redis-cli -h 10.60.82.220 -p 

  3、配置sentinel

  也分别复制三个文件sentinel_26379.conf、sentinel_26380.conf、sentinel_26381.conf, 相关信息修改如下:

port
daemonize yes
protected-mode no
dir "/data/redis/log/"
logfile "sentinel_26379.log" sentinel monitor mymaster 10.60.82.220
sentinel down-after-milliseconds mymaster
sentinel failover-timeout mymaster
sentinel parallel-syncs mymaster
#sentinel auth-pass mymaster YKHykh123456 sentinel known-slave mymaster 10.60.82.220
sentinel known-slave mymaster 10.60.82.220
#sentinel current-epoch

其他两个文件也做相应修改

  4、启动sentinel服务

# redis-sentinel sentinel_26379.conf
# redis-sentinel sentinel_26380.conf
# redis-sentinel sentinel_26381.conf

  5、检查sentinel

# redis-cli -h 10.60.82.220 -p  //登陆服务
> sentinel masters  //查看主服务信息

> sentinel slaves mymaster //查看所有从服务信息

配置相关就算完成了

centos7下Redis-Sentinel安装和配置的更多相关文章

  1. mac与centos下redis的安装与配置

    前言 最近在用redis,下面简单写一下mac和centos下redis的安装与配置方法. 安装 mac下面 安装命令:brew intall redis 运行命令:brew services sta ...

  2. Centos7 下的SVN安装与配置

    Centos7 下的SVN安装与配置 1.关闭防火墙 临时关闭防火墙 systemctl stop firewalld 永久防火墙开机自关闭 systemctl disable firewalld 临 ...

  3. centos6.8下redis的安装和配置

    centos6.8下redis的安装和配置 下载.安装 在redis官网可以获取到最新版本的redis 进入/usr/local/目录,执行如下命令 wget http://download.redi ...

  4. linux下redis的安装及配置启动

    linux下redis的安装及配置启动 标签: redisnosql 2014-10-24 14:04 19732人阅读 评论(0) 收藏 举报  分类: 数据与性能(41)  wget http:/ ...

  5. CentOS7下NFS服务安装及配置固定端口

    CentOS7下NFS服务安装及配置 系统环境:CentOS Linux release 7.4.1708 (Core) 3.10.0-693.el7.x86_64 软件版本:nfs-utils-1. ...

  6. 莫小安 Linux下Redis的安装与配置

    转载自--Linux下Redis的安装与配置 redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了 memcached的不足,它 ...

  7. [Linux]Linux下redis的安装及配置.

    在上一篇[Linux] linux下安装配置 zookeeper/redis/solr/tomcat/IK分词器 详细实例. 我们已经将redis所需tar包拷贝到了linux下的root 根目录下, ...

  8. Linux下Redis的安装与配置

    redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了 memcached的不足,它支持存储的value类型相对更多,包括stri ...

  9. Linux下Redis的安装、配置操作说明

    Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类keyvalue存储的不足,在部分场合可以对关系数据库起到很好的补充作用.它提供了Pytho ...

  10. centos7下git的安装和配置

    git的安装: yum 源仓库里的 Git 版本更新不及时,最新版本的 Git 是 1.8.3.1,但是官方最新版本已经到了 2.9.2.想要安装最新版本的的 Git,只能下载源码进行安装. 1. 查 ...

随机推荐

  1. shell 基本操作小结

    1.echo和if else fi命令 #!/bin/bash echo hello;echo there filename=demo.sh if [ -e "$filename" ...

  2. Linux进程内存布局(翻译)

    Anatomy of a Program in Memory 在一个多任务OS中,每个进程都运行在它自己的内存沙箱中.这个沙箱就是虚拟地址空间,在32位下就是一块容量为4GB的内存地址.内核将这些虚拟 ...

  3. Linux环境下的定时任务(转载)

    今天做了个数据库的备份脚本,顺便系统得学习一下Linux下定时执行脚本的设置.Linux下的定时执行主要是使用crontab文件中加入定制计划来执行,设置比Windows稍微复杂一些(因为没有图形界面 ...

  4. [设计模式][c++]状态切换模式

    转自:http://blog.csdn.net/yongh701/article/details/49154439 状态模式也是设计模式的一种,这种设计模式思想不复杂,就是实现起来的代码有点复杂.主要 ...

  5. Codeforces 893E - Counting Arrays

    893E - Counting Arrays 思路:质因子分解. 对于每个质因子,假设它有k个,那么求把它分配到y个数上的方案数. 相当于把k个小球分配到y个盒子里的方案数. 这个问题可以用隔板法(插 ...

  6. English trip V1 - 6.Accidents Happen! 发生意外! Teacher:Corrine Key: 过去进行时 was or were + Ving

    In this lesson you will learn to talk about past occurences. 过去进行时 课上内容(Lesson) C: Hi, Loki! L: Hi, ...

  7. Vue.js Cookbook: 添加实例属性; 👍 axios(4万➕✨)访问API; filters过滤器;

    add instance properties //加上$,防止和已经定义的data,method, computed的名字重复,导致被覆写.//可以自定义添加其他符号. Vue.prototype. ...

  8. (GoRails )使用Vue.js制作拖拉list功能(v1-4) gem 'acts_as_list'(自动排列顺序)

    系列视频: use Vue.js to build the drag and drop support for the list themselves the cards that are under ...

  9. 12月12日 has_many through:的interference, option

    has_many :products, through: :cart_items, source: :product build定义:collection.build(attributes = {}, ...

  10. centos 7安装vmtools时提示The path "" is not a valid path to the xxx kernel headers.

    解决办法: yum -y install kernel-headers kernel-devel gcc reboot