Skip to content

Commit b673926

Browse files
author
Ali Ahmed
committed
Add Rabbit MQ config
1 parent 3dd4d00 commit b673926

File tree

9 files changed

+392
-0
lines changed

9 files changed

+392
-0
lines changed

driver-rabbitmq/deploy/ansible.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[defaults]
2+
host_key_checking=false
3+
private_key_file=~/.ssh/id_rsa
4+
5+
[privilege_escalation]
6+
become=true
7+
become_method='sudo'
8+
become_user='root'

driver-rabbitmq/deploy/deploy.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
- name: Install RabbitMQ Cluster
21+
hosts: rabbitmq
22+
connection: ssh
23+
tasks:
24+
- name: Install RPM packages
25+
yum: pkg={{ item }} state=latest
26+
with_items:
27+
- wget
28+
- java
29+
- sysstat
30+
- vim
31+
- name: Download erlang rpm
32+
get_url:
33+
url: https://packages.erlang-solutions.com/erlang-solutions-1.0-1.noarch.rpm
34+
dest: /tmp/erlang-solutions-1.0-1.noarch.rpm
35+
- name: Install Erlang
36+
yum:
37+
name: /tmp/erlang-solutions-1.0-1.noarch.rpm
38+
state: present
39+
- name: Install Rabbitmq Server
40+
yum:
41+
name: http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.14/rabbitmq-server-3.6.14-1.el6.noarch.rpm
42+
state: present
43+
44+
- name: change master hostname to rabbitmaster
45+
hostname:
46+
name: "rabbitmaster"
47+
when: rabbitmq_master is defined
48+
49+
- name: change slave1 hostname to rabbitslave1
50+
hostname:
51+
name: "rabbitslave1"
52+
when: rabbitslave1 is defined
53+
54+
- name: change slave2 hostname to rabbitslave2
55+
hostname:
56+
name: "rabbitslave2"
57+
when: rabbitslave2 is defined
58+
59+
- name: add entries to /etc/hosts
60+
lineinfile:
61+
dest: /etc/hosts
62+
line: "{{ item.line }}"
63+
state: present
64+
with_items:
65+
- { line: "{{ groups['rabbitmq'][0] }} rabbitmaster" }
66+
- { line: "{{ groups['rabbitmq'][1] }} rabbitslave1" }
67+
- { line: "{{ groups['rabbitmq'][2] }} rabbitslave2" }
68+
69+
# - name: stop rabbitmq
70+
# shell: rabbitmqctl stop_app
71+
# - name: kill rabbitmq
72+
# shell: rabbitmqctl stop ; ps aux | grep rabbitmq | grep -v grep | awk '{print $2}'| xargs kill -9
73+
# - name: reset rabbitmq
74+
# shell: rabbitmqctl reset
75+
76+
- name: start rabbitmq server
77+
service: name=rabbitmq-server state=started
78+
- name: install web management
79+
shell: rabbitmq-plugins enable rabbitmq_management
80+
- name: restart rabbitmq server
81+
service: name=rabbitmq-server state=restarted
82+
# - name: create admin/admin profile
83+
# shell: rabbitmqctl add_user admin admin
84+
# - name: set admin tag
85+
# shell: rabbitmqctl set_user_tags admin administrator
86+
# - name: set admin permission
87+
# shell: rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
88+
- name: clear servers erlang cookie
89+
shell: rm -f /var/lib/rabbitmq/.erlang.cookie
90+
- name: copy erlang.cookie
91+
copy: src=erlang.cookie dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400
92+
- name: kill rabbitmq
93+
shell: rabbitmqctl stop ; ps aux | grep rabbitmq | grep -v grep | awk '{print $2}'| xargs kill -9 ; rabbitmq-server -detached
94+
- name: start rabbitmq
95+
service: name=rabbitmq-server enabled=yes state=restarted
96+
- name: rabbitmq status
97+
shell: rabbitmqctl cluster_status
98+
register: result
99+
- debug: msg='{{result.stdout}}'
100+
- name: rabbit cluster stop slaves
101+
shell: rabbitmqctl stop_app
102+
when: rabbitmq_slave is defined
103+
- name: rabbit cluster slaves join master
104+
shell: rabbitmqctl join_cluster rabbit@rabbitmaster
105+
when: rabbitmq_slave is defined
106+
- name: rabbit cluster slaves start slaves
107+
shell: rabbitmqctl start_app
108+
when: rabbitmq_slave is defined
109+
- name: show rabbitmq cluster status
110+
shell: rabbitmqctl cluster_status
111+
- name: create ha pllicy
112+
shell: rabbitmqctl set_policy ha-all "^" '{"ha-mode":"exactly","ha-params":2,"ha-sync-mode":"automatic"}'
113+
when: rabbitmq_master is defined
114+
# - name: add queue taxCodeInvoiceQueue
115+
# rabbitmq_queue: name=cmcc_zzs_taxCodeInvoiceQueue
116+
# when: rabbitmq_master is defined
117+
# - name: add queue cmcc_zzs_generatorInvoiceQueue
118+
# rabbitmq_queue: name=cmcc_zzs_generatorInvoiceQueue
119+
# when: rabbitmq_master is defined
120+
# - name: add queue cmcc_zzs_pushInvoiceQueue
121+
# rabbitmq_queue: name=cmcc_zzs_pushInvoiceQueue
122+
# when: rabbitmq_master is defined
123+
# - name: add queue cmcc_zzs_sentToPlatformServerQueue
124+
# rabbitmq_queue: cmcc_zzs_sentToPlatformServerQueue
125+
# when: rabbitmq_master is defined
126+
- name: show queue list
127+
shell: rabbitmqctl list_queues
128+
register: result_queue
129+
- debug: msg='{{result_queue.stdout}}'

