一: Redis在windows下的环境搭建及配置

本文介绍了Redis在Windows下的安装过程,强调Redis是一个提供多个字典存储的服务器,类似于多数据库但不支持自定义数据库名和独立权限。在Windows环境中搭建Redis,包括配置文件redis.conf的讲解。
摘要由CSDN通过智能技术生成

1.Reids简介
Redis是一个字典结构的存储服务器,而实际上Redis提供了多个用来存储数据的字典(0-15),客户端可以指定将数据存储在哪个字典中,这与关系型数据库实例中创建多个数据库类似,所以可以将其中的每个字典理解成一个独立的数据库,Redis默认支持16个数据库,可以通过 databases 来修改这一数字,客户端与Redis建立连接后会自动选择0号数据库,但是Redis不支持自定义数据库的名字,不支持为每个数据库设置不同的密码,一个客户端要么可以访问全部的数据库要不就全部不可以访问,最重要的是个个数据库之间并不完全的隔离,flushall可以清空全部数据库的数据,这些数据库更像是一个命名的空间,不适合存储不同应用程序
2. window下环境的搭建

①:打开cmd窗口使用cd命令切换目录到Redis的安装目录(E:\TRS\redis)运行redis-server.exe redis.conf 
  如果想方便的话,可以把redis的路径加到系统的环境变量里,这样就省得再输路径了,后面的那个redis.conf可以省略,如果省略会启用默认的(启动服务端)
②:这时候另启一个cmd窗口,原来的不要关闭,不然就无法访问服务端了 (启动客户端)
  切换到redis目录下运行 redis-cli.exe -h 127.0.0.1 -p 6379 出现下图:

这里写图片描述
3. 这时候,就已经完成配置了,现在说下它的的redis.conf配置文件。下面是相关项的说明

# Redis configuration file example

# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no  
Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /var/run/redis.pid
当Redis以守护进程方式运行时,Redis默认会把pid写入/var/run/redis.pid文件,可以通过pidfile指定
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
指定Redis监听端口,默认端口为6379
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
#
# bind 127.0.0.1
绑定的主机地址
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755

# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
当 客户端闲置多长时间后关闭连接,如果指定为0,表示关闭该功能
# Set server verbosity to 'debug'
# it can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel verbose
指定日志记录级别,Redis总共支持四个级别:debug、verbose、notice、warning,默认为verbose
# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile stdout
日志记录方式,默认为标准输出,如果配置Redis为守护进程方式运行,而这里又配置为日志记录方式为标准输出,则日志将会发送给/dev/null
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no

# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0

# 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
# dbid is a number between 0 and 'databases'-1
databases 16
设置数据库的数量,默认数据库为0,可以使用SELECT <dbid>命令在连接上指定数据库id
################################ SNAPSHOTTING  #################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving at all commenting all the "save" lines.

save 900 1
save 300 10
save 60 10000
分别表示900秒(15分钟)内有1个更改,300秒(5分钟)内有10个更改以及60秒内有10000个更改。
指定在多长时间内,有多少次更新操作,就将数据同步到数据文件,可以多个条件配合
# Compress string objects using LZF when dump .rdb databases?
# For default that'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
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值