repeat repeat-cli

No default access control:

Remote service connection:

Repeat -h 127.0.0.1 -p-cli 6379

 

windows下 :redis-cli.exe -h 127.0.0.1 -p 6379
 
redis 127.0.0.1:6379>

Remote service halt:

redis-cli -h 172.168.10.254 -p6379 shutdown

 

2) when there is access control (plus -a password):

redis-cli -h 127.0.0.1 -p 6379 -a 123456

 

In addition to developing the -a parameter password when you log in, you can also do not specify a password when you log in and be authenticated before the action.

 

Suppose there are two Redis server, ip were: 192.168.1.101 and 192.168.1.103, how the redis-cli access 103 of 101 redis on it? Before a remote connection 103, the redis-cli talk about several key parameters:

用法:redis-cli [OPTIONS] [cmd [arg [arg ...]]]

-h <host ip>, default is 127.0.0.1

-p <port>, the default is 6379

-a <password>, if redis locked, you need to pass a password

--help, display help information

By rendis-cli usage presentation, connected to 101,103 should be very simple:

[root@linuxidc001 ~]# redis-cli -h 192.168.1.103 -p 6379 

repeat 192.168.1.103:6379> 

101 to 103 provided on all string values ​​user.1.name = zhangsan

redis 192.168.1.103:6379> set user.1.name zhangsan 

OK 

See ok, indicate successful set up. Then on the 103 landed directly, to see if I can get this value.

 

redis 192.168.1.103:6379>  keys *

redis 192.168.1.103:6379>  select 1

 

 

1, the connecting operation related commands

  • quit: close the connection (Connection)
  • auth: simple password authentication

2, the operation command value

  • exists (key): to confirm the existence of a key
  • del (key): delete a key
  • type (key): return type
  • keys (pattern): returns to meet all the key given pattern of
  • randomkey: returns a random key key space
  • rename (oldname, newname): The key of oldname renamed to newname, if it exists delete newname newname represented key
  • dbsize: Returns the number of key current database
  • expire: Time to set a key (s) of
  • ttl: Time to get a key of
  • select (index): Press the index query
  • move (key, dbindex): The current database is transferred to a key index of the database have dbindex
  • flushdb: Delete the current selection of all key database
  • flushall: Delete all all key database

3, command String operations

  • set (key, value): the name given to the database key value contains the string
  • get (key): Returns the name of the database's string of key value
  • getset (key, value): to name one of the key value given the string
  • mget (key1, key2, ..., key N): Returns the plurality of library string (they are named key1, key2 ...) of the value
  • setnx (key, value): If the name is not present in the key string, the string is added to the library, as a key name, value is value
  • setex (key, time, value): string added to the library (the name key, value value) at the same time, set time expires
  • mset (key1, value1, key2, value2, ... key N, value N): simultaneously to a plurality of string assigned name value i is assigned a string key i
  • msetnx (key1, value1, key2, value2, ... key N, value N): If all the names for the string key i do not exist, add string to the library, the name assigned value i key i
  • incr (key): name is key string by an operator
  • incrby (key, integer): integer is the key to increase the name of the string
  • decr (key): name is key string Decrement
  • decrby (key, integer): integer is the key to reduce the name of the string
  • append (key, value): value string of the name of an additional key value
  • substr (key, start, end): Returns the name of the key value for the sub-string of the string

4, the operation command List

  • rpush (key, value): value of the added value of a key element to the tail of the list name
  • lpush (key, value): value of the added value of a key element for the head of the list name
  • llen (key): Returns the name is key length of the list
  • lrange (key, start, end): Returns the name of the start to end of the element between the key in the list (index starts from 0, the same below)
  • ltrim (key, start, end): intercepting name is key list, between the retention elements start to end
  • lindex (key, index): Returns the name is key element in list at index
  • lset (key, index, value): assign key element to the name of the list in the index to value
  • lrem (key, count, value): delete the name is key to count median value of list elements. count is 0, the value is to delete all the elements, count> 0 value of count value from start to finish deleting elements, count <0 Remove the head from the tail | count | is a value of the element. lpop (key): to go back and delete the name of the first element key in the list of rpop (key): to go back and delete the name of the last element key in the list of blpop (key1, key2, ... key N, timeout): lpop command block version. That is when the timeout is zero, if encountered the name list key i does not exist or the list is empty, the command ends. If timeout> 0, then you encounter this situation, wait for timeout seconds, if the problem is not resolved, perform pop operation keyi + list beginning 1.
  • brpop (key1, key2, ... key N, timeout): block version of rpop. Refer to the previous command.
  • rpoplpush (srckey, dstkey): Returns the name and remove the last element of the list srckey, and adds the element to the name list of the head dstkey

