Experience Redis in windows

Source: Internet
Author: User
Tags redis server

Redis is a high-performance key-value database that uses memory as the primary storage, and data access is very fast. Of course, it also provides two mechanisms to support persistent data storage. unfortunately, the apsaradb for Redis project does not support Windows directly. The Windows project is an experimental project established and maintained by the Microsoft open technical team (with 32-bit or 64-bit support), so it is not applicable to the production environment, but it can be used for development and testing in Windows.

1. Download and install

Click here to go to the open-source homepage, download the source package, decompress the ZIP package, and go to msvs \ bin \ release to D: \ redis2.4. In this example, redis-server.exeand redis-cli.exe are used to run redis servers, redis-cli is a command line client that connects to the Redis server and uses Redis commands for various operations.

 

2. Service startup configuration

Copy redis. conf to D: \ redis2.4 in the root directory of the source package. Open the CMD command prompt and enter the following command to start the redis service.

Start:

redis-server redis.conf

In this way, the redis service is successfully started.

 

Configuration:

To change the redis configuration, You need to modify the redis. conf file. The following are some of its main configuration notes:

# Whether to run daemonize no # Redis default listening port 6379 # How many seconds after the client is idle, disconnect timeout 300 # log display level loglevel verbose # specify the log output file name, you can also specify the standard output port logfile redis. log # set the number of databases. The default value is 16, and the default value is 0. You can use select N to connect to different databases 32.# Dump persistence Policy# If one of the Keys data is changed, it will be refreshed to disk once every 900 seconds # save 900 1 # When 10 Keys data is changed, 300 seconds refresh to disk once save 300 100 # When one million pieces of keys data are changed, 60 seconds refresh to disk once save 6000 10000 # When dump. whether to compress the Data Object rdbcompression yes # dump the name of the persistent data storage file dbfilename dump. rdb ########### Replication ###################### Redis Master/Slave configuration, configure slaveof as the slave server # slaveof 192.168.0.105 6379 # master server connection password
# Masterauth <master-password >############## Security ############# set the connection password
# Requirepass <password >############### LIMITS ################ maximum number of client connections # maxclients 128 # maximum memory usage # maxmemory <bytes> ########### append only mode ########## whether to enable the log function appendonly no# AOF persistence Policy
# Appendfsync always # appendfsync everysec # appendfsync no ################# virtual memory ############# whether or not enable 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 slaveof in the server configuration file, and fill in the server IP address and port. If the master server sets the connection password, specify the password after masterauth.

Persistence

Redis provides two types of persistent texts: Dump persistence and AOF Log File persistence.

Dump persistence fully writes data in the memory to the data file, which is triggered by the Configuration policy. If the data fails to meet the trigger condition after the change, some data will be lost.

AOF persistence is log storage and incremental. Each data operation is recorded and generated based on the logs during data recovery.

3. command line operations

Run the CMD command prompt to open redis-cli to connect to the redis server, or use the telnet client.

# Redis-cli-h server-p Port-a password

redis-cli.exe -h 127.0.0.1 -p 6379

After the connection is successful, you can add, delete, modify, and query redis data, such as string operations.

The following are some common commands for server management:

Info # view Server Information
Select <dbsize> # select database index select 1
Flushall # Clear all data
Flushdb # Clear the database with the current index
Slaveof <Server> <port> # Set to slave server
Slaveof no one # set as the master server
Shutdown # Shut down the service

 

More commandsReference: http://redis.readthedocs.org/en/latest/

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.