[root@winkey ~]# ll /zwf/redis
total 21816
-rw-r--r-- 1 root root 7742 Mar 24 15:16 Makefile
-rw-r--r-- 1 root root 4589099 Mar 24 15:16 redis-benchmark
-rw-r--r-- 1 root root 22169 Mar 24 15:16 redis-check-aof
-rw-r--r-- 1 root root 45387 Mar 24 15:16 redis-check-dump
-rw-r--r-- 1 root root 4692174 Mar 24 15:16 redis-cli
-rw-r--r-- 1 root root 42348 Mar 24 15:18 redis.conf
-rw-r--r-- 1 root root 6459759 Mar 24 15:16 redis-sentinel
-rw-r--r-- 1 root root 6459759 Mar 24 15:17 redis-server
[root@winkey ~]# chmod +x /zwf/redis/redis-server
[root@winkey ~]# chmod +x /zwf/redis/redis-benchmark
[root@winkey ~]# chmod +x /zwf/redis/redis-check-aof
[root@winkey ~]# chmod +x /zwf/redis/redis-check-dump
[root@winkey ~]# chmod +x /zwf/redis/redis-cli
[root@winkey ~]# chmod +x /zwf/redis/redis-sentinel
[root@winkey ~]# ll /zwf/redis
total 21816
-rw-r--r-- 1 root root 7742 Mar 24 15:16 Makefile
-rwxr-xr-x 1 root root 4589099 Mar 24 15:16 redis-benchmark
-rwxr-xr-x 1 root root 22169 Mar 24 15:16 redis-check-aof
-rwxr-xr-x 1 root root 45387 Mar 24 15:16 redis-check-dump
-rwxr-xr-x 1 root root 4692174 Mar 24 15:16 redis-cli
-rw-r--r-- 1 root root 42348 Mar 24 15:18 redis.conf
-rwxr-xr-x 1 root root 6459759 Mar 24 15:16 redis-sentinel
-rwxr-xr-x 1 root root 6459759 Mar 24 15:17 redis-server
[root@winkey ~]# /zwf/redis/redis-server /zwf/redis/redis.conf
10693:C 24 Mar 15:21:01.156 # Can't chdir to './zwf/redis': No such file or directory
[root@winkey ~]# cd /zwf/redis
[root@winkey redis]# redis-server redis.conf
2192:C 24 Mar 15:35:29.526 # Can't chdir to './zwf/redis': No such file or directory
[root@winkey ~]# cd /
[root@winkey /]# /zwf/redis/redis-server /zwf/redis/redis.conf
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 3.0.3 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6380
| `-._ `._ / _.-' | PID: 10694
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
10694:M 24 Mar 15:22:34.196 # Server started, Redis version 3.0.3
10694:M 24 Mar 15:22:34.196 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
10694:M 24 Mar 15:22:34.196 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
10694:M 24 Mar 15:22:34.196 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10694:M 24 Mar 15:22:34.196 * The server is now ready to accept connections on port 6380
[root@winkey /]# /zwf/redis/redis-cli -h 119.23.33.56 -p 6380
119.23.33.56:6380> select 7
OK
119.23.33.56:6380[7]> set zengwenfeng zengwenfeng
OK
119.23.33.56:6380[7]> get zengwenfeng
"zengwenfeng"
119.23.33.56:6380[7]> exit
[root@winkey /]#
[root@winkey /]# /zwf/redis/redis-cli -p 6380 monitor
OK
^H1490341055.497153 [0 110.87.92.248:50362] "PING"
1490341055.519985 [0 110.87.92.248:50362] "INFO"
1490341055.554574 [0 110.87.92.248:50362] "select" "8"
1490341055.586482 [8 110.87.92.248:50362] "select" "9"
1490341055.618343 [9 110.87.92.248:50362] "select" "10"
1490341055.636761 [10 110.87.92.248:50362] "select" "11"
1490341055.654184 [11 110.87.92.248:50362] "select" "12"
1490341055.685279 [12 110.87.92.248:50362] "select" "13"
1490341055.703268 [13 110.87.92.248:50362] "select" "14"
1490341055.720748 [14 110.87.92.248:50362] "select" "15"
1490341055.737773 [15 110.87.92.248:50362] "select" "16"
1490341056.494884 [15 110.87.92.248:50362] "SELECT" "0"
1490341056.550117 [0 110.87.92.248:50362] "scan" "0" "MATCH" "*" "COUNT" "10000"
1490341056.678867 [0 110.87.92.248:50362] "scan" "0" "MATCH" "*" "COUNT" "10000"
1490341060.102354 [0 110.87.92.248:50362] "scan" "0" "MATCH" "*" "COUNT" "10000"
1490341080.491115 [0 110.87.92.248:50362] "SELECT" "7"
1490341080.551713 [7 110.87.92.248:50362] "scan" "0" "MATCH" "*" "COUNT" "10000"
package redis_01; import java.util.ArrayList; import java.util.List; import redis.clients.jedis.JedisPoolConfig; import redis.clients.jedis.JedisShardInfo; import redis.clients.jedis.ShardedJedis; import redis.clients.jedis.ShardedJedisPool; public class TestRedis { /** * 随笔风~ 随风~ * * @author ZengWeFeng * @date 2015.03.12 * @param args */ public static void main(String[] args) { List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(); shards.add(new JedisShardInfo("192.168.3.15", 6379)); shards.add(new JedisShardInfo("192.168.3.2", 6379)); ShardedJedisPool sjp = new ShardedJedisPool(new JedisPoolConfig(), shards); ShardedJedis client = sjp.getResource(); try { client.set("AA", "123"); client.set("BB", "234"); client.set("CC", "345"); client.set("DD", "345"); try { System.out.println(client.get("AA")); System.out.println(client.get("BB")); System.out.println(client.get("CC")); System.out.println(client.get("DD")); } catch (Exception e) { e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } finally { sjp.returnResource(client); } } }
http://www.cnblogs.com/fengru/p/5793087.html