虚拟机CentOS7.0 部署Redis 并配置网络实现外部远程访问

安装gcc和tcl

yum install gcc-c++

yum install -y tcl

下载Redis

wget http://download.redis.io/releases/redis-3.2.8.tar.gz

 

解压源码

tar -zxvf redis-3.2.8.tar.gz

进入到解压目录

cd redis-3.2.8

编译安装redis

make

make install

配置Redis 能允许外部远程访问

修改配置

vi redis.conf

 

 

保存退出vi

配置Redis 随系统启动

./utils/install_server.sh

设置iptables规则,允许外部访问6379端口

iptables -I INPUT 1 -p tcp -m state --state NEW -m tcp --dport 6379 -j ACCEPT
service iptables save

 若报错【The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.】

 安装iptables服务

yum install iptables-services

 配置iptables开机自启

systemctl enable iptables.service

关闭firewalld防火墙

systemctl stop firewalld.service
systemctl disable firewalld.service

至此,配置完成。

Redis服务查看、开启、关闭

a.通过【ps -ef|grep redis】命令查看Redis进程

b.开启Redis服务操作通过/etc/init.d/redis_6379 start命令,也可通过(service redis_6379 start)


c.关闭Redis服务操作通过/etc/init.d/redis_6379 stop命令,也可通过(service redis_6379 stop)

最后使用外部工具访问 Redis

 

redis.conf配置信息

原文地址:https://www.cnblogs.com/ZeroSunny/p/12674848.html