在 CentOS 上启动 Redis,常见有以下几种方式,取决于你是 源码安装 还是 yum 安装。
systemctl start redis
systemctl enable redis
systemctl status redis
systemctl stop redis
systemctl restart redis
配置文件一般在:
/etc/redis.conf
redis-server /path/to/redis.conf
修改 redis.conf:
daemonize yes
然后启动:
redis-server /path/to/redis.conf
创建服务文件:
vi /etc/systemd/system/redis.service
内容示例:
[Unit]
Description=Redis
After=network.target
[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
然后:
systemctl daemon-reload
systemctl start redis
systemctl enable redis
redis-cli ping
返回:
PONG
说明启动成功。
netstat -tunlp | grep 6379
修改 redis.conf:
bind 0.0.0.0
protected-mode no
重启 Redis。
如果你能告诉我:
我可以给你更精确的配置说明。