1、redis安装
wget http://download.redis.io/releases/redis-2.8.17.tar.gz
tar -xzvf redis-2.8.17.tar.gz
mv redis-2.8.17 redis
cd /usr/local/redis
make
2、redis主从复制
2.1、在redis的主从服务器上均安装redis
2.2、修改redis(从)端口为6380:vim /usr/local/redis/redis.conf 找到port 6379改为6380
2.3、修改redis默认配置:
关闭ip绑定,注释redis.conf中bind 127.0.0.1
关闭保护模式,将protected-mode yes改为protected-mode no
2.4、配置主从复制:
修改redis(从)配置文件redis.conf,在末尾加上slaveof IP PORT(主IP,主port),使主从复制永久有效。
2.5、启动redis主从的redis-server,使用/usr/local/redis/src/redis-server /usr/local/redis/redis.conf #以特定的配置文件启动
3、redis启动、关闭、连接
redis启动:/usr/local/redis/src/redis-server /usr/local/redis/redis.conf #以特定的配置文件启动
redis连接:/usr/local/redis/src/redis-cli -h IP地址 -p 端口
redis关闭:/usr/local/redis/src/redis-cli -h IP地址 -p 端口 shutdown #也可以直接kill -9 pid直接进行杀掉
4、redis版本查看
/usr/loca/redis/redis-server -v
redis基本操作
最新推荐文章于 2022-11-13 22:33:51 发布