centos安裝redis3.0.0叢集
這裡建立6個redis節點,其中三個為主節點,三個為從節點。
redis和埠對應關係:
127.0.0.1:7000127.0.0.1:7001
127.0.0.1:7002
從:
127.0.0.1:7003127.0.0.1:7004
127.0.0.1:7005
步驟:
1,下載redis。官網下載3.0.0版本,之前幾的版本不支援叢集模式
下載地址:http://download.redis.io/releases/redis-3.0.0.tar.gz
2:上傳伺服器,解壓,編譯tar -zxvf redis-3.0.0-rc2.tar.gz
mv redis-3.0.0-rc2.tar.gz redis3.0
cd /usr/local/redis3.0
make & make install
3:建立叢集需要的目錄並拷貝redis
mkdir -p /usr/local/cluster
mkdir -p /usr/local/cluster/7000
mkdir -p /usr/local/cluster/7001
mkdir -p /usr/local/cluster/7002
mkdir -p /usr/local/cluster/7003
mkdir -p /usr/local/cluster/7004
mkdir -p /usr/local/cluster/7005
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7000/
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7001/
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7002/
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7003/
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7004/
cp -rf /usr/local/redis3.0/* /usr/local/cluster/7005/
4:修改配置檔案redis.conf
vi /usr/local/cluster/7000/redis.conf
##修改配置檔案中的下面選項
port 7000
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
#同樣再對其它配置檔案進行修改
vi /usr/local/cluster/7001/redis.conf
vi /usr/local/cluster/7002/redis.conf
vi /usr/local/cluster/7003/redis.conf
vi /usr/local/cluster/7004/redis.conf
vi /usr/local/cluster/7005/redis.conf
##注意:不同的目錄配置不同的redis.conf中的port
5:啟動6個redis
cd /usr/local/cluster/7000/src
redis-server ../redis.conf
cd /usr/local/cluster/7001/src
redis-server ../redis.conf
cd /usr/local/cluster/7002/src
redis-server ../redis.conf
cd /usr/local/cluster/7003/src
redis-server ../redis.conf
cd /usr/local/cluster/7004/src
redis-server ../redis.conf
cd /usr/local/cluster/7005/src
redis-server ../redis.conf
##啟動之後使用命令檢視redis的啟動情況ps -ef|grep redis
6,建立redis叢集
cd /usr/local/redis3.0/src
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
6.1執行上面的命令的時候會報錯,因為是執行的的指令碼,需要
錯誤內容:/usr/bin/env: ruby: No such file or directory
所以需要安裝ruby的環境,這裡推薦使用yum install ruby
yum install ruby
6.2然後再執行第步的建立叢集命令,還會報錯,提示缺少rubygems元件
錯誤內容:
./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from ./redis-trib.rb:24
yum install rubygems
6.3再次執行第步的命令,還會報錯,提示不能載入redis,是因為缺少redis的介面
錯誤內容:
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./redis-trib.rb:25
gem install redis
這裡可能無法安裝,因為無法連線gem伺服器:
[@zw_22_90 src]# gem install redis --version 3.0.0
ERROR: Could not find a valid gem 'redis' (= 3.0.0) in any repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
需要手工下載並安裝:
wget https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
gem install -l ./redis-3.2.1.gem
6.4 再次執行第步的命令,正常執行
輸入yes,然後配置完成。
[@zw_22_90 src]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
>>> Creating cluster
Connecting to node 127.0.0.1:7000: OK
Connecting to node 127.0.0.1:7001: OK
Connecting to node 127.0.0.1:7002: OK
Connecting to node 127.0.0.1:7003: OK
Connecting to node 127.0.0.1:7004: OK
Connecting to node 127.0.0.1:7005: OK
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7000
127.0.0.1:7001
127.0.0.1:7002
Adding replica 127.0.0.1:7003 to 127.0.0.1:7000
Adding replica 127.0.0.1:7004 to 127.0.0.1:7001
Adding replica 127.0.0.1:7005 to 127.0.0.1:7002
M: 2022f24d581b4a7c3342e3245c32927cbd5ec16d 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 37b7008f80f8c21a698da8cb1f1b32db8c0c415c 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: ac6dc5fa96e856b34c1ba4c3814394e4ebb698dd 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
S: b5b76d70bbb0dbf3e7df8a38f1259e95e2054721 127.0.0.1:7003
replicates 2022f24d581b4a7c3342e3245c32927cbd5ec16d
S: 6881f8fef9c25da486f320ebf2ead39c1502db4c 127.0.0.1:7004
replicates 37b7008f80f8c21a698da8cb1f1b32db8c0c415c
S: f090526d32cced97731eef2a2e1722a7bac7d9ea 127.0.0.1:7005
replicates ac6dc5fa96e856b34c1ba4c3814394e4ebb698dd
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join...
>>> Performing Cluster Check (using node 127.0.0.1:7000)
M: 2022f24d581b4a7c3342e3245c32927cbd5ec16d 127.0.0.1:7000
slots:0-5460 (5461 slots) master
M: 37b7008f80f8c21a698da8cb1f1b32db8c0c415c 127.0.0.1:7001
slots:5461-10922 (5462 slots) master
M: ac6dc5fa96e856b34c1ba4c3814394e4ebb698dd 127.0.0.1:7002
slots:10923-16383 (5461 slots) master
M: b5b76d70bbb0dbf3e7df8a38f1259e95e2054721 127.0.0.1:7003
slots: (0 slots) master
replicates 2022f24d581b4a7c3342e3245c32927cbd5ec16d
M: 6881f8fef9c25da486f320ebf2ead39c1502db4c 127.0.0.1:7004
slots: (0 slots) master
replicates 37b7008f80f8c21a698da8cb1f1b32db8c0c415c
M: f090526d32cced97731eef2a2e1722a7bac7d9ea 127.0.0.1:7005
slots: (0 slots) master
replicates ac6dc5fa96e856b34c1ba4c3814394e4ebb698dd
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
至此redis叢集即搭建成功!
7,redis-cli命令進入叢集環境
[@zw_22_90 src]# redis-cli -c -p 7000
127.0.0.1:7000> quit;
相關文章
- CentOS7 安裝PG叢集CentOS
- centos安裝k8s叢集CentOSK8S
- CentOS 7.4 下安裝 ES 6.5.1 搜尋叢集CentOS
- Centos7手工安裝Kubernetes叢集CentOS
- 安裝Consul叢集
- 安裝Kafka叢集Kafka
- Linux-Centos6.8安裝redis-4.0.10 官方叢集版LinuxCentOSRedis
- Centos7安裝Nacos單機模式以及叢集模式(包含nignx安裝以及實現叢集)的相關配置CentOS模式
- centos7 安裝k8s1.30.1高可用叢集(非獨立etcd叢集)CentOSK8S
- 快速安裝 kafka 叢集Kafka
- 完整安裝always on叢集
- 安裝Zookeeper和Kafka叢集Kafka
- redis-3.0.6 安裝叢集Redis
- redis 5.0 叢集的安裝Redis
- Zookeeper3.4.14(單叢集)、Kafka_2.12-2.2.2(叢集)安裝Kafka
- Cloudera Manager安裝 & 搭建CDH叢集Cloud
- 安裝Greenplum 5.2 叢集實戰
- ARM架構安裝Kubernetes叢集架構
- Ubuntu上kubeadm安裝Kubernetes叢集Ubuntu
- Redis安裝+叢集+效能監控Redis
- CDH安裝大資料叢集大資料
- centos 6.9搭建pxc叢集CentOS
- Ubuntu 安裝k8s叢集UbuntuK8S
- 在Ubuntu 18.04.1上安裝Hadoop叢集UbuntuHadoop
- Zookeeper-3.4.10 叢集的安裝配置
- Cassandra安裝及分散式叢集搭建分散式
- CentOS 7.4 安裝 K8S v1.11.0 叢集所遇到的問題CentOSK8S
- Redis安裝之叢集-哨兵模式(sentinel)模式Redis模式
- 安裝配置 zookeeper (單機非叢集模式)模式
- 分散式 PostgreSQL 叢集(Citus)官方安裝指南分散式SQL
- Linux原始碼安裝RabbitMQ高可用叢集Linux原始碼MQ
- docker-compose安裝rocketmq雙主叢集DockerMQ
- Kubernetes安裝之三:etcd叢集的配置
- kubernetes叢集的安裝異常彙總
- CentOS7 搭建 Redis 叢集CentOSRedis
- centos7搭建redis叢集CentOSRedis
- CentOS部署ElasticSearch7.6.1叢集CentOSElasticsearch
- centos7搭建dolphinscheduler叢集CentOS
- 大資料叢集搭建 – 2. CDH叢集安裝 – NTP,MYSQL,nginx安裝大資料MySqlNginx