测试环境为3台centos7的主机,ip地址为192.168.73.132,192.168.73.133,192.168.73.134

Redis集群安装

1、官网下载稳定版redis源码包。

http://download.redis.io/releases/redis-4.0.2.tar.gz

2、安装依赖包

yum install gcc -y

3、安装,解压源码包之后,在解压后的目录下执行:

make MALLOC=libc

make install

cp src/redis-trib.rb /usr/local/bin/

4、安装ruby环境

yum -y install zlib openssl openssl-devel

下载ruby的源码包:

https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.gz

解压并且编译安装:

    ./configure && make && make install

cd ext/zlib/ && /usr/local/bin/ruby ./extconf.rb

make && make install

如果make的时候报错:

eRROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand

这个时候打开ext/zlib/Makefile文件,找到下面一行把路径进行修改一下。

zlib.o: $(top_srcdir)/include/ruby.h 改成:zlib.o: ../../include/ruby.h 

5、下载https://rubygems.org/downloads/redis-4.0.1.gem

/usr/local/bin/gem install -l redis-4.0.1.gem

6、创建apps用户及配置文件路径

mkdir -p  /apps/conf/redis-cluster

useradd apps

chown -R apps:apps /apps

7、切换到apps用户操作

su apps

cd /apps/conf/redis-cluster/

mkdir 7001 7002 7003 7004 7005 7006

8、拷贝源码中配置文件redis.conf到路径下,修改

示例修改如下:

bind 192.168.73.132 127.0.0.1

port 7001

daemonize yes

pidfile /apps/conf/redis-cluster/7001/redis.pid

dir /apps/conf/redis-cluster/7001/

appendonly yes

cluster-enabled yes

cluster-config-file /apps/conf/redis-cluster/7001/nodes.conf

cluster-node-timeout 5000

9、启动6个redis实例

redis-server 7001/redis.conf

redis-server 7002/redis.conf

redis-server 7003/redis.conf

redis-server 7004/redis.conf

redis-server 7005/redis.conf

redis-server 7006/redis.conf

10、创建集群

redis-trib.rb create --replicas 1 192.168.73.132:7001 192.168.73.132:7002 192.168.73.133:7003 192.168.73.133:7004 192.168.73.134:7005 192.168.73.134:7006

11、登录查看

redis-cli -c -h 192.168.73.132 -p 7001

cluster nodes

 

Zookeeper集群安装

1、准备3台主机,每台主机准备java环境

2、下载zookeeper-3.4.10安装包

3、配置zoo.cfg。将zoo_sample.cfg复制为zoo.cfg。

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/apps/svr/zookeeper-3.4.10/data/

clientPort=2181 #端口,可以修改

server.1=192.168.73.132:2888:3888

server.2=192.168.73.133:2888:3888

server.3=192.168.73.134:2888:3888

4、创建myid文件

其中,server.id中的id与/apps/svr/zookeeper-3.4.10/data/myid内容相同,不同主机的id不一致。

5、启动

bin/zkServer.sh start

 

Kafka集群安装

1、准备3台主机,每台主机准备java环境,准备zookeeper集群

2、下载二进制kafka_2.12-0.11.0.1安装包

3、修改配置文件server.properties

broker.id=132#唯一id,不能节点不能相同

listeners=PLAINTEXT://:9092 #端口,默认9092,可以修改

advertised.listeners=PLAINTEXT://192.168.73.132:9092

zookeeper.connect=192.168.73.132:2181,192.168.73.133:2181,192.168.73.134:2181

auto.leader.rebalance.enable=true #最后增加自动选举选项

4、启动

nohup ./bin/kafka-server-start.sh config/server.properties >logs/kafka.log &

 

dubbo-admin安装

1、源码构建dubbo-admin.war包,使用Jenkins,源码地址:

https://github.com/alibaba/dubbo.git

Mvn clean install -Dmaven.test.skip=true

2、下载tomcat,将构建的dubbo-admin.war包放到webapps路径下,启动

3、修改WEB-INF/dubbo.properties

dubbo.registry.address=zookeeper://192.168.73.132:2181?backup=192.168.73.133:2181,192.168.73.134:2181

Dubbo.admin.root.password,dubbo.admin.guest.password都是设置密码