/
deploy.yaml
144 lines (137 loc) · 5.02 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
- name: Hosts addresses
hosts: rmq-namesrv
become: false
tasks:
- debug:
msg: "RocketMQ broker servers {{ item }}"
with_items: "{{ groups['rmq-broker'] }}"
- debug:
msg: "RocketMQ name servers {{ item }}"
with_items: "{{ groups['rmq-namesrv'] }}"
- debug:
msg: "Benchmark clients {{ item }}"
with_items: "{{ groups['rmq-client'] }}"
- name: RocketMQ setup
hosts: all
connection: ssh
become: true
tasks:
- name: Install RPM packages
yum: pkg={{ item }} state=latest
with_items:
- wget
- java
- sysstat
- vim
- unzip
- file: path=/opt/rocketmq state=absent
- file: path=/opt/rocketmq state=directory
- set_fact:
nameServers: "{{ groups['rmq-namesrv']|map('extract', hostvars, ['ansible_default_ipv4', 'address'])|map('regex_replace', '(.*)', '\\1:9876') | join(';') }}"
rocketMQVersion: "4.3.0"
- name: Download RocketMQ package
unarchive:
src: http://mirror.bit.edu.cn/apache/rocketmq/{{ rocketMQVersion }}/rocketmq-all-{{ rocketMQVersion }}-bin-release.zip
remote_src: yes
dest: /opt/rocketmq
- set_fact:
privateIp: "{{ hostvars[inventory_hostname]['ansible_facts']['eth0']['ipv4']['address'] }}"
- name: Change locale to en_US.utf-8
shell: |
echo 'LANG=en_US.utf-8
LC_ALL=en_US.utf-8' > /etc/environment
- name: Setup RocketMQ Broker
hosts: rmq-broker
connection: ssh
become: true
tasks:
- set_fact:
brokerName: "{{ groups['rmq-broker'].index(inventory_hostname) }}"
- name: Set up broker
template:
src: "templates/rmq-broker.properties"
dest: "/opt/rocketmq/rocketmq-all-4.3.0-bin-release/conf/rmq-broker.properties"
- template:
src: "templates/rmq-broker.service"
dest: "/etc/systemd/system/rmq-broker.service"
- systemd:
state: restarted
daemon_reload: yes
name: "rmq-broker"
- name: Setup RocketMQ NameServer
hosts: rmq-namesrv
connection: ssh
become: true
tasks:
- name: Set up RocketMQ NameServer
template:
src: "templates/rmq-namesrv.properties"
dest: "/opt/rocketmq/rocketmq-all-4.3.0-bin-release/conf/rmq-namesrv.properties"
- template:
src: "templates/rmq-namesrv.service"
dest: "/etc/systemd/system/rmq-namesrv.service"
- systemd:
state: restarted
daemon_reload: yes
name: "rmq-namesrv"
- name: Setup Benchmark client
hosts: rmq-client
connection: ssh
become: true
tasks:
- file: path=/opt/benchmark state=absent
- name: Copy benchmark code
unarchive:
src: ../../package/target/openmessaging-benchmark-0.0.1-SNAPSHOT-bin.tar.gz
dest: /opt
- shell: rm -rf /opt/benchmark
- shell: mv /opt/openmessaging-benchmark-0.0.1-SNAPSHOT /opt/benchmark
- shell: tuned-adm profile latency-performance
- name: Get list of driver config files
raw: ls -1 /opt/benchmark/driver-rocketmq/*.yaml
register: drivers_list
- name: Configure URL
lineinfile:
dest: /opt/benchmark/driver-rocketmq/rocketmq.yaml
regexp: '^namesrvAddr: '
line: 'namesrvAddr: {{ nameServers }}'
with_items: '{{ drivers_list.stdout_lines }}'
- name: Configure memory
lineinfile:
dest: /opt/benchmark/bin/benchmark-worker
regexp: '^JVM_MEM='
line: 'JVM_MEM="-Xms12G -Xmx12G -XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+AggressiveOpts -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=32 -XX:ConcGCThreads=32 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB -XX:+PerfDisableSharedMem -XX:+AlwaysPreTouch -XX:-UseBiasedLocking"'
- name: Configure memory
lineinfile:
dest: /opt/benchmark/bin/benchmark
regexp: '^JVM_MEM='
line: 'JVM_MEM="-Xmx1G"'
- template:
src: "templates/workers.yaml"
dest: "/opt/benchmark/workers.yaml"
- name: Install benchmark systemd service
template:
src: "templates/benchmark-worker.service"
dest: "/etc/systemd/system/benchmark-worker.service"
- systemd:
state: restarted
daemon_reload: yes
name: "benchmark-worker"