1.官网下载redis,下载最新版本,安装yum install -y gcc ,yum install -y tcl 依赖包
https://redis.io/
2.上传并解压
tar -xvf redis-3.2.8.tar.gz
修改名称:mv redis-3.2.8 redis
进入目录: cd redis/ 编译: make 进入目录: cd src 启动shell: ./redis-server说明启动成功,Port: 6379
3.启动客户端:
4.连接java,先去maven仓库下载依赖包
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
<dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> 5.java代码import redis.clients.jedis.Jedis; public class RedisJava { public static void main(String[] args) { //Connecting to Redis server on localhost Jedis jedis = new Jedis("localhost"); System.out.println("Connection to server sucessfully"); //check whether server is running or not System.out.println("Server is running: "+jedis.ping()); } }