redis安装配置

先安装gcc,

yum install gcc

tar xzf redis-3.2.3.tar.gz

cd redis-3.2.3

make

如果报zmalloc.h:50:31: 错误:jemalloc/jemalloc.h,则使用make MALLOC=libc

make install

或者指定安装目录:make PREFIX=/usr/local/redis install

cp redis.conf /etc/

通常安装redis后必做的第一件事是更改配置文件,让redis默认以守护进程的模式启动并设置密码:

vi /etc/redis.conf

将daemonize从no改为yes

requirepass aStrongStringPassword

启动redis

# redis-server /etc/redis.conf

[root@localhost redis-3.2.4]# ps axu | grep redis
root 9711 0.0 0.0 136920 7556 ? Ssl 01:46 0:00 redis-server 127.0.0.1:6379
root 9715 0.0 0.0 112648 976 pts/0 S+ 01:46 0:00 grep --color=auto redis
[root@localhost redis-3.2.4]# redis-cli
127.0.0.1:6379> exit

查看redis整体情况

127.0.0.1:6379> client list
id=2 addr=127.0.0.1:38654 fd=5 name= age=197 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=32768 obl=0 oll=0 omem=0 events=r cmd=client
127.0.0.1:6379> info
# Server
redis_version:3.2.8
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:8ffb5d8f8beeb710
redis_mode:standalone
os:Linux 2.6.32-431.23.3.el6.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.4.7
process_id:18542
run_id:99f248a3c2cf7e0435489308dab0e4465262c592
tcp_port:6379
uptime_in_seconds:420
uptime_in_days:0
hz:10
lru_clock:13231573
executable:/root/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:823008
used_memory_human:803.72K
used_memory_rss:7794688
used_memory_rss_human:7.43M
used_memory_peak:823008
used_memory_peak_human:803.72K
total_system_memory:16726306816
total_system_memory_human:15.58G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:9.47
mem_allocator:jemalloc-4.0.3

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1489626161
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:4
instantaneous_ops_per_sec:0
total_net_input_bytes:134
total_net_output_bytes:6028863
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.29
used_cpu_user:0.21
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=2,expires=0,avg_ttl=0
127.0.0.1:6379> 

停止

#使用客户端
redis-cli shutdown
#因为Redis可以妥善处理SIGTERM信号,所以直接kill -9也是可以的
kill -9 PID

redis命令参考,建议整理过的,顺便参考官方的:http://redisdoc.com/

http://www.tuicool.com/articles/aQbQ3u

连接远程redis服务器

C:\Users\admin>cd /d d:\GMP\redis64-2.8.19

d:\GMP\redis64-2.8.19>redis-cli -h 192.168.230.128 -p 6379 -a "123456"
192.168.230.128:6379> set from-remote-key from-remote-value
OK
192.168.230.128:6379> keys *
1) "from-remote-key"
192.168.230.128:6379> get from-remote-key
"from-remote-value"
192.168.230.128:6379>

java客户端,官方推荐使用jedis。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值