centos7中安装redis
centos7安装redis
1、安装epel源
yum -y install epel-release
2、安装redis
yum -y install redis
3、启动redis
#启动
systemctl start redis
#开机启动
systemctl enable redis
4、配置redis
#编辑配置文件
vim /etc/redis.conf
#修改ip,默认127.0.0.1只允许本机联系
bind 127.0.0.1
#默认端口,可以修改
port 6379
#设置密码123
requirepass 123
5、使用redis
#登录reids
redis-cli -h ip -p 6379
#密码认证
auth 123
#常用操作
#查看所有key
keys *
#设置一个变量
set name 张三
#获取一个变量值
get name
源码安装redis6
yum -y install epel-release wget make gcc-c++
cd /opt
wget https://download.redis.io/releases/redis-6.2.3.tar.gz
tar -xf redis-6.2.3.tar.gz
cd redis-6.2.3
make
make install PREFIX=/usr/local/redis
cp redis.conf /etc/redis.conf
sed -i "s/bind 127.0.0.1/bind 0.0.0.0/g" /etc/redis.conf
sed -i "s/daemonize no/daemonize yes/g" /etc/redis.conf
sed -i "561i maxmemory-policy allkeys-lru" /etc/redis.conf
sed -i "481i requirepass weakPassword" /etc/redis.conf
vi /etc/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/bin/redis-server /etc/redis.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
[Install]
WantedBy=multi-user.target
systemctl enable redis
systemctl start redis
#配置全部变量
echo "export PATH=/usr/local/reids/bin:$PATH" >> /etc/profile
source /etc/profile
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)