Redis in the Windows environment

Source: Internet
Author: User
Tags redis server

Redis is a high-performance Key-value database that uses memory as primary storage with very fast data access, Of course it also provides two mechanisms to support data persistence storage. Unfortunately, the Redis project does not directly support the Windows,windows version of the project is created and maintained by the Microsoft Open Technical team for an experimental project (support 32, 64-bit), so it does not apply to the production environment, However, 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

This enables the Redis service to start 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 different databases by select N databases 32#dump persistence policy # when there is a keys The data is changed to 900 seconds 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 refresh to disk once save 6000 10000# when the dump. Rdb database compresses data Objects Rdbcompression yes#dump persisted data saved filenames Dbfilename dump.rdb########### Replication ###### ############### #Redis的主从配置, configure slaveof as the connection password for #slaveof 192.168.0.105 6379# master server from server # Masterauth<Master-password>############## Security ########### #设置连接密码 #requirepass<Password>############### LIMITS ############## #最大客户端连接数 # maxclients 128# maximum Memory utilization # MaxMemory<bytes>########## APPEND only MODE ######### #是否开启日志功能appendonly no# aof persistence strategy #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, you can change the Redis data additions and deletions, such as string manipulation:

Here are some common commands for server management:

Info    < dbsize > #选择数据库索引  Select 1flushall #清空全部数据flushdb  < servers ><  Port >  #设置为从服务器slaveof no one #设置为主服务器shutdown  #关闭服务

Redis in the Windows environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.