安装
- 下载安装包
1
| wget https://download.redis.io/releases/redis-6.0.9.tar.gz
|
- 解压安装包
1
| tar -zxvf redis-6.0.9.tar.gz
|
- 重命名
- 安装 make 所需要的包
1
| yum -y install gcc automake autoconf libtool make
|
- 编译安装 redis
如果出现了“Error jemalloc/jemalloc.h: No such file or directory” 。运行
如果出现了“error: ‘struct redisServer’ has no member named ‘maxmemory’”
1 2 3
| yum -y install centos-release-scl yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils scl enable devtoolset-9 bash
|
然后再运行‘make’命令
- 配置 redis 服务
1
| cp /usr/local/redis/utils/redis_init_script /etc/init.d/redis
|
- 将 redis-server redis-cli 拷到/user/local/bin
1
| cp /usr/local/redis/src/redis-server /usr/local/redis/src/redis-cli /usr/local/bin/
|
- 复制 redis 的配置文件到/etc/redis/目录下
1 2
| mkdir /etc/redis cp /usr/local/redis/redis.conf /etc/redis/6379.conf
|
编辑 6379.conf 文件
将 daemonize 的值改为 yes
将 requirepass 注释放开
将 bind 改为机器的 ip 地址
- 启动 redis
- 测试 redis
1 2
| redis-cli -a foobared select 1
|

- 打开 6379 端口让远程也可以访问
1 2
| firewall-cmd --zone=public --add-port=6379/tcp --permanent firewall-cmd --reload
|
欢迎关注作者公众号
