redis安装
直接看官网:
wget http://download.redis.io/releases/redis.tar.gz tar xzf redis.tar.gz cd redis make
简单使用:
启动服务: src/redis-server redis.conf 启动客户端: src/redis-cli redis> set foo bar OK redis> get foo "bar"
主要配置项(redis.conf):
port 6379 pidfile /var/run/redis_6379.pid logfile "/opt2/app/logs/redis/redis02.log" maxmemory 10G maxmemory-policy allkeys-lru aof-rewrite-incremental-fsync yes requirepass xxxx stop-writes-on-bgsave-error no #daemonize 如果需要在后台运行,把该项改为 yes
daemonize yes
LINUX内核参数调整(不调整 REDIS启动会有一系列报警):
性能: 1 vi /etc/sysctl.conf 添加 vm.overcommit_memory = 1 生效:sysctl vm.overcommit_memory=1 2 echo never > /sys/kernel/mm/transparent_hugepage/enabled vi /etc/rc.local transparent_hugepage=never 3 echo 511 > /proc/sys/net/core/somaxconn
REDIS启动:
# daemonize 已经设为 yes ./src/redis-server redis.conf # daemonize 未设为 yes ./src/redis-server redis.conf &
REDIS关闭:
# 关闭所有REDIS进程
pkill redis
#更友好的关闭REDIS
/usr/local/redis/bin/redis-cli shutdown
REDIS监控,程序挂掉自启: