Redis学习笔记

本文详细介绍了Redis的安装步骤,包括编译、测试、安装等。还说明了查找安装位置、后台启动、关闭Redis的方法,以及查看主从状态的命令。同时介绍了Redis的三种配置方式,重点阐述了搭建集群所需修改的配置,此外还提及了Ruby的安装与升级。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


1 安装流程

cd redisxxxx

make MALLOC=libc

make test

cd src
make install
cd ..
mkdir etc
mkdir bin
cp redis.conf etc/
cp mkreleasehdr.sh redis-check-aof redis-check-rdb redis-cli redis-server ../bin
cd ../bin
./redis-server

2 查找安装位置方法

3 后台启动方法

 redis.conf 设置 deamon yes

然后指定配置文件启动

./redis-server ../etc/redis.conf

 4 redis 关闭方法

./redis-5.0.5/bin/redis-cli shutdown

5 注意

用cli需指定端口,否则默认连接6380
logfile配置相对路径默认为当前的敲命令的路径

6 查看 master /slave状态

info replication

配置redis有三种 ,单节点,主从,哨兵(主从的修改版本,可以进行slave的选举),最后是集群

 7 搭建集群需要修改的配置

cp redis-trib.rb /usr/local/bin/

 

port 7000 //端口7000,7002,7003
bind 本机ip //默认ip为127.0.0.1 需要改为其他节点机器可访问的ip 否则创建集群时无法访问对应的端口,无法创建集群
daemonize yes //redis后台运行
pidfile /var/run/redis_7000.pid //pidfile文件对应7000,7001,7002
cluster-enabled yes //开启集群 把注释#去掉
cluster-config-file nodes_7000.conf //集群的配置 配置文件首次启动自动生成 7000,7001,7002
cluster-node-timeout 15000 //请求超时 默认15秒,可自行设置
appendonly yes

 

/root/soft/redis/cluster/redis-5.0.57001/src/redis-server /root/soft/redis/cluster/redis-5.0.57001/redis.conf

/root/soft/redis/cluster/redis-5.0.57001/src/redis-server /root/soft/redis/cluster/redis-5.0.57001/redis.conf
/root/soft/redis/cluster/redis-5.0.57002/src/redis-server /root/soft/redis/cluster/redis-5.0.57002/redis.conf
/root/soft/redis/cluster/redis-5.0.57003/src/redis-server /root/soft/redis/cluster/redis-5.0.57003/redis.conf
/root/soft/redis/cluster/redis-5.0.57004/src/redis-server /root/soft/redis/cluster/redis-5.0.57004/redis.conf
/root/soft/redis/cluster/redis-5.0.57005/src/redis-server /root/soft/redis/cluster/redis-5.0.57005/redis.conf


redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

 

 

 

yum -y install ruby ruby-devel rubygems rpm-build
gem install redis

redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
set sss sss
keys *


ruby -v 查看版本低于2.3,需要升级

 

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

\curl -sSL https://get.rvm.io | bash -s stable

 4、查找配置文件 find / -name rvm.sh 
 5、配置文件生效 source /etc/profile.d/rvm.sh 
 6、下载rvm依赖 rvm requirements 
 7、查看rvm库ruby版本 rvm list known
 8、安装ruby指定版本 rvm install ruby-2.4.1
 9、使用ruby版本默认 rvm use 2.4.1 default

转载于:https://www.cnblogs.com/genestart/p/11166882.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值