标签:jedis events ted name client host lin foo get
redis
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
cd redis-4.0.6
make
cd src/
./redis-server
./redis-cli
先启动server,再用cli去连接,开两个终端窗口
==============================
[root@localhost src]# ./redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> exit
[root@localhost src]# ./redis-cli
127.0.0.1:6379> get foo
"bar"
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> CONFIG GET *
127.0.0.1:6379> client list
id=3 addr=127.0.0.1:15897 fd=8 name= age=617 idle=520 flags=N db=0 sub=1 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=subscribe
id=4 addr=127.0.0.1:15921 fd=9 name= age=584 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
[root@localhost src]# ./redis-benchmark -n 10000
配置这个之后,远程才可以连接
127.0.0.1:6379> CONFIG SET protected-mode no
OK
127.0.0.1:6379> set aa bb
OK
=====================
package java20180118;
import redis.clients.jedis.Jedis;
public class Redis {
public static void main(String[] args) {
//连接本地的 Redis 服务
Jedis jedis = new Jedis("192.168.3.225");
System.out.println("连接成功");
//查看服务是否运行
System.out.println("服务正在运行: "+jedis.get("aa"));
}
}
=======================
标签:jedis events ted name client host lin foo get
原文地址:https://www.cnblogs.com/createyuan/p/11057249.html