博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Redis安装
阅读量:5942 次
发布时间:2019-06-19

本文共 2956 字,大约阅读时间需要 9 分钟。

环境

  • CentOS版本:CentOS 7.4
  • IP:118.190.144.33,47.104.79.18,47.104.171.222

注意事项

  • 安裝 GCC 编译工具 不然会有编译不过的问题
yum install -y gcc g++ gcc-c++ make
# 升级所有的包,防止出现版本过久不兼容问题yum -y update
  • 安装telnet

    ==需要通过telnet验证端口是否可以访问==

$ rpm -qa | grep telnet #检查是否安装了telnet$ yum install xinetd telnet telnet-server -y

关闭防火墙 节点之前需要开放指定端口,为了方便,生产不要禁用

$ firewall-cmd --state #查看防火墙是否运行  or  systemctl list-unit-files|grep firewalld.service$ service iptables stop  # 关闭命令:centos 6.x$ systemctl stop firewalld.service # 停止firewall centos 7.x

安装 Redis

下载,解压,编译安装

$ cd /opt$ wget http://download.redis.io/releases/redis-4.0.7.tar.gz$ tar xzf redis-4.0.7.tar.gz$ cd redis-4.0.7$ make$ make test #测试编译是否成功$ make install [prefix=/path] #完成安装

如果因为上次编译失败,有残留的文件

make distclean

安装遇到的异常

  • ==You need tcl 8.5 or newer in order to run the Redis test==异常解决方法

    make test 发生该异常

$ wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  $ sudo tar xzvf tcl8.6.1-src.tar.gz  -C /usr/local/  $ cd  /usr/local/tcl8.6.1/unix/  $ sudo ./configure  $ sudo make  $ sudo make install

redis.conf

#bind 127.0.0.1  注释掉bind#设置成后台进程运行redisdaemonize yes #保护模式修改为:noprotected-mode no # Specify the log file name. Also the empty string can be used to force# Redis to log on the standard output. Note that if you use standard# output for logging but daemonize, logs will be sent to /dev/null# 修改日志生成路径logfile /opt/redis-masterslave/log/redis.log

Master-slave

角色 主机
Master 118.190.144.33
Slave 47.104.79.18
Slave 47.104.171.222

redis.conf

################################# REPLICATION ################################## Master-Slave replication. Use slaveof to make a Redis instance a copy of# another Redis server. A few things to understand ASAP about Redis replication.## 1) Redis replication is asynchronous, but you can configure a master to#    stop accepting writes if it appears to be not connected with at least#    a given number of slaves.# 2) Redis slaves are able to perform a partial resynchronization with the#    master if the replication link is lost for a relatively small amount of#    time. You may want to configure the replication backlog size (see the next#    sections of this file) with a sensible value depending on your needs.# 3) Replication is automatic and does not need user intervention. After a#    network partition slaves automatically try to reconnect to masters#    and resynchronize with them.## 只需要配置slave机器slaveof 118.190.144.33 6379

验证是否成功 info replication

127.0.0.1:6379> info replication# Replicationrole:slavemaster_host:118.190.144.33master_port:6379master_link_status:up  # up:表示成功master_last_io_seconds_ago:6master_sync_in_progress:0slave_repl_offset:299slave_priority:100slave_read_only:1connected_slaves:0master_replid:0143f8f51faa2abbd3130e5b6e607063c8cf26b3master_replid2:0000000000000000000000000000000000000000master_repl_offset:299second_repl_offset:-1repl_backlog_active:1repl_backlog_size:1048576repl_backlog_first_byte_offset:1repl_backlog_histlen:299

哨兵(sentinel)

转载地址:http://bjqtx.baihongyu.com/

你可能感兴趣的文章
apache prefork模式优化错误
查看>>
通过jsp请求Servlet来操作HBASE
查看>>
JS页面刷新保持数据不丢失
查看>>
清橙A1202&Bzoj2201:彩色圆环
查看>>
使用data pump工具的准备
查看>>
springMVC---级联属性
查看>>
get和post区别
查看>>
crontab执行shell脚本日志中出现乱码
查看>>
cmd.exe启动参数说明
查看>>
《随笔记录》20170310
查看>>
网站分析系统
查看>>
从零开始来看一下Java泛型的设计
查看>>
Shell编程基础
查看>>
Shell之Sed常用用法
查看>>
3.1
查看>>
校验表单如何摆脱 if else ?
查看>>
JS敏感信息泄露:不容忽视的WEB漏洞
查看>>
分布式memcached服务器代理magent安装配置(CentOS6.6)
查看>>
Create Volume 操作(Part III) - 每天5分钟玩转 OpenStack(52)
查看>>
tomcat 8.0虚拟机配置文档
查看>>