需求:
1、将大量的WebService请求报文发送到mq集群之中,并保持消息先后顺序
2、保证每个消息的可靠性
3、维护MQ服务器的可扩展性
综合考虑,决定使用Apache的 activemq。接触的时候,新的activemq 5.10已经出,所以,本项目使用的是activemq5.10。activemq5.10要求jdk6+,由于项目立项比较老,所以将项目整体迁移到jdk1.7进行部署,并引入activemq服务器。OK,废话不多说,开始。
首先,选三台服务器。
之所以选三台,是因为zookeeper推荐最低三台配置,这样可以保持最大的可用服务器数,具体的这里不多说,可以查阅zookeeper的安装配置,以后有机会,详细讲解zookeeper。
我这里选择三台Linux服务器,ip地址分别为:192.168.120.241,192.168.120.242,192.168.120.171。系统均使用centos6.4
1、创建账号
useradd amqbroker; //默认会创建amqbroker的群组,并且amqbroker会自动加入amqbroker群组。
passwd amqbroker;修改密码
cd /home/amqbroker 切换目录
2、下载zookeeper
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
tar -xvf zookeeper-3.3.6.tar.gz
修改配置,mv zoo_sample.cfg zoo.cfg
vi zoo.cfg,内容如下:
1 # The number of milliseconds of each tick
2 tickTime=2000
3 # The number of ticks that the initial
4 # synchronization phase can take
5 initLimit=10
6 # The number of ticks that can pass between
7 # sending a request and getting an acknowledgement
8 syncLimit=5
9 # the directory where the snapshot is stored.
10 # do not use /tmp for storage, /tmp here is just
11 # example sakes.
12
13 dataDir=/home/amqbroker/zkdir/data
14 dataLogDir=/home/amqbroker/zkdir/log
15 # the port at which the clients will connect
16 clientPort=2181
17 # the maximum number of client connections.
18 # increase this if you need to handle more clients
19 #maxClientCnxns=60
20 #
21 # Be sure to read the maintenance section of the
22 # administrator guide before turning on autopurge.
23 #
24 # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
25 #
26 # The number of snapshots to retain in dataDir
27 #autopurge.snapRetainCount=3
28 # Purge task interval in hours
29 # Set to "0" to disable auto purge feature
30 #autopurge.purgeInterval=1
31
32
33 ##three servers of this cluster
34 server.1=192.168.120.241:2888:3888
35 server.2=192.168.120.242:2888:3888
36 server.3=192.168.120.171:2888:3888
dataDir=/home/amqbroker/zkdir/data
dataLogDir=/home/amqbroker/zkdir/log 这两行说明了,需要创建一个文件夹,分别存放data以及log,所以,在/home/amqbroker下创建文件夹zkdir,也可以创建在其他地方,只要配置中指定就好
在zkdir/data下,创建myid文件,并写入与ip地址相称的服务器编号,比如,192.168.120.241,写入 1;echo 1>myid;
其他两台机器配置相同,不过myid文件写入相应的id号
启动服务:
cd /home/amqbroker/zookeeper-3.3.6/bin
./zkServer.sh start
可以使用zookeeper自带的客户端测试:
./zkCli.sh -server 192.168.120.241:2181
其他两台一样配置
3、下载activemq-5.10
wget http://archive.apache.org/dist/activemq/5.10.1/apache-activemq-5.10.1-bin.tar.gz
tar -xvf apache-activemq-5.10.1-bin.tar.gz
vi apache-activemq-5.10.1/conf/activemq.xml
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and