Server cluster Role:
A server cluster means that many servers are clustered together for the same service, and it appears to the client that only one server cluster can use multiple computers for parallel computing to achieve high computational speed, or it can be backed up with multiple computers, so that any one machine can break the whole system or run normally. Once the Cluster service is installed and running on the server, the server can join the cluster. Clustering operations can reduce the number of single points of failure and enable high availability of clustered resources.
Cluster configuration for Redis:
(. Edit Network File
Hostname=redis (self-defined HOSTNAME)
Vi/etc/sysconfig/network
. Edit the Hosts file
Need to add IP and host name mappings at the end of the Hosts file
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
The IP address of this virtual machine is defined by its own hostname
192.168.1.162 Redis
Vi/etc/hosts
. Turn off firewall on boot
Service Iptables Stop
Chkconfig iptables off
)
1. Put the redis-3.2.10.tar.gz in Linux
2. Unzip the package (TAR-ZXVF xxxxx) to the current directory
3. Enter the redis-3.2.10 directory (CD xxxxx)
4. Make && make install and build Redis
5. Create the Redis_cluster folder in the redis-3.2.10 directory (mkdir redis_cluster)
6. Create the corresponding port number folder (6380,6381,6382,6383,6384,6385) under the Redis_cluster folder
7. Create a redis.conf file (Touch redis.conf) in these 6 folders respectively
8. Edit the file
!! Note: You must modify the IP and the corresponding port number
daemonize Yes
pidfile redis_6380.pid
logfile Redis_6380.log
appendonly Yes
bind 192.168.242.10
Port 6380
cluster-enabled Yes
cluster-config-file nodes-6380.conf
Cluster-node-timeout 15000
Cluster-slave-validity-factor Ten
Cluster-migration-barrier 1
Cluster-require-full-coverage Yes
9. Start the cluster
Enter the SRC directory of the redis-3.2.10
./redis-server. /redis_cluster/6380/redis.conf
./redis-server. /redis_cluster/6381/redis.conf
./redis-server. /redis_cluster/6382/redis.conf
./redis-server. /redis_cluster/6383/redis.conf
./redis-server. /redis_cluster/6384/redis.conf
./redis-server. /redis_cluster/6385/redis.conf
10. Check redis cluster boot status
ps-ef |grep Redis
11. If the cluster starts normally
Create a Redis (db) cluster
You must also first enter the SRC directory of the redis-3.2.10
./REDIS-TRIB.RB Create--replicas 1 IP Address: Port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number
./REDIS-TRIB.RB Create--replicas 1 192.168.1.186:6380 192.168.1.186:6381 192.168.1.186:6382 192.168.1.186:6383 192.168.1.186:6384 192.168.1.186:6385
If error:/usr/bin/env:ruby:no such file or directory
Description Ruby is not installed
12. Install Ruby
Yum Install Ruby
13. Run again./REDIS-TRIB.RB Create--replicas 1 IP Address: port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number
if error: No such file to load--RubyGems (Loaderror)
14. Installing RubyGems
Yum Install RubyGems
15. Implement gem install Redis to connect gems and Redis
16. If error: Redis required ruby version >= 2.2.2
17. Upgrading Ruby's version information
Ruby upgrade requires two dependent curl and RVM
18.1 Installing CULR
Yum Install Curl
18.2 RVM
curl-l Get.rvm.io | bash-s stable
I need to wait a long, long, long, long time.
If the following error occurs:
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the Mpapis public key (downloading the signatures).
GPG Signature verification failed for '/usr/local/rvm/archives/rvm-1.29.3.tgz '-' https://github.com/rvm/rvm/release S/DOWNLOAD/1.29.3/1.29.3.TAR.GZ.ASC '! Try to install GPG v2 and then fetch the public key:
GPG2--recv-keys 409b6b1796c275462a1703113804bb82d39dc0e3
Or if it fails:
Command Curl-ssl HTTPS://RVM.IO/MPAPIS.ASC | GPG2--import-
The key can compared with:
Https://rvm.io/mpapis.asc
Https://keybase.io/mpapis
NOTE:GPG version 2.1.17 has a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade-newer version (if available) or use the second method described above.
18.3 Resolve the above error
using Curl-ssl https://rvm.io/mpapis.asc | gpg2--import-Mr. Cheng Key
GPG: Key Ring '/ROOT/.GNUPG/SECRING.GPG ' has been established
GPG:/ROOT/.GNUPG/TRUSTDB.GPG: Establishing a database of trust
GPG: Key d39dc0e3: Public Key "Michal Papis (RVM signing) <[email protected]>" Imported
GPG: Total processed quantity: 1
GPG: Imported: 1 (rsa:1)
GPG: No absolute trust key found
18.4 Run curl-l Get.rvm.io | bash-s stable
The endless Waiting
19. Using the SOURCE/USR/LOCAL/RVM/SCRIPTS/RVM command
make RVM effective immediately
RVM list Known view currently available Ruby versions
21. Select one of the available Ruby versions to install, but the version you want to install must be larger than 2.2.2
RVM Install x.x.x
RVM use x.x.x immediately using the newly installed Ruby version
24. Running gem install Redis
25. Access to the Redis database
first, go to redis-3.2.10 's src directory.
./redis-cli-h xxx.xxx.xxx.xxx-c-P 6380
when the additions and deletions, error, unable to find other cluster information, the Redis cluster does not create a database, resulting in the cluster can not find storage space
Exit command exits the cluster
26. Create a Redis database
./REDIS-TRIB.RB Create--replicas 1 IP Address: Port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number IP Address: port number
./REDIS-TRIB.RB Create--replicas 1 192.168.1.186:6380 192.168.1.186:6381 192.168.1.186:6382 192.168.1.186:6383 192.168.1.186:6384 192.168.1.186:6385
27. Enter the cluster again
First, go to redis-2.3.10 's src directory.
Run./redis-cli-h xxx.xxx.xxx.xxx-c-P 6380
Re-test and delete check
Java:redis (Redis cluster configuration)