1.基础环境介绍:
操作系统:Centos 6.7
redis版本:3.0.2
2.开始安装:
1)基础安装
参考链接:http://309173854.blog.51cto.com/7370240/1710655
[root@Moxiaokai ~]#yum -y install tcl [root@Moxiaokai ~]# wget http://download.redis.io/releases/redis-3.0.2.tar.gz [root@Moxiaokai ~]# tar xzf redis-3.0.2.tar.gz [root@Moxiaokai ~]# cd redis-3.0.2 [root@Moxiaokai redis-3.0.2]# make [root@Moxiaokai redis-3.0.2]#make test
[root@Moxiaokai redis-3.0.2]#mkdir /usr/local/redis [root@Moxiaokai redis-3.0.2]# make PREFIX=/usr/local/redis install
[root@Moxiaokai redis-3.0.2]# ls /usr/local/redis/bin/
2).基础配置
创建配置文件目录
[root@Moxiaokai redis-3.0.2]# mkdir /usr/local/redis/etc [root@Moxiaokai redis-3.0.2]# cp redis.conf /usr/local/redis/etc/ [root@Moxiaokai redis-3.0.2]# ln -s /usr/local/redis/etc/redis.conf /etc/redis.conf
3).创建日志文件
[root@Moxiaokai redis-3.0.2]# touch /var/log/redis.log
4).配置命令调用
命令加入系统启动变量(推荐只加入root用户变量下)
[root@Moxiaokai redis-3.0.2]# echo "export PATH=/usr/local/redis/bin:\$PATH" >> /root/.bash_profile [root@Moxiaokai redis-3.0.2]# source .bash_profile 或者(source /root/.bash_profile)
3.启动服务器并配置
1).Linux参数优化
[root@Moxiaokai redis-3.0.2]# echo 'vm.overcommit_memory=1' >> /etc/sysctl.conf [root@Moxiaokai redis-3.0.2]# sysctl -p [root@Moxiaokai redis-3.0.2]# echo never > /sys/kernel/mm/transparent_hugepage/enabled [root@Moxiaokai redis-3.0.2]# echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled;' >> /etc/rc.local [root@Moxiaokai redis-3.0.2]# echo 'echo 511 > /proc/sys/net/core/somaxconn;' >>/etc/rc.local
2).配置redis.conf文件
[root@Moxiaokai redis-3.0.2]# cat /etc/redis.conf |grep -v '#' |grep -v '^$'
daemonize yes
pidfile /var/run/redis.pid
port 6379
tcp-backlog 511
bind 127.0.0.1 192.168.4.29
timeout 0
tcp-keepalive 0
loglevel notice
logfile "/usr/local/redis/var/redis.log"
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
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-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
3).手动启动redis-server
[root@Moxiaokai redis-3.0.2]# redis-server /etc/redis.conf
4).验证服务器启动状态
[root@Moxiaokai ~]#/etc/init.d/redis status [root@Moxiaokai ~]# ps -ef |grep redis
配置自启动文件:
见附件redis配置自启动文件
4.redis关闭
[root@Moxiaokai ~]# redis-cli
127.0.0.1:6379> shutdown save
127.0.0.1:6379>quit
到此redis3.0.2编译安装结束,如有疑问和问题,欢迎大家多多交流~~~
转载于:https://blog.51cto.com/309173854/1736571