redis安装和主从配置

环境条件:

主:192.168.5.35

备:192.168.5.38

1、解压

tar -zxvf redis-2.3.9.tar.gz

2、编译安装

make
make test     //检查一下 看有没有问题
make install

安装完之后,会在src目录下生成几个可执行文件,分别是mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server。其中redis-server是启动Redis服务的,redis-cli是进入Redis客户端的。

3、初始化

# cd /usr/local/redis/utils/

[root@xt-redis-2 utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server


Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.

4、配置

vim /etc/redis/6379.conf

daemonize yes

bind 0.0.0.0

5、启动

/usr/local/redis/src/redis-server /etc/redis/6379.conf

6、主从配置:

备redis配置:vim /etc/redis/6379.conf

slaveof 192.168.8.35 6379

重启redis生效

6、测试、查询

在master和slave分别执行info命令,查看结果如下:

[root@xt-redis-2 utils]# /usr/local/redis/src/redis-cli 
127.0.0.1:6379> info


主上查询显示:

然后在master执行set age 18

在slave执行get age,看是否能得到18,如果能够得到值则说明配置成功

主:


从:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值