Redis is a high-performance Key-value database that uses memory as primary storage, data access is very fast, and of course it provides two mechanisms to support data persistence storage. Unfortunately, Redis projects do not directly support windows, The Windows Edition project was developed and maintained by the Microsoft Open Technology team for an experimental project (32, 64-bit support), so the production environment is not applicable, but it can be used for development testing in a Windows environment.
1. Download and install
Poke here on the open source home, download the source package, unzip the zip package into the Msvs\bin\release folder has three files corresponding to 32, 64-bit, three versions of Windows services, here we choose 64-bit for example, decompression redisbin64.zip to D:\ redis2.4, the main use of Redis-server.exe and Redis-cli.exe, Redis-server for running Redis server, REDIS-CLI is a command line client, through which to connect Redis server, and use Redis commands for a variety of operations.
2. Service startup configuration
Copy the source package root directory redis.conf to D:\redis2.4, open the cmd command prompt, enter the following command to start the Redis service
Start:
Redis-server redis.conf
So the Redis service started successfully.
Configuration:
Changing the configuration of Redis requires modifying the redis.conf file, and here are some of its major configuration notes
#是否作为守护进程运行daemonize No#redis Default Listener port 6379# client idle for how many seconds, disconnect timeout 300# log display level loglevel verbose# Specify the file name of the log output, can also be specified to the standard output port logfile redis.log# set the number of databases, the default maximum is 16, the default connection to the database is 0, you can connect to different databases by select N databases#Dump持久化策略# When one of the keys data is changed, 900 seconds is flushed to disk once #save 900 # when 10 keys data is changed, 300 seconds is flushed to disk once save 300 100# when there are 1w keys data is changed, 60 seconds flush to disk once S Ave 6000 10000# when the dump. Rdb database compresses the data object Rdbcompression yes#dump persisted data saved file name Dbfilename dump.rdb########### Replication ##################### #Redis的主从配置, configure the slaveof instance as the connection password from the server #slaveof 192.168.0.105 6379# master server
# Masterauth <master-password>############## Security ########### #设置连接密码
#requirepass <password>############### LIMITS ############## #最大客户端连接数 # maxclients 128# maximum Memory utilization # MaxMemory < bytes>########## APPEND only MODE ######### #是否开启日志功能appendonly no# aof persistence policy
#appendfsync always#appendfsync everysec#appendfsync no################ VIRTUAL MEMORY ########### #是否开启VM function # vm-enabled no# vm-enabled yes#vm-swap-file logs/redis.swap#vm-max-memory 0#vm-page-size 32#vm-pages 134217728# Vm-max-threads 4
Master-slave replication
Configure the slaveof from the server configuration file, fill in the server IP and port, if the primary server set the connection password, after the Masterauth to specify the password on the line
Persistence of
Redis provides two persistent copywriting, dump persistence and aof log file persistence
Dump persistence is the complete writing of in-memory data to a data file, which is triggered by a configuration policy, and if a failure occurs after the data has changed and the trigger condition is not met, it can result in partial data loss.
AOF persistence is log storage, is the form of increments, recording each data manipulation action, data recovery is based on these logs to generate.
3. Command-Line Operations
Use the cmd command prompt to open the REDIS-CLI connection to the Redis server, or you can use the Telnet client
# redis-cli-h Server –p port –a password
Redis-cli.exe-h 127.0.0.1-p 6379
Once the connection is successful, the Redis data can be changed and deleted, such as string manipulation
Here are some common commands for server management:
Info #查看服务器信息
Select <dbsize> #选择数据库索引 Select 1
Flushall #清空全部数据
Flushdb #清空当前索引的数据库
Slaveof < servers > < ports > #设置为从服务器
Slaveof no one #设置为主服务器
Shutdown #关闭服务
more Command reference: http://redis.readthedocs.org/en/latest/
Using Redis under Windows