centos7安装Redis
1.安装gcc
yum -y install gcc
2. 安装tcl
yum -y install tcl
3.下载安装包
wget http://download.redis.io/releases/redis-5.0.3.tar.gz
4.解压文件
tar -zxvf redis-5.0.3.tar.gz
5.进入安装目录,执行make
cd redis-5.0.3
make
6. 指定安装目录
make install PREFIX=/usr/local/redis
7.前往安装目录
[root@iZbp1dcz9uks37mbjtm7v3Z redis-5.0.3]# cd /usr/local/redis/bin/ [root@iZbp1dcz9uks37mbjtm7v3Z bin]# ls redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
8.前台启动
./redis-cli
9.后台启动:从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录
[root@iZbp1dcz9uks37mbjtm7v3Z bin]# cp /opt/redis-5.0.3/redis.conf /usr/local/redis/bin/ [root@iZbp1dcz9uks37mbjtm7v3Z bin]# ls redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server [root@iZbp1dcz9uks37mbjtm7v3Z bin]# cd ../ [root@iZbp1dcz9uks37mbjtm7v3Z redis]# ls bin [root@iZbp1dcz9uks37mbjtm7v3Z redis]# cd bin/ [root@iZbp1dcz9uks37mbjtm7v3Z bin]# ls redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server
10. 修改 redis.conf 文件,把 daemonize no 改为 daemonize yes
11. 后台启动
./redis-server redis.conf
12. 设置开启启动
vi /etc/systemd/system/redis.service # 将下面复制进去 [Unit] Description=redis-server After=network.target [Service] Type=forking ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target
13.开机启动
[root@localhost bin]# systemctl daemon-reload [root@localhost bin]# systemctl start redis.service [root@localhost bin]# systemctl enable redis.service