【Redis】Centos7 安装 redis(详细教程)
    		       		warning:
    		            这篇文章距离上次修改已过424天,其中的内容可能已经有所变动。
    		        
        		                
                在CentOS 7上安装Redis的步骤如下:
- 安装依赖项
 
sudo yum install -y gcc make- 下载Redis源码
 
wget http://download.redis.io/releases/redis-5.0.3.tar.gz- 解压Redis源码
 
tar xzf redis-5.0.3.tar.gz- 编译Redis
 
cd redis-5.0.3
make- 安装Redis
 
sudo make install- 启动Redis服务
 
redis-server设置Redis为后台服务
首先复制Redis的配置文件到/etc/目录下:
sudo cp redis.conf /etc/redis.conf然后编辑/etc/redis.conf文件,将daemonize设置为yes,以便Redis可以作为后台服务运行。
使用systemd管理Redis服务
创建一个systemd服务文件:
sudo vi /etc/systemd/system/redis.service添加以下内容:
[Unit]
Description=Redis In-Memory Data Store
After=network.target
 
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
 
[Install]
WantedBy=multi-user.target启动Redis服务并设置开机自启:
sudo systemctl start redis
sudo systemctl enable redis以上步骤安装了Redis 5.0.3版本,你可以根据需要替换为其他版本的Redis。
评论已关闭