###redis的编译安装
# tar xvf redis-3.0.2.tar
redis-3.0.2/
redis-3.0.2/.gitignore
redis-3.0.2/00-RELEASENOTES
redis-3.0.2/BUGS
redis-3.0.2/CONTRIBUTING
redis-3.0.2/COPYING
redis-3.0.2/INSTALL
redis-3.0.2/MANIFESTO
......
#yum install gcc jemalloc-devel
# mkdir -p /data/app/redis/
# cd redis-3.0.2
# make PREFIX=/data/app/redis #编译
# make PREFIX=/data/app/redis install #安装
# mkdir -p /data/app/redis/{conf,var} #创建目录存放配置文件和持久化数据及日志
- 编辑配置文件
# vi /data/app/redis/conf/redis.conf
daemonize yes
pidfile "/data/app/redis/var/redis.pid"
port 6379
timeout 300
loglevel debug
logfile "/data/app/redis/var/redis.log"
databases 16
slave-read-only no
save 900 5
save 300 50
save 60 50000
rdbcompression yes
dbfilename "dump.rdb"
dir "/data/app/redis/var"
appendonly no
appendfsync always
maxmemory 1gb
####系统优化 redis在持久化旧数据的时候会使用双倍内存,最好实际内存为配置的maxmemory的2倍以上,并且允许overcommitmemory # sysctl -a|grep overcommit_memory|grep 0$ && echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf && sysctl -p
####启动redis # /data/app/redis/bin/redis-server /data/app/redis/conf/redis.conf
####使用cli查看redis # /data/app/redis/bin/redis-cli info
# Server
redis_version:3.0.2
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:e68e03119d8cfceb
redis_mode:standalone
os:Linux 2.6.32-504.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:32498
run_id:a4aef01c9dd7cb6a2c641a531b40edc4c65cfd73
tcp_port:6379
uptime_in_seconds:10
uptime_in_days:0
hz:10
lru_clock:255300
config_file:/data/app/redis/conf/redis.conf
# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
# Memory
used_memory:815984
used_memory_human:796.86K
used_memory_rss:2031616
used_memory_peak:815984
used_memory_peak_human:796.86K
used_memory_lua:36864
mem_fragmentation_ratio:2.49
mem_allocator:jemalloc-3.6.0
# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1459873082
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
# Stats
total_connections_received:1
total_commands_processed:0
instantaneous_ops_per_sec:0
total_net_input_bytes:14
total_net_output_bytes:0
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0
# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
# CPU
used_cpu_sys:0.01
used_cpu_user:0.00
used_cpu_sys_children:0.00
used_cpu_user_children:0.00
# Cluster
cluster_enabled:0
# Keyspace