1.安装gcc
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
source /opt/rh/devtoolset-9/enable
echo “source /opt/rh/devtoolset-9/enable” >>/etc/profile
2.下载redis
wget http://download.redis.io/releases/redis-6.0.6.tar.gz
解压
tar -zxf redis-6.0.6.tar.gz
3.编译
cd redis-6.0.6
make
4.安装
4.1当前目录安装
make install
4.2指定安装路径
make install PREFIX=/usr/software/redis
5.启动
5.1前端启动
进入src: cd src
./redis-server
关闭:ctrl+c
5.2后端启动(守护进程启动)
5.2.1拷贝redis.conf配置文件到redis的安装目录src
cp /usr/software/redis/redis-6.0.6/redis.conf /usr/software/redis/redis-6.0.6/src/
5.2.2修改redis.conf
vim redis.conf
将daemonize
由no
改为yes
daemonize yes
默认绑定的是回环地址,默认不能被其他机器访问
#bind 127.0.0.1
是否开启保护模式,由yes该为no
protected-mode no
5.2.3启动
./redis-server redis.conf
5.2.4关闭
./redis-cli shutdown
6 其它命令
redis-server :启动 redis 服务
redis-cli :进入 redis 命令客户端
redis-benchmark : 性能测试的工具
redis-check-aof : aof 文件进行检查的工具
redis-check-dump : rdb 文件进行检查的工具
redis-sentinel : 启动哨兵监控服务
7安装出错
server.c:5117:168: 错误:‘struct redisServer’没有名为‘sentinel_mode’的成员
serverLog(LL_WARNING, “Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/%s.conf”, argv[0], server.sentinel_mode ? “sentinel” : “redis”);
gcc -v # 查看gcc版本
yum -y install centos-release-scl # 升级到9.1版本
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