redis 4.0.8 源码包安装集群

系统:centos 6.9
软件版本:redis-4.0.8,rubygems-2.7.7,gcc version 4.4.7 20120313,openssl-1.1.0h,zlib-1.2.11

yum install c++ gcc

1、安装redis
tar -xf redis-4.0.8.tar.gz
cd redis-4.0.8
make
make install PREFIX=/redis-cluster

2、安装ruby和rubygems及相关组件(zlib和openssl)

安装ruby
wget https://rubygems.org/rubygems/rubygems-2.7.7.zip
unzip rubygems-2.7.7.zip
cd rubygems-2.7.7
./configure --prefix=/usr/local/ruby
make
make install

安装zlib
wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make
make install

安装openssl(1.1是当前稳定版本)
wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar -xf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h
./config --prefix=/usr/local/openssl #这里用的是config
# ./config -fPIC --prefix=/usr/local/openssl enable-shared
./config -t
make
make install

进入到ruby目录下安装zlib和openssl
cd /soft/ruby-2.4.4/ext/zlib #切换到ruby源码包中
ruby extconf.rb --with-zlib-include=/usr/local/zlib/include/ --with-zlib-lib=/usr/local/zlib/lib
# 会生成一个Makefile文件
# /usr/local/zlib是zlib安装目录
# 必须要指定zlib的路径
make
#出错提示 make: *** No rule to make target `/include/ruby.h‘, needed by `zlib.o‘. Stop
#修改Makefile,把这行记录 zlib.o: $(top_srcdir)/include/ruby.h 改成:zlib.o: ../../include/ruby.h
make && make install

cd /soft/ruby-2.4.4/ext/openssl
ruby extconf.rb --with-openssl-include=/usr/local/openssl/include/ --with-openssl-lib=/usr/local/openssl/lib
make
#错误提示 make: *** No rule to make target `/include/ruby.h‘, needed by `ossl.o‘. Stop
#打开Makefile文件,将$(top_srcdir)全部改成../..
make && make install

然后回到/soft/rubygems-2.7.7/目录下
[[email protected] rubygems-2.7.7]# ruby setup.rb
Bundler 1.16.2 installed
RubyGems 2.7.7 installed
Regenerating binstubs
Parsing documentation for rubygems-2.7.7
Installing ri documentation for rubygems-2.7.7

#安装
或者下载
gem install redis-3.3.0.gem

3、创建redis-cluster 目录
mkdir -p /redis-cluster/{redis7001,redis7006}
mkdir -p /redis-cluster/{redis7002,redis7005}
mkdir -p /redis-cluster/{redis7003,redis7004}

