架构方案
web1:192.168.1.211
web1:192.168.1.212
web1:192.168.1.214
部署软件:
java tomcat redis主从集群 zookeeper集群 elastcserch集群
####三台服务器Jdk安装部署
rpm �Civh jdk-7u67-linux-x64.rpm
vi /root/.bash_profile
添加内容
JAVA_HOME=/usr/java/jdk1.7.0_67
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
#使变量文件生效
source /root/.bash_profile
测试:java �Cversion
###########redis主从部署
yum -y install gcc vim
tar xf redis-3.0.3.tar.gz
mv redis-3.0.3 /storage/local/redis-3.0.3
cd /storage/local/redis-3.0.3
make MALLOC=libc && make install
redis配置:
redis目录:/storage/local/redis-3.0.3
主的redis配置文件,使用默认的配置文件就可以了,如果你需要设计其他参数
从的redis配置文件,添加
#从的redis配置文件,需要添加vim /storage/local/redis-3.0.3/redis.conf daemonize yes slaveof 192.168.1.211 6379
启动主从redis
redis-server /storage/local/redis-3.0.3/redis.conf
查看主redis信息
#查看主redis的信息redis-cli -h 192.168.1.211 info Replication# Replicationrole:master #代表192.168.1.211:6379 这台redis是主connected_slaves:1slave0:192.168.9.18,6379,online
查看从redis信息
#查看主redis的信息redis-cli -h 192.168.1.212 info Replication# Replicationrole:slave #代表192.168.1.211:6379 这台redis是主master_host:192.168.1.212master_port:6379master_link_status:up master_last_io_seconds_ago:4master_sync_in_progress:0slave_priority:100slave_read_only:1connected_slaves:0
配置redis sentinel集群监控服务
1.添加一份redis sentinel 配置文件
vim /storage/local/redis-3.0.3/sentinel.conf##redis-0##sentinel实例之间的通讯端口port 26379#master1 port 26379 sentinel monitor mymaster 192.168.1.211 6379 2 sentinel down-after-milliseconds mymaster 5000 sentinel failover-timeout mymaster 900000 sentinel parallel-syncs mymaster 2
2.有配置文件了,那么启动redis sentinel做redis集群监听
redis-sentinel /storage/local/redis-3.0.3/sentinel.conf
监控状态查询
#################ZooKeeper部署
第一步:主机名称到IP地址映射配置
ZooKeeper集群中具有两个关键的角色:Leader和Follower。集群中所有的结点作为一个整体对分布式应用提供服务,集群中每个结点之间都互相连接,所以,在配置的ZooKeeper集群的时候,每一个结点的host到IP地址的映射都要配置上集群中其它结点的映射信息。
例如,我的ZooKeeper集群中每个结点的配置,以slave-01为例,/etc/hosts内容如下所示:
vim /etc/hosts
192.168.1.211 slave-01
192.168.1.212 slave-02
192.168.1.214 slave-03
第二步:修改ZooKeeper配置文件
在其中一台机器(slave-01)上,解压缩
tar xf zookeeper-3.3.4.tar.gz,mv zookeeper-3.3.4 zookeeper-3.3.4-node1
修改配置文件
cp zookeeper-3.3.4-node1/conf/zoo_sample.cfg /zoo.cfg
vim zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper
clientPort=2181
server.1=slave-01:2888:3888
server.2=slave-02:2888:3888
server.3=slave-03:2888:3888
第三步:远程复制分发安装文件
上面已经在一台机器slave-01上配置完成ZooKeeper,现在可以将该配置好的安装文件远程拷贝到集群中的各个结点对应的目录下:
scp -r zookeeper-3.3.4-node1/[email protected]:/storage/local/zookeeper-3.3.4-node2
scp -r zookeeper-3.3.4-node1/[email protected]:/storage/local/zookeeper-3.3.4-node3
第四步:设置myid
在我们配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机,conf/zoo.cfg文件中配置的server.X中X为什么数字,则myid文件中就输入这个数字
mkdir /tmp/zookeeper
web1设置: echo "1" > /tmp/zookeeper/myid
web2设置: echo "2" > /tmp/zookeeper/myid
web3设置: echo "3" > /tmp/zookeeper/myid
启动
sh /home/storage/local/zookeeper-node1/bin//zkServer.sh start
查看状态
sh /home/storage/local/zookeeper-node1/bin//zkServer.sh status
JMX enabled by default
Using config: /home/hadoop/installation/zookeeper-3.3.4/bin/../conf/zoo.cfg
Mode: leader 或follower(正常)
######################elasticsearch集群部署
tar xf elasticsearch-1.7.1.tar.gz
mkdir -pv /storage/local/elasticsearch-cluster
vim /storage/local/elasticsearch-node1/conf/elasticsearch.yml
cluster.name: elasticsearch-cluster-CentOS
node.name: "es-node1"
node.master: true
node.data: true
marvel.agent.enabled: false
transport.tcp.port: 9300
http.port: 9200
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.1.212:9300", "192.168.1.214:9300"]
3.安装head插件
#进入到节点bin路径
cd /storage/local/elasticsearch-cluster/elasticsearch-node1/bin
安装插件
[root@localhost bin]# ./plugin -install mobz/elasticsearch-head
安装完插件之后会在es节点bin路径同级创建一个plugins目录,存放安装的插件
4.复制一份配置好的节点为elasticsearch-node2
scp -r /home/storage/local/zookeeper-node1/ [email protected]:/home/storage/local/zookeeper-node1/elasticsearch-node2
scp -r /home/storage/local/zookeeper-node1/ [email protected]:/home/storage/local/zookeeper-node1/elasticsearch-node3
所有服务器启动服务:
sh /home/storage/local/elasticsearch-node1/bin/elasticsearch -d -Xms512m -Xmx512m
状态如图
本文出自 “我的天空” 博客,谢绝转载!