Centos 安装Redis

本文介绍如何从源码安装Redis,并详细说明了通过utils目录下的install_server.sh脚本进行服务配置的过程,包括设置端口、配置文件、日志文件等。

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

1. 安装redis服务
去这里找最新版:
http://download.redis.io
 
 
编译:
wget http://download.redis.io/releases/redis-4.0.2.tar.gz
tar zxvf redis-4.0.2.tar.gz
cd redis-4.0.2
make
 
安装编译后的程序:
make install
 
当然,可以指定位置安装的,例如:
make PREFIX=/opt/redis4 install
 
此时:
# ls /opt/redis4/bin/
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
 
 
注意对引导按照server的影响:
# sh 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
Please select the redis executable path [] 
Mmmmm...  it seems like you don't have a redis executable. Did you run make install yet?        ####这里要指定 redis-server 的路径,这一条提示是没指定直接回车时的结果,下一条是正确的姿势
Please select the redis executable path [] /opt/redis4/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     : /opt/redis4/bin/redis-server
Cli Executable : /opt/redis4/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379                                                 ####这里有一个开机启动项的配置
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
 
 启动的时候 连同6379.config文件一起启动 ,这样AOF配置才会生效
[root@winner etc]# cd /usr/local/bin
[root@winner bin]# ./redis-server /etc/6379.conf
 
 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值