Centos7下安装Redis6.0.5
1.安装c环境
# 查看gcc版本
gcc -v
# 安装gcc,默认安装4.8.5
yum -y install gcc
# 升级到9.3.1
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本
scl enable devtoolset-9 bash
# 长期使用gcc9.3
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
2.下载redis解压
wget http://download.redis.io/releases/redis-6.0.5.tar.gz
tar xzf redis-6.0.5.tar.gz
cd redis-6.0.5
# 把redis编译安装到自己的指定目录
make install PREFIX=/usr/local/redis
3.复制redis.conf到指定位置并修改配置
cp /opt/redis6.0.5/redis.conf /usr/local/redis/6379/redis.conf
修改redis.conf配置:
# bind绑定的是自己机器网卡的ip,如果有多块网卡可以配多个ip,
# 代表允许客户端通过机器的哪些网卡ip去访问, 内网一般可以不配置bind,注释掉即可
# bind 127.0.0.1
# 改为daemonize no 改为yes 后台运行
daemonize yes
# protected-mode yes 修改为 protected-mode no 关闭保护模式,开启的话,只有本机才可以访问redis
protected-mode no
4. 启动服务
./bin/redis-server ./6379/redis.conf
ps -ef|grep redis查看是否启动成功