1.官网下载redis,下载最新版本,安装yum install -y gcc ,yum install -y tcl 依赖包java
https://redis.io/redis
2.上传并解压shell
tar -xvf redis-3.2.8.tar.gzmaven
修更名称:mv redis-3.2.8 redis
进入目录: cd redis/
编译: make
进入目录: cd src
启动shell: ./redis-server code
说明启动成功,Port: 6379server
3.启动客户端:it
4.链接java,先去maven仓库下载依赖包io
<!-- 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()); } }