1 CentOS 7 安装
1.1 下载安装包
[root@localhost opt]# wget https://download.redis.io/releases/redis-6.0.8.tar.gz
1.2 解压安装包
[root@localhost opt]# tar -zxvf redis-6.0.8.tar.gz
1.3 安装gcc环境
yum -y install gcc
yum -y install epel-release
# 查看gcc版本是否在5.3以上,centos7.6默认安装4.8.5
gcc -v
# 如果gcc版本4.8.5,需要手动升级gcc到5.3及以上升级到gcc 9.3:
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 使用scl命令临时设置使用gcc 9.3版本(退出shell或重启就会恢复原系统gcc版本。)
scl enable devtoolset-9 bash
# 使用环境变量长期设置当前使用gcc 9.3版本
如果要长期使用gcc 9.3的话:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
1.4 编译安装
# 编译出错时,清除编译生成的文件
make distclean
# 编译安装到指定目录下
make PREFIX=/usr/local/redis install
# 卸载
make uninstal
1.5 拷贝配置文件到安装目录
[root@localhost redis-6.0.8]# cp redis.conf /usr/local/redis/bin
1.6 配置redis配置文件
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes # 设置后台启动
1.7 通过redis-server指定配置文件启动redis服务
[root@localhost bin]# ps -ef |grep redis
root 46371 38437 0 15:18 pts/0 00:00:00 grep --color=auto redi
[root@localhost bin]# ls
dump.rdb redis-check-aof redis-cli redis-sentinel
redis-benchmark redis-check-rdb redis.conf redis-server
[root@localhost bin]# sudo redis-server redis.conf
[root@localhost bin]# ps -ef |grep redis
root 46401 1 0 15:18 ? 00:00:00 redis-server 127.0.0.1:6379
root 46410 38437 0 15:18 pts/0 00:00:00 grep --color=auto redi
1.8 通过redis-cli 客户端连接redis
[root@localhost bin]# sudo redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379>
网友评论