Redis常用命令
1、 启动Redis
- 前台启动:./redis-server
- 后台启动:./redis-server ./redis.conf
(需要配置redis.conf)
把之前redis.conf里面的 daemonize no 改为 daemonize yes
2、查看Redis服务和进程
ps -ef | grep redis
或
netstat -ano | grep 6379
3、访问客户端Cli
./src/redis-cli
如果设置密码,用参数 -a指定密码
./src/redis-cli -a yourpassword
4、关闭Redis
./redis-cli shutdown
或
kill -9 PID
可以使用ps -ef | grep redis 查进程号(PID)
注意:上述的操作过程中,始终是关闭了防火墙的,关闭的命令如下:
centos 7:
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
centos 7之前的版本:
service iptables stop #停止
chkconfig iptables off #禁用