Installation and use of Redis under Windows

Source: Internet
Author: User
Tags download redis redis server

Recently learned data caching technology, search on the internet, found that Java cache technology is more popular with Redis and memcached, for the purpose of learning, here do not compare their.

This blog focuses on the installation and use of a redis in cache technology.

One, download Redis for Windows

Search Redis fow windows on your network to download the Redis compact package. Unpack the package.

You will find 32-bit and 64-bit versions of the package, as appropriate, using the corresponding compression package.


Second, decompression

I'm using Redisbin_x64.zip's compressed package and unzip it into the Redis folder.

After unpacking, you will find only a few. exe files. Here, Redis is a good general.


Third, the configuration

Create a new Conf folder under Redis and make a redis.conf text file. Copy the contents to the configuration file.

# Redis configuration file example# By default Redis does not run as a daemon. The use of ' yes ' if you need it.# Note that Redis would write a PID file in/var/run/redis.pid when daemonized.# is running in the form of a later process, the default is n Odaemonize no# when run as a daemon, Redis write a PID file in/var/run/redis.pid by default.# You can specify a custom pi D File Location here.# If you specify a later form of execution, you need to specify a PID file pidfile/var/run/redis.pid# Accept connections on the specified port, Defau LT is 6379# monitor port number Port 6379# If you want you can bind a single interface if the BIND option is not# specified all the Inter Faces would listen for connections.# bound host ip# bind 127.0.0.1# Close The connection after a client are idle for N seconds (0 t o Disable) # Client idle timeout, set to 0, no time-out.  After idle time, the client connection is turned off timeout 300# Set server verbosity to ' debug ' # It can is one of:# debug (a lot of the information, useful for development/testing) # Notice (moderately verbose, what are want in production probably) # warning (only very important/c ritical messages is logged) # log recordsLevel loglevel debug# Specify the log file name. Also ' stdout ' can is used to force# the demon-log on the standard output.  Note that if the standard# output for logging but daemonize, logs'll be sent to/dev/null# logging mode logfile stdout# Set The number of databases. The default database is DB 0, you can select# a different one on a per-connection basis using select <dbid> where# D Bid is a number between 0 and ' databases ' -1# available databases databases 16################################ snapshotting ########### ######################## Save the DB on disk:## save <seconds> <changes>## would save the db if both the GI Ven number of seconds and the given# number of write operations against the DB occurred.## in the example below the being Haviour'll be-save:# after-SEC (min) If at least 1 key changed# after the SEC (5 min) If at least ten keys Changed# after the SEC if at least 10000 keys Changedsave 1save 10save 10000# Compress string objects usingLZF when dump. RDB databases?# for default this ' s set to ' yes ' as it's almost always a win.# If you want to save some CPU In the saving child set it to ' No ' but# the dataset would likely be bigger if you have compressible values or keys.# stored to local number If you need to compress data rdbcompression yes# the filename where to dump the db# local data name Dbfilename dump.rdb# for default save/load DB in/f Rom the working directory# Note that's must specify a directory not a file name.# local database store path dir./####################### ########## REPLICATION ################################## master-slave REPLICATION. Use slaveof to make a Redis instance a copy of# another Redis server. Note that the configuration was local to the slave# so for example it was possible to configure the slave to save the DB wit h a# different interval, or to listen to another ports, and so on.# when the service is from service, set the IP address and port number of the primary service # # slaveof <masterip> &lt masterport># If The Master is password protected (using the "Requirepass" configuration# directive below) it Is possible to tell the slave to authenticate before# starting the replication synchronization process, otherwise the Maste R will# Refuse the slave request.# when the service is from the service, set the connection password for the main service # # Masterauth <master-password>########################## ######## SECURITY #################################### Require clients to issue AUTH <PASSWORD> before processing a  NY other# commands. This might is useful in environments in which you does not trust# others with access to the host running redis-server.## Thi s should stay commented out for backward compatibility and because most# people does not need auth (e.g. they run their own servers). # Connection Password # # Requirepass foobared################################### LIMITS ################################## # # # Set the max number of connected clients at the same time. By default there# is no limit, and it's up to the number of file descriptors the Redis process# are able to open. The special value ' 0 ' means no limts.# Once the limit is reached Redis would close all the new connections sending# an error ' max number of clients reached '. # Maximum client connections, default not set # # maxclients 128# Don ' t use more Memory than the specified amount of bytes.# when the memory limit is reached Redis would try to remove keys with an# Expir E set. It'll try to start freeing keys this is going to expire# in little time and preserve keys with a longer time to live.# Redis would also try to remove objects from free lists if possible.## if all this fails, Redis would start to reply with err ORS to commands# that would use more memory, like SET, Lpush, and so on, and would continue# to reply to the most read-only comm ANDs like get.## Warning:maxmemory can is a good idea mainly if you want the use of Redis as a# ' state ' server or cache, not As a real DB. When Redis is used as a real# database the memory usage would grow over the weeks, it'll be obvious if# it's going to us E Too much memory in the long run, and you'll have the time# to upgrade. With MaxMemory after the limit was reached you ' ll START to get# errors for write operations, and this may even leads to DB inconsistency.# set maximum memory, after reaching maximum memory setting, Redis Line tries to understand the expired or expiring K EY, when this method is processed, the maximum memory setting is reached and the write operation cannot be performed. # # MaxMemory <bytes>############################## APPEND only MODE ################################ by default Redis asynchronously dumps the dataset on disk. If you can live# with the idea that the latest records would be be lost if something like a crash# happens this is the Preferr Ed to run Redis. If instead a lot# about your data and don ' t want to that a single record can get lost you should# enable the AppE nd only mode:when This mode is enabled Redis would append# every write operation received in the file Appendonly.log.  This file will# is read on startup in order to rebuild the full dataset in memory.## Note so can have both the async Dumps and the append only file if you# like (you have to comment the "save" statements above to disable the dumps). # Stil L If append only mode is enabled Redis would load the DATA from the# log file at startup ignoring the Dump.rdb file.## the name of the append only file is "Appendonly.log" # # IMP Ortant:check the bgrewriteaof to Check what rewrite the append# log file in background when it gets too big.# set up Redis service After each operation is completed, whether to update the log operation, if closed, may cause a loss of data over a period of time when the power outage, # because the Redis itself synchronization data files are synchronized according to the save conditions above, so some data will be stored in memory for a period of time. AppendOnly no# Update log file name # Appendfilename appendonly.aof# the Fsync () call tells the Operating System to actually write data On disk# instead to wait for more data in the output buffer. Some OS would really flush# data on disk, Some other OS would just try to do it asap.## Redis supports three different modes : # # No:don ' t Fsync, just let the OS flush the data when it wants. faster.# Always:fsync after every write to the append only log. Slow, safest.# Everysec:fsync only if one second passed since the last fsync. compromise.## The default is "always" that ' s the safer of the options. It's up to your to# understand if you can relax this to "everysec" that Would fsync every second# or to ' no ' that would let the operating system flush the output buffer when# it want, for better Performances (But if you can live with the idea of# some data loss consider the default persistence mode that ' s Snapshotti ng). # Update log condition with three selectable values: Appendfsync always# appendfsync everysec# appendfsync no############################### Advanced  CONFIG ################################ Glue Small output buffers together in order to send small replies in a# single TCP Packet. Uses a bit more CPUs but most of the times it's a win# in terms of number of queries per second. Use ' yes ' if unsure. #glueoutputbuf the yes# use object sharing.  Can save a lot of memory if you had many common# string in your datasets, but performs lookups against the shared objects# Pool so it uses more CPUs and can be a bit slower. Usually it's a good# idea.## when object sharing are enabled (Shareobjects Yes) you can use# shareobjectspoolsize to contro L The size of the pool used in order to try# object SharIng. A bigger pool size would leads to better sharing capabilities.# in general you want this value to is at least the double of The number of# very common strings you had in your dataset.## warning:object sharing are experimental, and don ' t enable this feature# in production before of Redis 1.0-stable. Still try this feature in# your development environment so we can test it better.# shareobjects no# shareobjec Tspoolsize 1024 # Whether to use virtual memory #vm-enabled no;# virtual memory file path, cannot multiple Redis shares # vm-swap-file/tmp/redis.swap# will all be greater than vm-max-memory Data into virtual memory. All index data is memory data regardless of the size of the vm-max-memory value. # if Vm-max-memory is set to 0, all data is stored on disk. # Vm-max-memory 0

Iv. starting a Redis server

Use the command to start the Redis server.

Redis-server.exe conf/redis.conf

After successful startup, you will see the following prompt:


V. Connect to a REDIS server

The ability to connect to a server is possible using Redis's own commands.

Redis-cli.exe-h localhost-p 6379
After the connection is successful, you will be prompted with the following:

At this point, you will be able to manipulate the data using Redis commands. For other instructions, please check the details on the Internet.

Installation and use of Redis under Windows

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.