Installation Redis experience in Windows environment

Source: Internet
Author: User
Tags memory usage redis zip redis server


Redis is a high-performance key-value database that uses memory as primary storage, and data access is very fast, 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 the Microsoft Open Technology team to establish and maintain an experimental project (support 32, 64 bits), so does not apply to the production environment, However, it can be used in Windows environments to develop tests.



1. Download and install



Jab here to the open source home, download the source package, unzip the ZIP packet into the Msvsbinrelease folder has three files corresponding to 32, 64 bits, Windows service Three versions, where we choose 64-bit for example, decompression redisbin64.zip to D: redis2.4, where the main use of Redis-server.exe and Redis-cli.exe, Redis-server to run the Redis server, REDIS-CLI is a command-line client, through which to connect the Redis server, and use the Redis command for a variety of operations.



2. Service startup configuration



Copy 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 key configuration notes:


 #是否作为守护进程运行 daemonize No #Redis The default listening port 6379 #客户端闲置多少秒后, disconnect timeout #日志显示级别 loglevel verbose #指定日志输出的文件名, or Specifies to the standard output port logfile Redis.log #设置数据库的数量, the default maximum is 16, the default connection database is 0, you can connect different databases through select N databases #Dump持久化策略 #当有一条Keys data is changed , 900 seconds refresh to disk once #save 900 1 #当有10 keys data is changed, 300 seconds refresh to disk once save #当有1w keys data is changed, 60 seconds refresh to disk once save 6000 1 0000 #当dump. RDB The database to compress the data object Rdbcompression Yes #dump the file name saved by the persisted data dbfilename Dump.rdb ########### Replication # # ################### #Redis的主从配置, configure slaveof instance as 192.168.0.105 6379 from server #主服务器连接密码 # Masterauth < master-password> ############## Security ########### #设置连接密码 #requirepass <password> ############### LIMITS ####### ####### #最大客户端连接数 # maxclients 128 #最大内存使用率 # maxmemory <bytes> ########## APPEND only MODE ######### #是否开启日志功能 AppE 
Ndonly 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 #vm-pages 134217728 #vm-max-threads 4 
 #Do you want to run as a daemon?
Daemonize no
#Redis Default listening port
Port 6379
# disconnected after the client is idle, disconnected
Timeout 300
#日志display level
Loglevel verbose
# Specify the file name of the log output, or specify the standard output port.
Logfile redis.log
#Set the number of databases, the default maximum is 16, the default connection database is 0, you can connect to different databases through select N
Databases 32
#DumpPersistence Strategy
#When a Keys data is changed, it is refreshed to disk once in 900 seconds.
#save 900 1
#When 10 Keys data is changed, 300 seconds is refreshed to disk once
Save 300 100
#When there are 1w keys data changed, refresh to disk once in 60 seconds
Save 6000 10000
#When the dump .rdb database is compressed, whether to compress the data object
Rdbcompression yes
#dump File name for persistent data saving
Dbfilename dump.rdb
###############################################################
#Redis master-slave configuration, configure slaveof instance as slave server
#slaveof 192.168.0.105 6379
#main server connection password
# masterauth <master-password>
############## safety ###########
#Set the connection password
#requirepass <password>
############### LIMITS ##############
#Maximum client connections
# maxclients 128
#maximum memory usage
# maxmemory <bytes>
########## APPEND ONLY MODE #########
# Whether to enable the log function
Appendonly no
# AOF Persistence Strategy
#appendfsync always
#appendfsync everysec
#appendfsync no
################ VIRTUAL MEMORY ###########
#Do you want to enable the 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



To configure slaveof from the server configuration file, fill in the server IP and port, and if the primary server has a connection password set, the password will be specified after Masterauth.



Persistence of


    • Redis provides two kinds of persistent copywriting, dump persistence and aof log file persistence.
    • Dump persistence is the complete writing of the data in memory to the data file, triggering the write by the configuration policy, and some data loss if the failure occurs after the data changes and fails to reach the triggering condition.
    • AOF persistence is a log-stored, incremental form that records the action of each data operation and is generated from these logs when data is recovered.


3. Command-line operation



Use the cmd command prompt to open the REDIS-CLI connection 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


After successful connection, you can check the Redis data, such as String operation:






Here are some common server management commands:


Info #View server information
Select <dbsize> #Select database index select 1
Flushall #clear all data
Flushdb #clear the current index database
Slaveof <server> <port> #set to slave
Slaveof no one #Set as the primary server
Shutdown #close service 
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.