www.idev.top

Linux 平台下 Redis 安装教程

Redis

Redis 是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。

使用教程

  • 安装 Redis
wget https://download.redis.io/releases/redis-6.2.5.tar.gz
tar xzf redis-6.2.5.tar.gz
cd redis-6.2.5
make install PREFIX=/usr/local/redis
ln -s /usr/local/redis/bin/* /usr/local/bin/
mkdir /usr/local/redis/{etc,var}
cp redis.conf /usr/local/redis/etc/
sed -i "s@logfile.*@logfile /usr/local/redis/var/redis.log@" /usr/local/redis/etc/redis.conf
sed -i 's@pidfile.*@pidfile /run/redis/redis.pid@' /usr/local/redis/etc/redis.conf  
sed -i "s@^dir.*@dir /usr/local/redis/var@" /usr/local/redis/etc/redis.conf 
sed -i "s@^# bind 127.0.0.1@bind 127.0.0.1@" /usr/local/redis/etc/redis.conf
sed -i 's@daemonize no@daemonize yes@' /usr/local/redis/etc/redis.conf  
sed -i 's@^supervised.*@supervised systemd@' /usr/local/redis/etc/redis.conf   
  • systemctl 开机启动
mkdir /run/redis
cp utils/systemd-redis_server.service /lib/systemd/system/redis-server.service
sed -i "s@^ExecStart.*@ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf@" /lib/systemd/system/redis-server.service
sed -i "s@^Type=.*@Type=forking@" /lib/systemd/system/redis-server.service
systemctl enable redis-server
systemctl start redis-server

注意

  • 所有操作均在 root 权限下进行
posted @ 2021-04-16 14:52  JetsungChan  阅读(80)  评论(0编辑  收藏  举报