linux服务之redis
Posted createyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux服务之redis相关的知识,希望对你有一定的参考价值。
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去连接,开两个终端窗口
==============================
[[email protected] 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
[[email protected] 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
[[email protected] 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"));
=======================
以上是关于linux服务之redis的主要内容,如果未能解决你的问题,请参考以下文章