centos7下redis安装及配置远程连接
centos7下redis安装及配置远程连接
一、安装
安装依赖
yum install gcc-c++ -y
检查gcc版本
gcc -v
若果gcc版本在5.3以下,升级到5.3以上
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# 临时设置使用该升级后的gcc,重启后还会使用默认的gcc
scl enable devtoolset-9 bash
# 一直使用升级后的gcc, 重启也不影响
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile
下载源码包并移动到指定目录
wget https://download.redis.io/releases/redis-6.0.8.tar.gz
mv redis-6.0.8.tar.gz /usr/local/
进入到
/usr/local/
解压tar -zvxf redis-6.0.8.tar.gz
进入到解压目录
cd redis-6.0.8
安装
make && make install
启动服务
cd src
redis-server
启动客户端
redis-cli
二、配置允许远程连接,后台启动服务
编辑配置文件
vim /usr/local/redis-6.0.8/redis.conf
配置文件部分修改如下
# bind 127.0.0.1
bind 0.0.0.0 # 允许外部链接
# protected-mode yes
protected-mode no # 关闭保护模式,是为了远程连接
# daemonize no
daemonize yes # 守护模式, 为了能让服务后台运行
关闭防火墙
systemctl stop firewalld
启动服务
redis-server /usr/local/redis-6.0.8/redis.conf
- 可以通过远程连接了
还没有评论,来说两句吧...