From 551719b88178efc647cc79253ce73b62ef704087 Mon Sep 17 00:00:00 2001 From: Wayne Schneider Date: Tue, 16 Aug 2016 10:57:35 -0500 Subject: [PATCH] Ansible plays to build dev environment with zookeeper ensemble. --- docker/docker-deploy.yml | 43 +++++++++++++++++++++----- docker/group_vars/dev | 5 ++-- docker/zookeeper/configuration.xsl | 24 +++++++++++++++ docker/zookeeper/log4j.properties | 58 ++++++++++++++++++++++++++++++++++++ docker/zookeeper/zoo.cfg | 28 +++++++++++++++++ 5 files changed, 148 insertions(+), 10 deletions(-) create mode 100644 docker/zookeeper/configuration.xsl create mode 100644 docker/zookeeper/log4j.properties create mode 100644 docker/zookeeper/zoo.cfg diff --git a/docker/docker-deploy.yml b/docker/docker-deploy.yml index 20578b5..dc58055 100644 --- a/docker/docker-deploy.yml +++ b/docker/docker-deploy.yml @@ -54,11 +54,23 @@ command: docker network create luinet when: docker_nets.stdout.find('luinet') == -1 + - name: Copy ZooKeeper config if not present + become: yes + copy: src=zookeeper dest=/etc/masterkey/lui/ force=no + + - name: Create ZooKeeper dataDirs + become: yes + file: path=/var/lib/masterkey/lui/zookeeper/zk{{ item }} state=directory + with_sequence: start=1 end={{ num_zk_servers }} + - name: Launch ZooKeeper containers become: yes docker_container: name: zk{{ item }} image: jplock/zookeeper + volumes: + - /etc/masterkey/lui/zookeeper:/opt/zookeeper/conf + - /var/lib/masterkey/lui/zookeeper/zk{{ item }}:/tmp/zookeeper with_sequence: start=1 end={{ num_zk_servers }} - name: Get ZooKeeper container networks @@ -80,6 +92,26 @@ with_sequence: start=1 end={{ num_zk_servers }} when: (zk_net.results[item|int-1].stdout|from_json).bridge is defined + - name: Create ZooKeeper myid files + become: yes + copy: content={{ item }} dest=/var/lib/masterkey/lui/zookeeper/zk{{ item }}/myid + with_sequence: start=1 end={{ num_zk_servers }} + when: num_zk_servers > 1 + + # Note - this will not remove servers from config + - name: Update zoo.cfg for ensemble + become: yes + lineinfile: dest=/etc/masterkey/lui/zookeeper/zoo.cfg line="server.{{ item }}=zk{{ item }}:2888:3888" + register: zk_conf + with_sequence: start=1 end={{ num_zk_servers }} + when: num_zk_servers > 1 + + - name: Restart ZooKeeper + become: yes + command: docker restart zk{{ item }} + with_sequence: start=1 end={{ num_zk_servers }} + when: zk_conf|changed + - name: Get contents of /solr path in ZooKeeper become: yes command: docker exec -t zk1 bin/zkCli.sh get /solr @@ -93,16 +125,11 @@ - name: Build the lui-solr image become: yes - docker_image: name=lui-solr path={{ docker_image_path }} + docker_image: name=lui-solr path={{ solr_image_path }} - - name: Build ZooKeeper links for Solr containers + - name: Build -z string for Solr set_fact: - # zk_links: [] - zk_solr: [] - - - set_fact: - # zk_links: "{{ zk_links + ['zk'+item+':ZK'+item] }}" - zk_solr: "{{ zk_solr + ['zk'+item+':2181'] }}" + zk_solr: "{{ zk_solr|default([]) + ['zk'+item+':2181'] }}" with_sequence: start=1 end={{ num_zk_servers }} - name: Launch Solr containers diff --git a/docker/group_vars/dev b/docker/group_vars/dev index a95559e..8d4a956 100644 --- a/docker/group_vars/dev +++ b/docker/group_vars/dev @@ -1,7 +1,8 @@ --- docker_users: - vagrant -docker_image_path: /vagrant/docker/solr +solr_image_path: /vagrant/docker/solr +zookeeper_image_path: /vagrant/docker/zookeeper num_solr_servers: 2 -num_zk_servers: 1 +num_zk_servers: 3 num_shards: 2 diff --git a/docker/zookeeper/configuration.xsl b/docker/zookeeper/configuration.xsl new file mode 100644 index 0000000..377cdbe --- /dev/null +++ b/docker/zookeeper/configuration.xsl @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + +
namevaluedescription
+ + +
+
diff --git a/docker/zookeeper/log4j.properties b/docker/zookeeper/log4j.properties new file mode 100644 index 0000000..9825970 --- /dev/null +++ b/docker/zookeeper/log4j.properties @@ -0,0 +1,58 @@ +# Define some default values that can be overridden by system properties +zookeeper.root.logger=INFO, CONSOLE +zookeeper.console.threshold=INFO +zookeeper.log.dir=. +zookeeper.log.file=zookeeper.log +zookeeper.log.threshold=DEBUG +zookeeper.tracelog.dir=. +zookeeper.tracelog.file=zookeeper_trace.log + +# +# ZooKeeper Logging Configuration +# + +# Format is " (, )+ + +# DEFAULT: console appender only +log4j.rootLogger=${zookeeper.root.logger} + +# Example with rolling log file +#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE + +# Example with rolling log file and tracing +#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE + +# +# Log INFO level and above messages to the console +# +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.Threshold=${zookeeper.console.threshold} +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n + +# +# Add ROLLINGFILE to rootLogger to get log file output +# Log DEBUG level and above messages to a log file +log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender +log4j.appender.ROLLINGFILE.Threshold=${zookeeper.log.threshold} +log4j.appender.ROLLINGFILE.File=${zookeeper.log.dir}/${zookeeper.log.file} + +# Max log file size of 10MB +log4j.appender.ROLLINGFILE.MaxFileSize=10MB +# uncomment the next line to limit number of backup files +#log4j.appender.ROLLINGFILE.MaxBackupIndex=10 + +log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n + + +# +# Add TRACEFILE to rootLogger to get log file output +# Log DEBUG level and above messages to a log file +log4j.appender.TRACEFILE=org.apache.log4j.FileAppender +log4j.appender.TRACEFILE.Threshold=TRACE +log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file} + +log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout +### Notice we are including log4j's NDC here (%x) +log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n diff --git a/docker/zookeeper/zoo.cfg b/docker/zookeeper/zoo.cfg new file mode 100644 index 0000000..a5a2c0b --- /dev/null +++ b/docker/zookeeper/zoo.cfg @@ -0,0 +1,28 @@ +# The number of milliseconds of each tick +tickTime=2000 +# The number of ticks that the initial +# synchronization phase can take +initLimit=10 +# The number of ticks that can pass between +# sending a request and getting an acknowledgement +syncLimit=5 +# the directory where the snapshot is stored. +# do not use /tmp for storage, /tmp here is just +# example sakes. +dataDir=/tmp/zookeeper +# the port at which the clients will connect +clientPort=2181 +# the maximum number of client connections. +# increase this if you need to handle more clients +#maxClientCnxns=60 +# +# Be sure to read the maintenance section of the +# administrator guide before turning on autopurge. +# +# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance +# +# The number of snapshots to retain in dataDir +#autopurge.snapRetainCount=3 +# Purge task interval in hours +# Set to "0" to disable auto purge feature +#autopurge.purgeInterval=1 -- 1.7.10.4