4、复制redis程序(可选)
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7001/
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7002/
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7003/
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7004/
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7005/
cp -rf /usr/local/redis3.0/* /redis-cluster/redis7006/
# 可以独立执行redis-server,也可以公用一个redis-server bin程序文件

5、创建redis.conf脚本
在每个redis700X目录下创建redis.conf
port 7001
daemonize yes
pidfile "/redis-cluster/redis7001/redis7001.pid"
logfile "/redis-cluster/redis7001/redis7001.log"
dir "/redis-cluster/redis7001/data"
cluster-enabled yes
cluster-config-file "/redis-cluster/redis7001/7001.conf"
cluster-node-timeout 5000
appendonly yes
#bind 192.168.2.22 如果需要多台主机通信,加入这条
# cluster-config-file是集群的信息文件名,默认与redis7001.conf在同一目录,不需要指定路径
# appendonly 表示开启redis AOF方式的数据持久化

6、运行redis测试
使用脚本批量启动
cd /redis-cluster
vim startall.sh
#!/bin/bash
cd /redis-cluster
redis-server redis7001/redis.conf
redis-server redis7002/redis.conf
redis-server redis7003/redis.conf
redis-server redis7004/redis.conf
redis-server redis7005/redis.conf
redis-server redis7006/redis.conf

chmod +x startall.sh #增加执行权限
./startall.sh #打开测试
ss -tnl #查看端口
killall redis-server #测试完毕结束所有redis-server进程

7、执行redis-trib.rb启动集群
从源码包里src目录中复制redis-trib.rb到/redis-cluster下,按提示输入yes

[[email protected] redis-cluster]# ./redis-trib.rb create --replicas 1 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 127.0.0.1:7006
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:7001
127.0.0.1:7002
127.0.0.1:7003
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
Adding replica 127.0.0.1:7006 to 127.0.0.1:7003
M: 63979c7c252db530f828a0b013796eb362107601 127.0.0.1:7001
slots:0-5460 (5461 slots) master
M: 7b6e483a2060237ab770b192f3cad02448e063be 127.0.0.1:7002
slots:5461-10922 (5462 slots) master
M: 5f519d56955a80d89e4ab773c4e13a1abdfe0872 127.0.0.1:7003
slots:10923-16383 (5461 slots) master
S: 0198263589b8d89f0179886cfc898294e0cab64f 127.0.0.1:7004
replicates 63979c7c252db530f828a0b013796eb362107601
S: d0db3c39a1ce7ef9148b9b5ca43394735a5d532d 127.0.0.1:7005
replicates 7b6e483a2060237ab770b192f3cad02448e063be
S: 02b3906a4cac9d566c14f58f8818384062242f2c 127.0.0.1:7006
replicates 5f519d56955a80d89e4ab773c4e13a1abdfe0872
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:7001)
M: 63979c7c252db530f828a0b013796eb362107601 127.0.0.1:7001
slots:0-5460 (5461 slots) master
M: 7b6e483a2060237ab770b192f3cad02448e063be 127.0.0.1:7002
slots:5461-10922 (5462 slots) master
M: 5f519d56955a80d89e4ab773c4e13a1abdfe0872 127.0.0.1:7003
slots:10923-16383 (5461 slots) master
M: 0198263589b8d89f0179886cfc898294e0cab64f 127.0.0.1:7004
slots: (0 slots) master
replicates 63979c7c252db530f828a0b013796eb362107601
M: d0db3c39a1ce7ef9148b9b5ca43394735a5d532d 127.0.0.1:7005
slots: (0 slots) master
replicates 7b6e483a2060237ab770b192f3cad02448e063be
M: 02b3906a4cac9d566c14f58f8818384062242f2c 127.0.0.1:7006
slots: (0 slots) master
replicates 5f519d56955a80d89e4ab773c4e13a1abdfe0872
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

8、查看端口
[[email protected] redis-cluster]# netstat -tunl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:17001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17002 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17003 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17004 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17005 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:17006 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7001 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7002 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7003 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7004 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7005 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:7006 0.0.0.0:* LISTEN

9、登陆到集群测试

[[email protected] redis-cluster]# redis-cli -h 127.0.0.1 -c -p 7001 #本地可以不加-h
127.0.0.1:7001> keys *
(empty list or set)
127.0.0.1:7001> set name wajika
-> Redirected to slot [5798] located at 127.0.0.1:7002
OK
127.0.0.1:7002> set name ceshi
OK
127.0.0.1:7002> set wajika name
OK
127.0.0.1:7002> set wwwwwwwwwwaaa wajika
-> Redirected to slot [2810] located at 127.0.0.1:7001
OK
127.0.0.1:7001> cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_sent:3976
cluster_stats_messages_received:3976
127.0.0.1:7001>

#集群部署成功

#关闭集群的方法
[[email protected] redis7001]# redis-cli -c -h 127.0.0.1 -p 7001 shutdown
#关闭集群7001节点,如果没有-h参数,默认连接127.0.0.1,如果没有-p参数,默认连接6370端口
#(所有如果用默认的,就没有-h -p)

原文地址:https://www.cnblogs.com/wajika/p/9193064.html

时间: 2024-11-05 18:45:23

redis 4.0.8 源码包安装集群的相关文章

源码包安装(Python mysql redis)

一  源码包安装 (1)python3.6源码包安装 ./configure ------> 定制功能 make make install mysql 源码包 cmake make make install (2) redis 源码包安装 make 修改环境变量 vim /etc/profile 添加以下一行: export PATH=/opt/redis-3.2.10/src:$PATH 生效配置 source /etc/profile (3) 让python链接redis unzip red

gitlab升级迁移---源码包安装转rpm包(三)

距离上次gitlab升级快过去一年了,期间gitlab已更新了好多新版本,都没有进行升级.理由很简单,因为升级很麻烦,秉着能用就先用着的想法.但是最近gitlab接连发出之前旧版本有安全漏洞,看到的公告是:<GitLab 叕发布安全补丁 12.0.3, 11.11.5 和 11.10.8,请即刻升级>,都出现“叕”字了,说明不得不升级了,毕竟代码是公司的核心资产. 那么说干就干,首先去gitlab官网查看升级文档,看需要升级哪些东西.我这gitlab之前是用源码包安装的,版本是10.8.7,需

烂泥:mysql5.0数据库源码编译安装

本文首发于烂泥行天下. 本次实验的mysql.OS相关信息如下: Mysql:5.0.96 OS:centos 32 bit 最近公司要上新的业务,指明数据库使用的是mysql5.0版本.如果是使用rpm包安装的话,那就很简单了.直接使用yum安装即可,命令如下: yum –y install mysql mysql-server Yum方式安装完毕后,直接启动mysql数据库服务即可.如下图: 这样基本上就可以了. 但是这样安装mysql数据库,没有进行定制.比如mysql数据库的数据文件存储

Ubuntu软件安装指南:dpkg、apt 与源码包安装

基础知识: 通常情况下,linux会这样放软件的组件(一般规范): 程序的文档->/usr/share/doc; /usr/local/share/doc 程序->/usr/share; /usr/local/share 程序的启动项->/usr/share/apps; /usr/local/share 程序的语言包->/usr/share/locale; /usr/local/share/locale 可执行文件->/usr/bin; /usr/local/bin 而有的软

zabbix源码包安装

Zabbix源码包安装 Cenos5.3 Basic server 安装顺序 Libxml2 Libmcrypt Zlib Libpng Jpeg:需要创建目录jpeg  /bin  /lib   /include   /man/man1 ./configure --prefix=/usr/local/jpeg8/ --enable-shared Freetype字体库 Libxpm安装.libXpm-devel安装 Autoconf  直接./configure装到系统里 Libgd:   [

18、Linux源码包安装详解

安装源码包 安装一个源码包,是需要我们自己把源代码编译成二进制的可执行文件.如果你读得懂这些源代码,那么你就可以去修改这些源代码自定义功能,然后再去编译成你想要的.使用源码包的好处除了可以自定义修改源代码外还可以定制相关的功能,因为源码包在编译的时候是可以附加额外的选项的. 源码包的编译用到了linux系统里的编译器,常见的源码包一般都是用C语言开发的,这也是因为C语言为linux上最标准的程序语言.Linux上的C语言编译器叫做gcc,利用它就可以把C语言变成可执行的二进制文件.所以如果你的机

cenos6.5源码包安装lnmp环境

虽然centos6可以用yum安装nginx,但是我还是写个教程用源码包安装用于线上环境. 一:在nginx官网下载nginx,并安装 我下载的是nginx-1.6.0 #./configure --prefix=/usr/local/nginx make&& make install 卸载已存在的apache服务和php [[email protected] Desktop]# yum remove httpd php* 安装development Tools [[email prote

linux CentOS7 中安装包管理:rpm 、yum及源码包安装使用

一. 安装软件包的三种方法 yum ---python rpm工具 yum工具 源码包 二. rpm包介绍 设置光驱并挂载: [[email protected] ~]# mount /dev/cdrom /mntmount: /dev/sr0 写保护,将以只读方式挂载 [[email protected] ~]# ls /mntEULA    isolinux  repodata                      TRANS.TBL GPL     LiveOS    RPM-GPG-

7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装

7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装 扩展 1. 配置yum源优先级 http://ask.apelearn.com/question/7168 2. 把源码包打包成rpm包 http://www.linuxidc.com/Linux/2012-09/70096.htm # 7.6  yum更换国内源 ![mark](http://oqxf7c508.bkt.clouddn.com/blog/20170812/154757717.png?imagesl