作者:じ☆ve不哭
发布时间:2020-06-19T16:01:06
yum install -y cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc make tcl
centos7 默认的 gcc 版本小于 5.3 无法编译
sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
// 临时生效,退出 shell 或重启会恢复原 gcc 版本
sudo scl enable devtoolset-9 bash
// 永久生效
sudo echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
wget http://download.redis.io/releases/redis-6.0.5.tar.gz
tar -zxvf redis-6.0.5.tar.gz
cd redis-6.0.5
make
make test
make install
编译文件会复制到/usr/local/bin目录下
sudo mkdir /etc/redis
sudo cp redis.conf /etc/redis/
sudo vi /etc/systemd/system/redis.service
内容如下:
[Unit]
Description=Redis
After=network.target
[Service]
#Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecReload=/usr/local/bin/redis-server -s reload
ExecStop=/usr/local/bin/redis-server -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
注意Type=forking不注释掉 服务无法启动
# 使服务自动运行
sudo systemctl daemon-reload
sudo systemctl enable redis
# 启动服务
sudo systemctl restart redis
sudo systemctl status redis