redis部署

一.redis部署

第一步 编译redis源码

[root@itheima ~]# cd redis-3.0.0

[root@itheima redis-3.0.0]# make

第二步 安装redis

[root@itheima redis-3.0.0]# make install PREFIX=/usr/local/redis19

第三步 前端启动的命令

[root@itheima bin]# ./redis-server

正常关闭:[root@itheima bin]# ./redis-cli shutdown

启动界面:(一旦客户端关闭,则redis服务也停掉


第四步 后端启动

需要将redis解压之后的源码包中的redis.conf文件拷贝到bin目录下,

[root@itheima bin]# cp /root/redis-3.0.0/redis.conf ./

第五步修改redis.conf文件daemonize改为yes

第六步:使用命令后端启动redis

[root@itheima bin]# ./redis-server redis.conf

第七步查看是否启动成功


关闭后端启动的方式:

正常关闭:[root@itheima bin]# ./redis-cli shutdown

第八步:防火墙设置

[root@itheima redis-3.0.0]# vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

重启防火墙设置

[root@itheima redis-3.0.0]# service iptables restart

二.

Redis持久化方案

redis.conf中可以指定持久化文件存储的目录

1.1.1 Rdb问题

一旦redis非法关闭那么会丢失最后一次持久化之后的数据

如果数据不能允许丢失那么要使用aof方式

1.1 Aof方式

Redis默认是不使用该方式持久化的。Aof方式的持久化是操作一次redis数据库

则将操作的记录存储到aof持久化文件中

第一步开启aof方式的持久化方案

redis.conf中的appendonly改为yes即开启aof方式的持久化方案


Aof文件存储的目录和rdb方式的一样

Aof文件存储的名称.


在使用aofrdb方式时如果redis重启则数据从aof文件加载

三.redis 主从配置(6台)

第一步复制出六个从机

第二步:1.修改从机的port地址为7001-7006。2.bind ip地址

第三步清除从机中的持久化文件

[root@itheima bin2]# rm -rf appendonly.aof dump.rdb

第四步:安装ruby

第五步:redis-3.0.0包下src目录中的以下文件拷贝到redis19/redis-cluster/


第六步 启动7001-7006这六台机器


第七步修改start-all.sh文件的权限

[root@itheima redis-cluster]# chmod u+x start-all.sh

[root@itheima redis-cluster]# ./start-all.sh

[root@itheima redis-cluster]# ./redis-trib.rb create --replicas 1 192.168.242.137:7001 192.168.242.137:7002 192.168.242.137:7003 192.168.242.137:7004 192.168.242.137:7005  192.168.242.137:7006

第八步 设置防火墙

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7001 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7002 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7003 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7004 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7005 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7006 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 7007 -j ACCEPT
























  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值