一、下载redis
- 安装gcc-c++
yum install gcc-c++
- 下载redis并解压到指定的目录
官网地址: https://redis.io/download
wget http://download.redis.io/releases/redis-6.0.3.tar.gz
tar -zxvf redis-6.0.3.tar.gz -C /opt/module/ # -C 指定解压到那个目录下
安装
- 进入到解压后的目录,并编译redis
cd /opt/module/redis-6.0.3/
make
- 安装
make install PREFIX=/opt/module/redissrver # 后面是指定的安装目录
如果报错,需要升级gcc,执行一下命令
gcc -v
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
# 以上为临时启用,如果要长期使用gcc 9.1的话:
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
在执行make
- 启动服务
./redis-server /opt/module/redis-6.0.3/redis.conf
启动成功
- 修改redis服务的配置文件
修改绑定的ip,在redis.conf的69行左右
damonize改为yes 可以后台运行
requirepass 设置密码
执行命令:
./redis-server /opt/module/redis-6.0.3/redis.conf