windows版redis的下載地址以及報錯解決辦法
下載地址:https://github.com/MSOpenTech/redis
用win+R輸入cmd開啟,在到相應的資料夾下面,輸入啟動了命令即可
win下面批量啟動redis程式碼:
package com.learn.redis;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
-
Created by dufy on 2017/3/28.
-
cmd /c dir 是執行完dir命令後關閉命令視窗。
-
cmd /k dir 是執行完dir命令後不關閉命令視窗.
-
cmd /c start dir 會開啟一個新視窗後執行dir指令,原視窗會關閉。
-
cmd /k start dir 會開啟一個新視窗後執行dir指令,原視窗不會關閉。
-
redis-cli.exe -h 127.0.0.1 -p 埠
-
info replication – 檢視主從複製
-
info sentinel-- 檢視哨兵情況
-
window本地搭redis的哨兵模式:http://blog.csdn.net/liuchuanhong1/article/details/53206028
-
啟動服務工具類
*/
public class StartRedisServer {
private final static String redisRootPath = “F:\Redis-x64-3.2.100”;public static void main(String[] args) {
List cmds = new ArrayList();
String cmdRedis6379 = "cmd /k start redis-server.exe redis.conf ";//redis-server.exe redis.conf
String cmdRedis6380 = "cmd /k start redis-server.exe redis6380.conf ";
String cmdRedis6381 = "cmd /k start redis-server.exe redis6381.conf ";//redis-server.exe redis.confcmds.add(cmdRedis6379); cmds.add(cmdRedis6380); cmds.add(cmdRedis6381); String cmdRedis26379 = "cmd /k start redis-server.exe sentinel.conf --sentinel";//redis-server.exe sentinel26479.conf --sentinel String cmdRedis26479 = "cmd /k start redis-server.exe sentinel26479.conf --sentinel";//redis-server.exe sentinel26479.conf --sentinel String cmdRedis26579 = "cmd /k start redis-server.exe sentinel26579.conf --sentinel";//redis-server.exe sentinel26479.conf --sentinel cmds.add(cmdRedis26379); cmds.add(cmdRedis26479); cmds.add(cmdRedis26579); initRedisServer(cmds);
}
public static void initRedisServer(List cmdStr){
if(cmdStr != null && cmdStr.size() > 0){
for (String cmd:cmdStr
) {
try {
Process exec = Runtime.getRuntime().exec(cmd, null, new File(redisRootPath));
Thread.sleep(1*1000);
}catch (InterruptedException e) {
System.out.println(“執行緒中斷異常” + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
System.out.println(“cmd command error” + e.getMessage());
e.printStackTrace();
}} }
}
}