虚拟机下CentOS7开启SSH连接
http://blog.csdn.net/tuntun1120/article/details/65443757
找回丢失的VMware Network Adapter VMnet8
http://blog.csdn.net/xiaolongwang2010/article/details/8760190
CentOS配置Redis
http://www.imooc.com/learn/839
CentOS6.5下Redis安装与配置
http://blog.csdn.net/ludonqin/article/details/47211109
测试Redis
./bin/redis-server ./redis.con
[root@iZwz9c8snbryz9283bar5nZ redis-3.2.9]# ps -ef |grep -i redis
root 27597 24307 0 18:36 pts/0 00:00:00 vim redis_init_script
root 27698 1 0 19:35 ? 00:00:00 ./bin/redis-server 127.0.0.1:6379
root 27704 27646 0 19:36 pts/1 00:00:00 grep -i redis
[root@iZwz9c8snbryz9283bar5nZ redis-3.2.9]# ./bin/redis-cli shutdown
SecureCRT连接一
drwxrwxr-x. 6 root root 4096 5鏈 17 23:39 redis-3.2.9
-rw-r--r--. 1 root root 1547695 5鏈 17 23:40 redis-3.2.9.tar.gz
[root@bogon ~]# ll
总用量 1520
-rw-------. 1 root root 1245 6月 21 12:19 anaconda-ks.cfg
drwxrwxr-x. 6 root root 4096 5月 17 23:39 redis-3.2.9
-rw-r--r--. 1 root root 1547695 5月 17 23:40 redis-3.2.9.tar.gz
[root@bogon ~]# ls
anaconda-ks.cfg redis-3.2.9 redis-3.2.9.tar.gz
[root@bogon ~]# cd redis-3.2.9
[root@bogon redis-3.2.9]# ll
总用量 208
-rw-rw-r--. 1 root root 87407 5月 17 23:39 00-RELEASENOTES
-rw-rw-r--. 1 root root 53 5月 17 23:39 BUGS
-rw-rw-r--. 1 root root 1805 5月 17 23:39 CONTRIBUTING
-rw-rw-r--. 1 root root 1487 5月 17 23:39 COPYING
drwxrwxr-x. 7 root root 211 6月 21 13:26 deps
-rw-rw-r--. 1 root root 11 5月 17 23:39 INSTALL
-rw-rw-r--. 1 root root 151 5月 17 23:39 Makefile
-rw-rw-r--. 1 root root 4223 5月 17 23:39 MANIFESTO
-rw-rw-r--. 1 root root 6834 5月 17 23:39 README.md
-rw-rw-r--. 1 root root 46695 5月 17 23:39 redis.conf
-rwxrwxr-x. 1 root root 271 5月 17 23:39 runtest
-rwxrwxr-x. 1 root root 280 5月 17 23:39 runtest-cluster
-rwxrwxr-x. 1 root root 281 5月 17 23:39 runtest-sentinel
-rw-rw-r--. 1 root root 7606 5月 17 23:39 sentinel.conf
drwxrwxr-x. 2 root root 8192 6月 21 13:27 src
drwxrwxr-x. 10 root root 167 5月 17 23:39 tests
drwxrwxr-x. 7 root root 4096 5月 17 23:39 utils
[root@bogon redis-3.2.9]# cd /user/local/redis
[root@bogon redis]# ll
总用量 52
drwxr-xr-x. 2 root root 150 6月 21 13:36 bin
-rw-r--r--. 1 root root 93 6月 21 15:40 dump.rdb
-rw-r--r--. 1 root root 46696 6月 21 13:43 redis.conf
[root@bogon redis]# cd bin
[root@bogon bin]# ll
总用量 15064
-rw-r--r--. 1 root root 76 6月 21 13:36 dump.rdb
-rwxr-xr-x. 1 root root 2431832 6月 21 13:32 redis-benchmark
-rwxr-xr-x. 1 root root 25168 6月 21 13:32 redis-check-aof
-rwxr-xr-x. 1 root root 5181840 6月 21 13:32 redis-check-rdb
-rwxr-xr-x. 1 root root 2584848 6月 21 13:32 redis-cli
lrwxrwxrwx. 1 root root 12 6月 21 13:32 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 5181840 6月 21 13:32 redis-server
[root@bogon bin]# cd..
-bash: cd..: 未找到命令
[root@bogon bin]# cd ..
[root@bogon redis]# ll
总用量 52
drwxr-xr-x. 2 root root 150 6月 21 13:36 bin
-rw-r--r--. 1 root root 93 6月 21 15:40 dump.rdb
-rw-r--r--. 1 root root 46696 6月 21 13:43 redis.conf
[root@bogon redis]# ./bin/redis-server ./redis.conf
[root@bogon redis]# ps -ef | grep -i redis
root 2376 1 0 16:59 ? 00:00:00 ./bin/redis-server 127.0.0.1:6379
root 2380 2290 0 16:59 pts/0 00:00:00 grep --color=auto -i redis
[root@bogon redis]# ./bin/redis-cli
127.0.0.1:6379> set company jxust
OK
127.0.0.1:6379> get company
"jxust"
127.0.0.1:6379> getset company baidu
"jxust"
127.0.0.1:6379> get company
"baidu"
127.0.0.1:6379> set person jack
OK
127.0.0.1:6379> get person
"jack"
127.0.0.1:6379> del person
(integer) 1
127.0.0.1:6379> get person
(nil)
127.0.0.1:6379> incr num
(integer) 1
127.0.0.1:6379> get num
"1"
127.0.0.1:6379> incr num
(integer) 2
127.0.0.1:6379> get num
"2"
127.0.0.1:6379> incr company
(error) ERR value is not an integer or out of range
127.0.0.1:6379> decr num
(integer) 1
127.0.0.1:6379> get num
"1"
127.0.0.1:6379> decr num2
(integer) -1
127.0.0.1:6379> get num2
"-1"
127.0.0.1:6379> incrby num 5
(integer) 6
127.0.0.1:6379> incrby num3 5
(integer) 5
127.0.0.1:6379> get num3
"5"
127.0.0.1:6379> decrby num 3
(integer) 3
127.0.0.1:6379> append num 5
(integer) 2
127.0.0.1:6379> get num
"35"
127.0.0.1:6379> append num4 234
(integer) 3
127.0.0.1:6379> get num4
"234"
127.0.0.1:6379> //哈希值
(error) ERR unknown command '//哈希值'
127.0.0.1:6379> hset myhash username jackson
(integer) 1
127.0.0.1:6379> hset myhash age 18
(integer) 1
127.0.0.1:6379> hmset myhash2 username rose age 21
OK
127.0.0.1:6379> hget myhash username
"jackson"
127.0.0.1:6379> hmget myhash username age
1) "jackson"
2) "18"
127.0.0.1:6379> hgetall myhash
1) "username"
2) "jackson"
3) "age"
4) "18"
127.0.0.1:6379> hgetall myhash2
1) "username"
2) "rose"
3) "age"
4) "21"
127.0.0.1:6379> hdel myhash2 username age
(integer) 2
127.0.0.1:6379> hgetall myhash2
(empty list or set)
127.0.0.1:6379> hmset myhash2 username rose age 21
OK
127.0.0.1:6379> del myhash2
(integer) 1
127.0.0.1:6379> hgetall myhash2
(empty list or set)
127.0.0.1:6379> hget myhash age
"18"
127.0.0.1:6379> hincrby myhash age 5
(integer) 23
127.0.0.1:6379> hget myhash age
"23"
127.0.0.1:6379> hexists myhash username
(integer) 1
127.0.0.1:6379> hgetall myhash
1) "username"
2) "jackson"
3) "age"
4) "23"
127.0.0.1:6379> hlen myhash
(integer) 2
127.0.0.1:6379> hkeys myhash
1) "username"
2) "age"
127.0.0.1:6379> hvals myhash
1) "jackson"
2) "23"
127.0.0.1:6379> //存储list
(error) ERR unknown command '//存储list'
127.0.0.1:6379> lpush mylist a b c
(integer) 3
127.0.0.1:6379> lpush mylist 1 2 3
(integer) 6
127.0.0.1:6379> rpush mylist2 a b c
(integer) 3
127.0.0.1:6379> rpush mylist2 1 2 3
(integer) 6
127.0.0.1:6379> lrange mylist 0 5
1) "3"
2) "2"
3) "1"
4) "c"
5) "b"
6) "a"
127.0.0.1:6379> lrange mylist2 0 -1
1) "a"
2) "b"
3) "c"
4) "1"
5) "2"
6) "3"
127.0.0.1:6379> lrange mylist2 0 -2
1) "a"
2) "b"
3) "c"
4) "1"
5) "2"
127.0.0.1:6379> lpop mylist
"3"
127.0.0.1:6379> lrange mylist 0 -1
1) "2"
2) "1"
3) "c"
4) "b"
5) "a"
127.0.0.1:6379> rpop mylist2
"3"
127.0.0.1:6379> lrange mylist2 0 -1
1) "a"
2) "b"
3) "c"
4) "1"
5) "2"
127.0.0.1:6379> llen mylist
(integer) 5
127.0.0.1:6379> llen mylist2
(integer) 5
127.0.0.1:6379> llen mylist3
(integer) 0
127.0.0.1:6379> lpushx mylist x
(integer) 6
127.0.0.1:6379> lrange mylist 0 -1
1) "x"
2) "2"
3) "1"
4) "c"
5) "b"
6) "a"
127.0.0.1:6379> lpushx mylis3 x
(integer) 0
127.0.0.1:6379> lpushx myli2 x
(integer) 0
127.0.0.1:6379> lpushx mylist2 y
(integer) 6
127.0.0.1:6379> lrange mylist2 0 -1
1) "y"
2) "a"
3) "b"
4) "c"
5) "1"
6) "2"
127.0.0.1:6379> lpush mylist3 1 2 3
(integer) 3
127.0.0.1:6379> lpush mylist3 1 2 3
(integer) 6
127.0.0.1:6379> lpush mylist3 1 2 3
(integer) 9
127.0.0.1:6379> lrange mylist3 0 -1
1) "3"
2) "2"
3) "1"
4) "3"
5) "2"
6) "1"
7) "3"
8) "2"
9) "1"
127.0.0.1:6379> lrem mylist3 2 3
(integer) 2
127.0.0.1:6379> lrange mylist3 0 -1
1) "2"
2) "1"
3) "2"
4) "1"
5) "3"
6) "2"
7) "1"
127.0.0.1:6379> lrem mylist3 -2 1
(integer) 2
127.0.0.1:6379> lrange mylist3 0 -1
1) "2"
2) "1"
3) "2"
4) "3"
5) "2"
127.0.0.1:6379> lrem mylist3 0 2
(integer) 3
127.0.0.1:6379> lset mylist 3 mmm
OK
127.0.0.1:6379> lrange mylist 0 -1
1) "x"
2) "2"
3) "1"
4) "mmm"
5) "b"
6) "a"
127.0.0.1:6379> lpush mylist 4 a b c
(integer) 10
127.0.0.1:6379> lpush mylist 4 a b c
(integer) 14
127.0.0.1:6379> lrange mylist3 0 -1
1) "1"
2) "3"
127.0.0.1:6379> lrange mylist4 0 -1
(empty list or set)
127.0.0.1:6379> lpush mylist4 a b c
(integer) 3
127.0.0.1:6379> lpush mylist4 a b c
(integer) 6
127.0.0.1:6379> lrange mylist4 0 -1
1) "c"
2) "b"
3) "a"
4) "c"
5) "b"
6) "a"
127.0.0.1:6379> linsert mylist4 after b 22
(integer) 7
127.0.0.1:6379> lrange mylist4 0 -1
1) "c"
2) "b"
3) "22"
4) "a"
5) "c"
6) "b"
7) "a"
127.0.0.1:6379> lpush mylist5 1 2 3
(integer) 3
127.0.0.1:6379> lpush mylist5 1 2 3
(integer) 6
127.0.0.1:6379> lpush mylist6 1 2 3
(integer) 3
127.0.0.1:6379> lrange mylist5
(error) ERR wrong number of arguments for 'lrange' command
127.0.0.1:6379> lrange mylist5 0 -1
1) "3"
2) "2"
3) "1"
4) "3"
5) "2"
6) "1"
127.0.0.1:6379> lrange mylist6 0 -1
1) "3"
2) "2"
3) "1"
127.0.0.1:6379> rpoplpush mylist5 mylist6
"1"
127.0.0.1:6379> lrange mylist5 0 -1
1) "3"
2) "2"
3) "1"
4) "3"
5) "2"
127.0.0.1:6379> lrange mylist6 0 -1
1) "1"
2) "3"
3) "2"
4) "1"
127.0.0.1:6379> //操作set
(error) ERR unknown command '//操作set'
127.0.0.1:6379> sadd myset a b c
(integer) 3
127.0.0.1:6379> sadd myset a
(integer) 0
127.0.0.1:6379> sadd myset 1 2 3
(integer) 3
127.0.0.1:6379> srem myset 1 2
(integer) 2
127.0.0.1:6379> smembers myset
1) "b"
2) "3"
3) "a"
4) "c"
127.0.0.1:6379> sismember myset a
(integer) 1
127.0.0.1:6379> sismember myset 0
(integer) 0
127.0.0.1:6379> sadd myal a b c
(integer) 3
127.0.0.1:6379> sadd mybl a c 1 2
(integer) 4
127.0.0.1:6379> sdiff myal myb1
1) "a"
2) "b"
3) "c"
127.0.0.1:6379> sdiff mya1 myb1
(empty list or set)
127.0.0.1:6379> sdiff myal mybl
1) "b"
127.0.0.1:6379> sadd myall a b c
(integer) 3
127.0.0.1:6379> sadd mybll a c 1 2
(integer) 4
127.0.0.1:6379> sinter myall mybll
1) "c"
2) "a"
127.0.0.1:6379> sadd myalll a b c
(integer) 3
127.0.0.1:6379> sadd myblll a c 1 2
(integer) 4
127.0.0.1:6379> sunion myalll myblll
1) "2"
2) "b"
3) "c"
4) "a"
5) "1"
127.0.0.1:6379> semebers myset
(error) ERR unknown command 'semebers'
127.0.0.1:6379> semembers myset
(error) ERR unknown command 'semembers'
127.0.0.1:6379> smembers myset
1) "b"
2) "3"
3) "a"
4) "c"
127.0.0.1:6379> scard myset
(integer) 4
127.0.0.1:6379> srandmember myset
"b"
127.0.0.1:6379> srandmember myset
"b"
127.0.0.1:6379> srandmember myset
"c"
127.0.0.1:6379> srandmember myset
"c"
127.0.0.1:6379> keys *
1) "mylist3"
2) "myal"
3) "num2"
4) "myhash"
5) "name"
6) "mylist5"
7) "num"
8) "num4"
9) "myall"
10) "myset"
11) "mylist"
12) "mylist6"
13) "mybl"
14) "num3"
15) "company"
16) "mylist2"
17) "mylist4"
18) "myalll"
19) "mybll"
20) "myblll"
127.0.0.1:6379> keys my?
(empty list or set)
127.0.0.1:6379> key my*
(error) ERR unknown command 'key'
127.0.0.1:6379> keys my*
1) "mylist3"
2) "myal"
3) "myhash"
4) "mylist5"
5) "myall"
6) "myset"
7) "mylist"
8) "mylist6"
9) "mybl"
10) "mylist2"
11) "mylist4"
12) "myalll"
13) "mybll"
14) "myblll"
127.0.0.1:6379> del myb1 myb2
(integer) 0
127.0.0.1:6379> exists my1
(integer) 0
127.0.0.1:6379> existsmyal
(error) ERR unknown command 'existsmyal'
127.0.0.1:6379> exists myal
(integer) 1
127.0.0.1:6379> get name
"hello"
127.0.0.1:6379> rename name newname
OK
127.0.0.1:6379> get newname
"hello"
127.0.0.1:6379> expire newname 1000
(integer) 1
127.0.0.1:6379> ttl newname
(integer) 993
127.0.0.1:6379> type newname
string
127.0.0.1:6379> type mylist2
list
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> select 1
OK
127.0.0.1:6379[1]> keys *
(empty list or set)
127.0.0.1:6379[1]> select 0
OK
127.0.0.1:6379> keys *
1) "mylist3"
2) "myal"
3) "num2"
4) "myhash"
5) "mylist5"
6) "num"
7) "num4"
8) "myall"
9) "newname"
10) "myset"
11) "mylist"
12) "mylist6"
13) "mybl"
14) "num3"
15) "company"
16) "mylist2"
17) "mylist4"
18) "myalll"
19) "mybll"
20) "myblll"
127.0.0.1:6379> move myset 1
(integer) 1
127.0.0.1:6379> select 1
OK
127.0.0.1:6379[1]> keys *
1) "myset"
127.0.0.1:6379[1]> type myset
set
127.0.0.1:6379[1]> select 0
OK
127.0.0.1:6379> multi exec discard
(error) ERR wrong number of arguments for 'multi' command
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> get num
"2"
127.0.0.1:6379> multi
OK
127.0.0.1:6379> incr num
QUEUED
127.0.0.1:6379> incr num
QUEUED
127.0.0.1:6379> exec
1) (integer) 3
2) (integer) 4
127.0.0.1:6379> set user tom
OK
127.0.0.1:6379> get user
"tom"
127.0.0.1:6379> multi
OK
127.0.0.1:6379> set uer jerry
QUEUED
127.0.0.1:6379> discard
OK
127.0.0.1:6379> get user
"tom"
127.0.0.1:6379> a
[root@bogon redis]#
SecureCRT连接二
Last login: Wed Jun 21 16:35:27 2017 from 192.168.150.1
[root@bogon ~]# cd /user/local/redis
[root@bogon redis]# ll
总用量 52
drwxr-xr-x. 2 root root 150 6月 21 13:36 bin
-rw-r--r--. 1 root root 517 6月 21 17:39 dump.rdb
-rw-r--r--. 1 root root 46696 6月 21 13:43 redis.conf
[root@bogon redis]# ./bin/redis-cli
127.0.0.1:6379> set num 1
OK
127.0.0.1:6379> get num
"1"
127.0.0.1:6379> incr num
(integer) 2
127.0.0.1:6379> get num
"4"
127.0.0.1:6379>