Linux编译安装Redis

Install Redis on Linux

Install Redis from Source

除了C编译器和libc外,Redis没有其他依赖包。

Compiling Redis

首先解压Reids tar包,进入redis目录,运行make命令进行编译:

tar -xzvf redis-stable.tar.gz
cd redis-stable
make

如果编译成功,在src目录下可以发现一下Redis二进制文件:

  • redis-server: Redis Server
  • redis-cli:Redis客户端工具

T将二进制文件默认安装在/usr/local/bin下

make install

Starting and stopping Redis in the foreground

启动Redis

redis-server

Redis Server运行在前台,运行Ctrl-C​.停止Redis。

Install Redis more properly

创建redis systemd服务

 假设redis-server 和redis-cli 文件都放在 /usr/local/bin目录下

分别创建redis配置文件和数据文件目录

mkdir /etc/redis
mkdir /usr/local/redis/6379

从源码包中拷贝redis systemd示例文件

cp utils/systemd-redis_server.service /usr/lib/systemd/system/

修改systemd 文件.

ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Type=forking
User=redis
Group=redis
WorkingDirectory=/usr/local/redis/6379

从源码包中拷贝redis 示例配置文件

cp redis.conf /etc/redis/redis.conf

创建redis工作和数据目录

mkdir /usr/local/redis/6379

修改redis配置文件

  • Set daemonize to yes (by default it is set to no).
  • Set the pidfile to /var/run/redis_6379.pid​ (modify the port if needed).
  • Change the port accordingly. In our example it is not needed as the default port is already 6379.
  • Set your preferred loglevel.
  • Set the logfile to /usr/local/redis/6379/redis_6379.log​
  • Set the dir to /usr/local/redis/6379​ (very important step!)

最后将redis systemd服务加入开机自启

systemctl enable systemd-redis_server.service

启动redis服务

systemctl start systemd-redis_server.service
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值