安装Redis 2.8到Windows时的注意事项

总结

这是关于在Windows环境下使用chocolatey安装Redis 2.8的笔记。

环境

    • Windows7 (64bit)

chocolatey 0.9.9.11

Redis 2.8.2104

在中国的原生区域中,安装Redis。

> choco install redis-64 -version 2.8.2104
Installing the following packages:
redis-64
By installing you accept licenses for the packages.

redis-64 v2.8.2104
 ShimGen has successfully created a shim for redis-benchmark.exe
 ShimGen has successfully created a shim for redis-check-aof.exe
 ShimGen has successfully created a shim for redis-check-dump.exe
 ShimGen has successfully created a shim for redis-cli.exe
 ShimGen has successfully created a shim for redis-server.exe
 The install of redis-64 was successful.

Chocolatey installed 1/1 package(s). 0 package(s) failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

请以中文原生态地改写以下内容,只需要一个版本 :

> redis-server --version
Redis server v=2.8.2104 sha=00000000:0 malloc=dlmalloc-2.8 bits=64 build=83ad777ec89a946b
> redis-cli --version
redis-cli 2.8.2104

建立执行环境

目录 (mù lù)

D:\dev\redis-2.8.2104
  ├─ \db
  ├─ \logs
  ├─ redis.conf
  ├─ server.bat
  └─ cli.bat

配置文件

################################ GENERAL  #####################################
port 6379
tcp-backlog 511
bind 127.0.0.1

timeout 0
tcp-keepalive 0
loglevel notice

logfile "D:/dev/redis-2.8.2104/logs/redis.log"

databases 16

################################ SNAPSHOTTING  ################################
save 900 1
save 300 10
save 60 10000

stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes

dbfilename dump.rdb
dir "D:/dev/redis-2.8.2104/db"

################################# REPLICATION #################################
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no

slave-priority 100

################################### LIMITS ####################################
maxclients 100

############################## APPEND ONLY MODE ###############################
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec

no-appendfsync-on-rewrite no

auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes

################################ LUA SCRIPTING  ###############################
lua-time-limit 5000

################################## SLOW LOG ###################################
slowlog-log-slower-than 10000
slowlog-max-len 128

################################ LATENCY MONITOR ##############################
latency-monitor-threshold 0

############################# Event notification ##############################
notify-keyspace-events ""

############################### ADVANCED CONFIG ###############################
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000

activerehashing yes

client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60

hz 10

aof-rewrite-incremental-fsync yes

执行批处理文件

redis-server.exe D:\dev\redis-2.8.2104\redis.conf
redis-cli.exe -h localhost -p 6379 -n 0

巧克力

巧克力的选项和命令

– 版本

> choco --version
0.9.9.11

请帮帮我。

> choco --help

列举

> choco list

搜索本地安装的软件包

> choco list redis -localonly
redis-64 2.8.2104
1 packages installed.

搜索

> choco search redis
> choco search redis -localonly
redis-64 2.8.2104
1 packages installed.

春季数据 Redis

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-redis</artifactId>
  <version>1.6.2.RELEASE</version>
</dependency>
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfig {

  @Bean
  public JedisConnectionFactory jedisConnectionFactory() {
    return new JedisConnectionFactory();
  }

  @Bean
  public RedisTemplate<String, Object> redisTemplate() {
    RedisTemplate<String, Object> template = new RedisTemplate<>();
    template.setConnectionFactory(jedisConnectionFactory());
    template.setKeySerializer(new StringRedisSerializer());
    template.setEnableTransactionSupport(true);
    return template;
  }

}

应用程序的属性文件

# REDIS (RedisProperties)
spring.redis.database=0 # Database index used by the connection factory.
spring.redis.host=localhost # Redis server host.
spring.redis.password= # Login password of the redis server.
spring.redis.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
spring.redis.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
spring.redis.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
spring.redis.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive.
spring.redis.port=6379 # Redis server port.
spring.redis.sentinel.master= # Name of Redis server.
spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs.
spring.redis.timeout=0 # Connection timeout in milliseconds.

RedisProperties.java 的中文释义是 Redis 属性文件。

广告
将在 10 秒后关闭
bannerAds