安装
1 2 3
| sudo yum install redis sudo yum install epel-release sudo yum install redis
|
启动、关闭、连接
1 2 3 4 5 6 7 8 9 10 11 12
| service redis start
service redis stop
service redis status
ps -ef | grep redis
redis-cli
keys *
|
配置开机启动
从防火墙开放端口
1 2
| sudo firewall-cmd --zone=public --add-port=6379/tcp --permanent sudo firewall-cmd --reload
|
开启远程访问
默认是只能在本机访问、所以通过网络访问需要额外的配置。配置文件的目录在:/etc/redis.conf
。然后分别修改下面两处配置:


测试
1 2 3 4 5 6 7 8 9 10 11 12 13
| import redis.clients.jedis.Jedis;
public class TestRedis { public static void main(String[] args) { Jedis redis = new Jedis("192.168.102.6"); System.out.println(redis.ping()); } }
|
参考:
https://www.cnblogs.com/rslai/p/8249812.html
https://blog.csdn.net/xujian_2001/article/details/78927706