centos7安装redis6.x, gcc报错解决

it2023-11-02  66

文章目录

1. 升级gcc:2. gcc切换:3.重新source一下环境变量4.查看gcc版本:5. 重新编译redis6. 修改配置文件7. 创建systemctl的文件(使用systemctl进行管理)8. 创建软连接(方便在任何地方执行redis-cli) centos7默认安装的是gcc是4.8.5,redis6.0只支持5.3以上版本

1. 升级gcc:

yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

2. gcc切换:

临时切换:scl enable devtoolset-9 bash 永久切换:echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile

3.重新source一下环境变量

source /etc/profile

4.查看gcc版本:

gcc -v

5. 重新编译redis

进入redis目录,执行make install

make install PREFIX=/usr/local/redis

6. 修改配置文件

cp redis.conf /usr/local/redis/bin/

模式改为后台启动 daemonize yes

7. 创建systemctl的文件(使用systemctl进行管理)

vim /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

8. 创建软连接(方便在任何地方执行redis-cli)

ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli

最新回复(0)