driver-rabbitmq/deploy/erlang.cookie

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LSKNKBELKPSTDBBCHETL

driver-rabbitmq/deploy/hosts.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[rabbitmq]
2+
192.168.153.133 rabbitmq_master=true
3+
192.168.153.132 rabbitmq_slave=true rabbitslave1=true
4+
192.168.153.131 rabbitmq_slave=true rabbitslave2=true
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
variable "public_key_path" {
2+
default = "~/.ssh/id_rsa.pub"
3+
description = <<DESCRIPTION
4+
Path to the SSH public key to be used for authentication.
5+
Ensure this keypair is added to your local SSH agent so provisioners can
6+
connect.
7+
8+
Example: ~/.ssh/id_rsa.pub
9+
DESCRIPTION
10+
}
11+
12+
variable "key_name" {
13+
default = "pulsar-benchmark-key"
14+
description = "Desired name of AWS key pair"
15+
}
16+
17+
variable "region" {
18+
default = "us-west-2"
19+
}
20+
21+
variable "ami" {
22+
default = "ami-9fa343e7" // RHEL-7.4
23+
}
24+
25+
provider "aws" {
26+
region = "${var.region}"
27+
}
28+
29+
# Create a VPC to launch our instances into
30+
resource "aws_vpc" "benchmark_vpc" {
31+
cidr_block = "10.0.0.0/16"
32+
33+
tags {
34+
Name = "Benchmark-VPC"
35+
}
36+
}
37+
38+
# Create an internet gateway to give our subnet access to the outside world
39+
resource "aws_internet_gateway" "default" {
40+
vpc_id = "${aws_vpc.benchmark_vpc.id}"
41+
}
42+
43+
# Grant the VPC internet access on its main route table
44+
resource "aws_route" "internet_access" {
45+
route_table_id = "${aws_vpc.benchmark_vpc.main_route_table_id}"
46+
destination_cidr_block = "0.0.0.0/0"
47+
gateway_id = "${aws_internet_gateway.default.id}"
48+
}
49+
50+
# Create a subnet to launch our instances into
51+
resource "aws_subnet" "benchmark_subnet" {
52+
vpc_id = "${aws_vpc.benchmark_vpc.id}"
53+
cidr_block = "10.0.0.0/24"
54+
map_public_ip_on_launch = true
55+
}
56+
57+
resource "aws_security_group" "benchmark_security_group" {
58+
name = "terraform"
59+
vpc_id = "${aws_vpc.benchmark_vpc.id}"
60+
61+
# SSH access from anywhere
62+
ingress {
63+
from_port = 22
64+
to_port = 22
65+
protocol = "tcp"
66+
cidr_blocks = ["0.0.0.0/0"]
67+
}
68+
69+
# All ports open within the VPC
70+
ingress {
71+
from_port = 0
72+
to_port = 65535
73+
protocol = "tcp"
74+
cidr_blocks = ["10.0.0.0/16"]
75+
}
76+
77+
# outbound internet access
78+
egress {
79+
from_port = 0
80+
to_port = 0
81+
protocol = "-1"
82+
cidr_blocks = ["0.0.0.0/0"]
83+
}
84+
85+
tags {
86+
Name = "Benchmark-Security-Group"
87+
}
88+
}
89+
90+
resource "aws_key_pair" "auth" {
91+
key_name = "${var.key_name}"
92+
public_key = "${file(var.public_key_path)}"
93+
}
94+
95+
resource "aws_instance" "zookeeper" {
96+
ami = "${var.ami}"
97+
instance_type = "t2.small"
98+
key_name = "${aws_key_pair.auth.id}"
99+
subnet_id = "${aws_subnet.benchmark_subnet.id}"
100+
vpc_security_group_ids = ["${aws_security_group.benchmark_security_group.id}"]
101+
count = 3
102+
103+
tags {
104+
Name = "zk-${count.index}"
105+
}
106+
}
107+
108+
resource "aws_instance" "pulsar" {
109+
ami = "${var.ami}"
110+
instance_type = "i3.4xlarge"
111+
key_name = "${aws_key_pair.auth.id}"
112+
subnet_id = "${aws_subnet.benchmark_subnet.id}"
113+
vpc_security_group_ids = ["${aws_security_group.benchmark_security_group.id}"]
114+
count = 3
115+
116+
tags {
117+
Name = "pulsar-${count.index}"
118+
}
119+
}
120+
121+
resource "aws_instance" "client" {
122+
ami = "${var.ami}"
123+
instance_type = "c4.8xlarge"
124+
key_name = "${aws_key_pair.auth.id}"
125+
subnet_id = "${aws_subnet.benchmark_subnet.id}"
126+
vpc_security_group_ids = ["${aws_security_group.benchmark_security_group.id}"]
127+
count = 1
128+
129+
tags {
130+
Name = "pulsar-client-${count.index}"
131+
}
132+
}
133+
134+
output "client_ssh_host" {
135+
value = "${aws_instance.client.0.public_ip}"
136+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=RabbitMQ broker
3+
After=network.target
4+
5+
[Service]
6+
ExecStart=/usr/lib/rabbitmq/bin/rabbitmq-server
7+
WorkingDirectory=/var/lib/rabbitmq
8+
RestartSec=1s
9+
Restart=on-failure
10+
Type=simple
11+
LimitNOFILE=300000
12+
13+
[Install]
14+
WantedBy=multi-user.target

driver-rabbitmq/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!--
2+
3+
Licensed to the Apache Software Foundation (ASF) under one
4+
or more contributor license agreements. See the NOTICE file
5+
distributed with this work for additional information
6+
regarding copyright ownership. The ASF licenses this file
7+
to you under the Apache License, Version 2.0 (the
8+
"License"); you may not use this file except in compliance
9+
with the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing,
14+
software distributed under the License is distributed on an
15+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
KIND, either express or implied. See the License for the
17+
specific language governing permissions and limitations
18+
under the License.
19+
20+
-->
21+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>io.openmessaging.benchmark</groupId>
26+
<artifactId>messaging-benchmark</artifactId>
27+
<version>0.0.1-SNAPSHOT</version>
28+
<relativePath>..</relativePath>
29+
</parent>
30+
31+
<artifactId>driver-pulsar</artifactId>
32+
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>${project.groupId}</groupId>
37+
<artifactId>driver-api</artifactId>
38+
<version>${project.version}</version>
39+
</dependency>
40+
41+
<dependency>
42+
<groupId>org.apache.pulsar</groupId>
43+
<artifactId>pulsar-client</artifactId>
44+
<version>1.20.0-incubating</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.pulsar</groupId>
49+
<artifactId>pulsar-client-admin</artifactId>
50+
<version>1.20.0-incubating</version>
51+
</dependency>
52+
</dependencies>
53+
</project>

0 commit comments

Comments
 (0)