5, the operation command Set

  • sadd (key, member): the name for the key elements of the set to add member
  • srem (key, member): delete the element member name is key set of
  • spop (key): random back and delete the name of a key element in the set
  • smove (srckey, dstkey, member): The name srckey member element from the set of moves name set dstkey
  • scard (key): Returns the name is key set of base
  • sismember (key, member): testing whether the member is the name for the set of key elements of
  • sinter (key1, key2, ... key N): intersection of
  • sinterstore (dstkey, key1, key2, ... key N): and the intersection of the intersection of a set of saved to dstkey
  • sunion (key1, key2, ... key N): find and set
  • sunionstore (dstkey, key1, key2, ... key N): seeking and sets and save and set to set dstkey
  • sdiff (key1, key2, ... key N): Set differencing
  • sdiffstore (dstkey, key1, key2, ... key N): to save a set of differencing and the difference between the current collector dstkey
  • smembers (key): Returns the name of all the elements of the set of key
  • A random element of the set key and returns the name of: srandmember (key)

6, command zset (sorted set) operating

  • zadd (key, score, member): add elements to the member name is key in zset, score for sorting. If the element already exists, it updates the score according to the sequence element.
  • zrem (key, member): delete the element member name is key in zset
  • zincrby (key, increment, member): If the name is key Member zset element already exists, the score of the element is increased increment; otherwise, adds the element to the collection, which score value increment
  • zrank (key, member): Returns the name is key zset (elements have been sorted by score in ascending order) rank in the member elements (ie index, starting from 0), if no member elements, returns "nil"
  • zrevrank (key, member): Returns the name is key zset (elements have been descending order by score) rank in the member elements (ie index, starting from 0), if no member elements, returns "nil"
  • zrange (key, start, end): Returns the name is key zset (elements have been sorted by score in ascending order) index of all elements from start to end of
  • zrevrange (key, start, end): Returns the name is key zset (elements have been descending order by score) in the index of all elements from start to end of
  • zrangebyscore (key, min, max): Returns the name is key zset the score> = min and score <= max all the elements zcard (key): Returns the name zset the key base zscore (key, element): Returns the name is a key of zset elements of element score zremrangebyrank (key, min, max): delete name is key zset in rank> = min and rank <= max all the elements zremrangebyscore (key, min, max): delete name is key zset of the score> = min and score <= max all the elements
  • zunionstore / zinterstore (dstkeyN, key1, ..., keyN, WEIGHTS w1, ... wN, AGGREGATE SUM | MIN | MAX): the N zset seeking union and intersection, and the last set of saved dstkeyN in. Set a score for each element before performing AGGREGATE calculation for the parameters to be multiplied by WEIGHT. If no WEIGHT, defaults to 1. The default is AGGREGATE SUM, i.e. score results of all elements in the set is the set of elements corresponding to a value SUM operations, the MIN and MAX refers to score the results of all elements in the set is the set of elements corresponding to the minimum and maximum values.

7, the operation command Hash

  • hset (key, field, value): additive element in the field as a key to the hash of the name <-> value
  • hget (key, field): Returns the name is key corresponding to the hash value in field
  • hmget (key, field1, ..., field N): Returns the name of the field i corresponding to the hash value of the key
  • hmset (key, field1, value1, ..., field N, value N): additive element field i of the hash key in the name of the <-> value i
  • hincrby (key, field, integer): integer is the key to increase the name of the hash value in the field of
  • hexists (key, field): the domain name if there is a key field for the hash of the key
  • hdel (key, field): delete the name is key to the hash key field of domain
  • The number of the hash key and returns the name of elements: hlen (key)
  • hkeys (key): Returns the name is key hash of all keys
  • hvals (key): Returns the name of all of the keys corresponding to the hash value key
  • hgetall (key): Returns the name is key hash of all keys (field) and its corresponding value

8, endurance of

  • save: synchronize data saved to disk
  • bgsave: save data to disk asynchronously
  • Stamp return to the last successful save data to disk Unix: lastsave
  • shundown: synchronize data saved to disk, and then close Services

9, remote control service

  • info: provides server information and statistics
  • monitor: real-time dump request received
  • slaveof: Copy change policy settings
  • config: Configure Redis server at runtime

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/10942743.html