first, talk about the installation of a single Redis service use of Redis is 2.8.17 version, downloaded from the official website extract the contents of: &NBSP ; Installing and starting a Redis service is simple, as follows: 1, configuring the log file directory: Use only the Modify logfile to navigate to the log folder & nbsp 2, command line locator to the directory to extract files &NB Sp cd/d D:\MasterRedis-2.8.17 (Windows 7)   &NB Sp cd/d D:\SlaveRedis-2.8.17 ( Windows Server) 3, installing Redis:redis-server--service-install redis.windows.conf-- LogLevel verbose 4, start Redis:redis-server--service-start 5, stop Redis:redis-server--service-stop 6, Uninstalling Redis:redis-server--service-uninstall
Second, we turn to the conclusionAfter a half-day toss, the conclusion is: success! The process I'll talk about next, the conclusion is to deploy the master-slave service on a single Windows servers machine, the second Redis example will never start (solved when writing this article), can be successfully deployed on two different servers
Iii. Talk about the process1, would like to install the deployment of a single redis continuous operation two times, only to find that the first operation has started a service called Redis, the second operation when the service is not installed at all, the solution is to give the Redis service named, the command is as follows: Redis-server-- Service-install redis6379.windows.conf--loglevel verbose--service-name Redis6379--service-name is the service name, the pit daddy is I copy the life on the net So there is only one bar (-), half a day do not get the desired results (a hillock will also create a service named Redis) 2, the installation of the service when added servicename, in the service start, stop, uninstall also need to add servicename parameter 1, service Start: Redis-server--service-start--service-name Redis6379 redis6379.windows.conf
2, Service stop: Redis-server--service-stop--service-name Redis6379 redis6379.windows.conf 3, service uninstall: Redis-server--servi Ce-uninstall--service-name Redis6379 redis6379.windows.conf 3, finally talk about why the master-slave service can be installed successfully, but the second service will never start after starting a service
Pits
The message for the Event Viewer is as follows: (unintelligible!) )
Pit just in the command to install the service: Redis-server--service-install--service-name Redis6379 redis6379.windows.conf--loglevel verbose (not OK) Redis-server--service-install redis6379.windows.conf--loglevel verbose--service-name Redis6379 (OK)
See clearly, it is the location of the Service-name parameter, not before the configuration file, must be placed in the last
v. Talk about changes to the configuration file (redis.windows.conf)1, the Master Redis service configuration file does not have to make the modification possibly this place needs to modify, I did not do the test 2, changes from the Redis service configuration file are as follows: 1, Port modification 2, currently see here not Make changes, comment 3, log file 4, specify the IP and port of the primary Redis service
v. Cut a diagram to illustrate the conclusion (the tool used is Redisdesktopmanager)1. Redisremotemaster is the master Redis for remote host
2, Redisremoteslaver for remote host from Redis (can see start master Redis not set ABC, return is NULL, set, return new value) 3, redislocal as host from Redis (same as 2)
v. Calling the Redis code
1, configure the master-slave server
<appSettings> <!--redis Write server address, you can add multiple servers through, delimited-- <add key= "readwritehosts" value= " 192.168.1.100:6379 "/> <!--redis Read server address, you can add multiple servers via, divider-- <add key=" readonlyhosts "value=" 192.168.1.100:6380,127.0.0.1:6379 "/> </appSettings>
2. Redis Initialization (RedisConfig.cs
)
Class Redisconfig {public static redisclient Redis { get { return (redisclient) Reidspools.getclient (); } } private static string[] hosts; private static Pooledredisclientmanager Reidspools; Static Redisconfig () { var readwritehosts = configurationmanager.appsettings["Readwritehosts"]. Split (', '); var readonlyhosts = configurationmanager.appsettings["Readonlyhosts"]. Split (', '); Reidspools = new Pooledredisclientmanager (readwritehosts, readonlyhosts, new redisclientmanagerconfig { Maxwritepoolsize = 100,//"write" link pool link number maxreadpoolsize = 200,//"read" link pool link number AutoStart = True, defaultdb = 0 }); } }
3. Redis Operation Tool Class (RedisHelper.cs)
public class Redishelper {///<summary>////</summary>//<type param name= "T" ></typeparam>//<param name= "key" ></param>//<returns></retu Rns> Public T get<t> (string key) {using (var Redis = Redisconfig.redis) { Return Redis. Get<t> (key); }}///<summary>///Set values///</summary>//<typeparam name= "T" >< /typeparam>//<param name= "key" ></param>///<param Name= "value" ></param> <returns></returns> public bool Set<t> (string key, T value) {using (var Redis = Redisconfig.redis) {return redis. Set<t> (key, value); }}///<summary>//Set value///</summary>//<typeparam NAme= "T" ></typeparam>//<param name= "key" ></param>//<param name= "value" ></ param>//<returns></returns> public bool Set<t> (string key, T value, DateTime DT) {using (var Redis = Redisconfig.redis) {return redis. Set<t> (key, value, DT); } } }
4. Calling code
Class program { static void Main (string[] args) { var redis = new Redishelper (); Redis. Set<string> ("AA", DateTime.Now.ToString ()); var d = Redis. Get<string> ("AA"); } }
Category: Other databases
Redis Master Service Deployment