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()); } }