linux中Redis单机安装

Redis安装

Linux版本:CentOS release 6.9

Redis 版本:redis-3.2.12.tar.gz

默认端口:6379

1、执行解压命令

tar -xzf redis-3.2.12.tar.gz

2、执行编译命令

make MALLOC=libc

 

3、执行安装到指定目录命令,此次指定目录为 /my/mysys/redis

make PREFIX=/my/mysys/redis install

完成后目录结构

4、配置文件 复制配置文件到安装目录

mv /my/mysys/redis-3.2.12/redis.conf ./

 5、修改配置文件

将其中的"daemonize no"行改为"daemonize yes",让其在后台运行

6、启动redis

redis目录中执行启动命令   ./bin/redis-server redis.conf

 7、测试连接到redis

redis目录中执行连接命令 ./bin/redis-cli -p 6379

 8、关闭redis

redis目录中执行关闭命令 ./bin/redis-cli -p 6379 shutdown

*可能出现的问题

1缺少gcc命令

解决方法

2、错误:jemalloc/jemalloc.h

解决

 

配置文件

bind *
protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
pidfile /etc/redis/redis.pid
loglevel notice
logfile ""
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
maxmemory 500mb
maxmemory-policy noeviction
appendonly no
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-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
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
requirepass 123456

原文地址:https://www.cnblogs.com/xuchen0117/p/13754697.html