Ubuntu Online Environment installation Redis
sudo apt-get install Redis-server
When the installation is complete, the Redis server starts automatically to see if the process starts properly
Ps-axu|grep redis
redis 18689 0.1 0.4-40136 ? SSL 09:12 0:01/usr/bin/redis-server 127.0.0.1:6379
root 18760 0.0 0.0 14224 932 pts/0 S+ 09:32 0:00 grep--color=auto Redis
to view the installed version of Redis
Redis-cli-h 127.0.0.1 Info | grep ' redis_version '
redis_version:3.0.6
Check Redis Server Status
Netstat-nlt|grep 6379
Sudo/etc/init.d/redis-server status
accessing Redis through command line clientsInstalling the Redis server automatically installs the Redis command-line client together. In the native input
redis-clicommand can be started and the client program accesses the Redis server.
redis.conf configuration file path
/etc/redis# ls
redis.conf redis-server.post-down.d redis-server.post-up.d redis-server.pre-down.d Redis-server.pre-up.d
In the/etc/redis directory can modify the redis.conf configuration file to achieve port configuration, password configuration, cluster configuration, etc., after the modification can be restarted through the following command:
Service Redis Restart
Other CommandsOpen Redis:service Redis Start
Stops Redis:service Redis stop
Restart Redis:service Redis Restart
To view the status of services: Service Redis Status
Brief introduction of Redis cluster environment1. Build the cluster first install Ruby program
Apt Install ruby
Using the REDIS-TRIB.RB tool can easily build a redis cluster environment. This tool location can be searched by using the following command (note that Redis installed using the method described in the preceding procedure is possible to find this tool)
Find/-name "REDIS-TRIB.RB"
If you can't find it, use the following command to install it and find it again.
Gem install Redis [default installation]
gem install redis-v 3.0.6 [Specify version installation]
Once you have found the tool, you can use the following command to build the cluster (IP and port in the command is the Redis server you have started)
./redis-trib.rb Create--replicas 1 192.168.22.43:6380 192.168.22.43:6381 192.168.22.43:6382 192.168.22.54:6390 192.168.22.54:6391 192.168.22.54:6392
The above command after the successful execution, will build three main three from the cluster environment, and have similar function of the Sentinel's failback. One of the main server or fault, will automatically make it from the server as the primary server, when the original primary server reply, automatically changed to from the server. If a group of master and slave servers are offline or fail, the cluster will stop working.
Set up a cluster must have three or more than three servers to do, or you will be the error
./redis-trib.rb Create--replicas 1 192.168.22.43:6380 192.168.22.54:6379
./redis-trib.rb:1573:warning:key " Threshold ' is duplicated and overwritten on line 1573
>>> creating cluster
* * Error:invalid Configurati On for cluster creation.
Redis Cluster requires at least 3 master nodes.
This isn't possible with 2 nodes and 1 replicas per node.
At least 6 nodes are required.
The cluster that constructs the different IP environment must configure the bind in the configuration file of each server to 0.0.0.0 (also can put all your cluster server IP to write in), otherwise the execution redis-trib.rb will prompt cannot find the server
The client command for the cluster environment is best brought with-C for automatic redirection, otherwise you will encounter (error) moved 12182 in set or get
Redis-cli-c-P 6392