Permalink
Fetching contributors…
Cannot retrieve contributors at this time
237 lines (225 sloc) 7.69 KB
#
# 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: Format and mount disks for Pulsar/BookKeeper hosts
hosts: pulsar
connection: ssh
become: true
tasks:
- name: Format disks
filesystem:
fstype: xfs
dev: '{{ item }}'
with_items:
- '/dev/nvme0n1'
- '/dev/nvme1n1'
- name: Mount disks
mount:
path: "{{ item.path }}"
src: "{{ item.src }}"
fstype: xfs
opts: defaults,noatime,nodiscard
state: mounted
with_items:
- { path: "/mnt/journal", src: "/dev/nvme0n1" }
- { path: "/mnt/storage", src: "/dev/nvme1n1" }
- name: Pulsar installation
hosts: all
connection: ssh
become: true
tasks:
- name: Set performance profile
command: tuned-adm profile latency-performance
- name: Install RPM packages
yum: pkg={{ item }} state=latest
with_items:
- wget
- java
- sysstat
- vim
- screen
- set_fact:
zookeeperServers: "{{ groups['zookeeper'] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | map('regex_replace', '^(.*)$', '\\1:2181') | join(',') }}"
serviceUrl: "pulsar://{{ hostvars[groups['pulsar'][0]].private_ip }}:6650/"
httpUrl: "http://{{ hostvars[groups['pulsar'][0]].private_ip }}:8080/"
pulsarVersion: "2.1.1-incubating"
- file: path=/opt/pulsar state=absent
- file: path=/opt/pulsar state=directory
- name: Download Pulsar binary package
unarchive:
src: "https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-{{ pulsarVersion }}/apache-pulsar-{{ pulsarVersion }}-bin.tar.gz"
remote_src: yes
dest: /opt/pulsar
extra_opts: ["--strip-components=1"]
- set_fact:
private_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
max_heap_memory: "6g"
max_direct_memory: "6g"
- template:
src: "templates/pulsar_env.sh"
dest: "/opt/pulsar/conf/pulsar_env.sh"
- name: Change locale to en_US.utf-8
shell: |
echo 'LANG=en_US.utf-8
LC_ALL=en_US.utf-8' > /etc/environment
- name: ZooKeeper setup
hosts: zookeeper
connection: ssh
become: true
tasks:
- set_fact:
zid: "{{ groups['zookeeper'].index(inventory_hostname) }}"
max_heap_memory: "512m"
max_direct_memory: "512m"
- file:
path: "/opt/pulsar/{{ item }}"
state: directory
with_items:
- data/zookeeper
- template:
src: "templates/pulsar_env.sh"
dest: "/opt/pulsar/conf/pulsar_env.sh"
- template:
src: "templates/zoo.cfg"
dest: "/opt/pulsar/conf/zookeeper.conf"
- template:
src: templates/myid
dest: "/opt/pulsar/data/zookeeper/myid"
- template:
src: "templates/zookeeper.service"
dest: "/etc/systemd/system/zookeeper.service"
- systemd:
state: restarted
daemon_reload: yes
name: "zookeeper"
- command: >
bin/pulsar initialize-cluster-metadata --cluster local
--zookeeper localhost:2181
--global-zookeeper localhost:2181
--web-service-url {{ httpUrl }}
--broker-service-url {{ serviceUrl }}
args:
chdir: /opt/pulsar
when: groups['zookeeper'][0] == inventory_hostname
- name: BookKeeper setup
hosts: pulsar
connection: ssh
become: true
tasks:
- template:
src: "templates/bookkeeper.conf"
dest: "/opt/pulsar/conf/bookkeeper.conf"
- name: Install bookkeeper systemd service
template:
src: "templates/bookkeeper.service"
dest: "/etc/systemd/system/bookkeeper.service"
- systemd:
state: restarted
daemon_reload: yes
name: "bookkeeper"
- name: Pulsar configuration and systemd setup
hosts: pulsar
connection: ssh
become: true
tasks:
- name: Set up broker
template:
src: "templates/broker.conf"
dest: "/opt/pulsar/conf/broker.conf"
- template:
src: "templates/pulsar.service"
dest: "/etc/systemd/system/pulsar.service"
- systemd:
state: restarted
daemon_reload: yes
name: "pulsar"
- name: Get Maven version
hosts: localhost
become: false
tasks:
- shell: >
cat ../../pom.xml | xmllint --format - \
| sed "s/xmlns=\".*\"//g" | xmllint --stream --pattern /project/version --debug - \
| grep -A 2 "matches pattern" | grep text | sed "s/.* [0-9] //g"
register: maven_version
- set_fact:
benchmark_version: "{{ maven_version.stdout }}"
- name: Pulsar benchmarking client setup
hosts: client
connection: ssh
become: true
tasks:
- name: Set up client config
template:
src: "templates/client.conf"
dest: "/opt/pulsar/conf/client.conf"
- 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: mv /opt/openmessaging-benchmark-0.0.1-SNAPSHOT /opt/benchmark
- template:
src: "templates/workers.yaml"
dest: "/opt/benchmark/workers.yaml"
- name: Get list of driver config files
raw: ls -1 /opt/benchmark/driver-pulsar/*.yaml
register: drivers_list
- name: Configure service URL
lineinfile:
dest: '{{ item }}'
regexp: '^ serviceUrl\: '
line: ' serviceUrl: {{ serviceUrl }}'
with_items: '{{ drivers_list.stdout_lines }}'
- name: Configure http URL
lineinfile:
dest: '{{ item }}'
regexp: '^ httpUrl: '
line: ' httpUrl: {{ httpUrl }}'
with_items: '{{ drivers_list.stdout_lines }}'
- name: Configure memory
lineinfile:
dest: /opt/benchmark/bin/benchmark-worker
regexp: '^JVM_MEM='
line: 'JVM_MEM="-Xms6G -Xmx6G -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="-Xmx4G"'
- 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"
- name: List host addresses
hosts: localhost
become: false
tasks:
- debug:
msg: "Zookeeper servers {{ item }}"
with_items: "{{ groups['zookeeper'] }}"
- debug:
msg: "Pulsar/BookKeeper servers {{ item }}"
with_items: "{{ groups['pulsar'] }}"
- debug:
msg: "Benchmark clients {{ item }}"
with_items: "{{ groups['client'] }}"