ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] # Redis的下载和安装 1:下载Redis Redis的官方网站Download页面,Redis提示说:Redis的正式版不支持Windows,要Windows学习Redis,请点击Learn more,跳转到:https://github.com/MSOpenTech/redis ~~~ The Redis project does not officially support Windows. However, the Microsoft Open Tech group develops and maintains this Windows port targeting Win64. Learn more! ~~~ 这里可以下载Windows版本的Redis, ![](https://box.kancloud.cn/da74cc760939359375e2b9e5fc7f5e6d_1138x388.jpg) # 安装和测试 (1):安装 将下载好的压缩包,进行解压,(强调:解压的目录不要带中文!!!) 2): 测试 wins+r ,输入cmd,进入命令提示符,并进入到解压的文件夹下面: ![](https://box.kancloud.cn/f3d51b9796a9efb876859538e1f0d179_1148x450.jpg) # Redis哨兵模式部署 参考博文 http://blog.csdn.net/liuchuanhong1/article/details/53206028 # Java代码批量启动windows下面的redis的服务 由于在windows 启动这么多服务太麻烦,就用java写了一个批量启动服务的代码!如下,可以直接使用! ~~~ 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命令后关闭命令窗口。<br/> * cmd /k dir 是执行完dir命令后不关闭命令窗口.<br/> * cmd /c start dir 会打开一个新窗口后执行dir指令,原窗口会关闭。<br/> * cmd /k start dir 会打开一个新窗口后执行dir指令,原窗口不会关闭。<br/> * redis-cli.exe -h 127.0.0.1 -p 端口<br/> * info replication -- 查看主从复制<br/> * info sentinel-- 查看哨兵情况<br/> * * window本地搭redis的哨兵模式:http://blog.csdn.net/liuchuanhong1/article/details/53206028<br/><br/> * * 启动服务工具类 */ public class StartRedisServer { private final static String redisRootPath = "F:\\Redis-x64-3.2.100"; public static void main(String[] args) { List<String> cmds = new ArrayList<String>(); 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 ";//redis-server.exe redis.conf String cmdRedis6381 = "cmd /k start redis-server.exe redis6381.conf ";//redis-server.exe redis.conf cmds.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<String> 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(); } } } } } ~~~