服务器:CentOS 8.0 64bit
-
下载redis
官网 redis.io
-
需要安装gcc编译工具
[root@VM-16-6-centos local]# yum install -y gcc gcc-c++
-
上传到服务器,解压并安装
# 解压 [root@VM-16-6-centos local]# tar -zxvf redis-6.2.7.tar.gz # 进入Redis目录 [root@VM-16-6-centos local]# cd redis-6.2.7/ # 编译安装 [root@VM-16-6-centos redis-6.2.7]# make && make install # 默认安装目录 /usr/local/bin
-
前台启动
[root@VM-16-6-centos bin]# redis-server
-
后台启动
# 备份redis.conf 到 /etc目录 [root@VM-16-6-centos redis-6.2.7]# cp redis.conf /etc/redis.conf # 进入etc目录 [root@VM-16-6-centos redis-6.2.7]# cd /etc # 修改配置文件 daemonize yes 设置服务后台启动 [root@VM-16-6-centos etc]# vim redis.conf # 启动Redis [root@VM-16-6-centos etc]# cd /usr/local/bin [root@VM-16-6-centos bin]# redis-server /etc/redis.conf # 查看Redis进程 [root@VM-16-6-centos bin]# ps -ef | grep redis
-
客户端访问 redis-cli
[root@VM-16-6-centos bin]# redis-cli
-
关闭Redis
# 单实例关闭 [root@VM-16-6-centos bin]# redis-cli shutdown # 进入终端后再关闭 127.0.0.1:6379> shutdown # 多实例关闭:指定端口关闭 [root@VM-16-6-centos bin]# redis-cli -p 6379 shutdown
-
开机自启
# 复制配置文件 [root@VM-16-6-centos redis-6.2.7]# cp utils/redis_init_script /etc/init.d/redis # 修改配置文件中redis安装目录 [root@VM-16-6-centos redis-6.2.7]# vim /etc/init.d/redis # 修改权限 [root@VM-16-6-centos redis-6.2.7]# chmod 777 /etc/init.d/redis # 设置开机启动 [root@VM-16-6-centos redis-6.2.7]# chkconfig redis on