# 在centOS下安装redis5.0.5 cd /usr/local # 进入所要安装的目录 wget http://download.redis.io/releases/redis-5.0.5.tar.gz # 下载redis5.0.5 tar -xzf redis-5.0.5.tar.gz # 解压 cd /usr/local/redis-5.0.5 # 进入解压目录
make # 编译
cat /etc/redis.conf | grep -v "#" | grep -v "^$" protected-mode yes port 6767 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /var/run/redis_6379.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 slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 requirepass 123456 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-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
# 配置redis # 若部署在远程服务器,例如阿里云,需要在安全策略组中加入6379端口的访问权限,否则防火墙会阻止访问6379端口,导致无法正常连接redis cd /usr/local/redis-5.0.5 # 进入安装目录 cp redis.conf redis.conf.bak # 备份redis配置文件 vim redis.conf # 编辑配置文件 requirepass xxxxxxxxxx # 设置访问密码 注释掉 bind 127.0.0.1 # 设置redis为任何ip都可访问,如需设置指定ip,则添加bind protected-mode no # 设置为no,否则不能保证全网段进行访问 daemonize yes # 设置为yes,保证以守护进程的方式运行redis 修改完成后保存退出 ln -s /usr/local/redis-5.0.5/src/redis-server /usr/bin/redis # 建立redis-server软连接 # 直接运行redis-server将以前端形式启动redis cd /usr/local/redis-5.0.5 # 进入 redis redis.conf # 按照配置文件的设置启动redis(已建立软连接)