frank6866.zookeeper
Zookeeper
This role helps set up a Zookeeper cluster on CentOS/RHEL.
Role Variables
Here are the default variable values for Zookeeper:
zk_maxClientCnxns : 50 # Max client connections
zk_tickTime : 2000 # Time in milliseconds for tick
zk_initLimit : 10 # Init limit for the connection
zk_syncLimit : 5 # Sync limit for the connection
zk_dataDir : /var/lib/zookeeper # Directory for data storage
zk_data_logDir : /var/lib/zookeeper # Directory for log data
zk_clientPort : 2181 # Port for client connections
zk_leaderPort : 2888 # Port for leader election
zk_electionPort : 3888 # Port for election communication
Example Inventory File
Here’s an example of how to write your inventory file:
zk-1 ansible_ssh_host=192.168.168.201 ansible_ssh_port=22 ansible_ssh_user=centos
zk-2 ansible_ssh_host=192.168.168.202 ansible_ssh_port=22 ansible_ssh_user=centos
zk-3 ansible_ssh_host=192.168.168.203 ansible_ssh_port=22 ansible_ssh_user=centos
[cluster1]
zk-1 zk_myid=1 zk_ip=192.168.168.201
zk-2 zk_myid=2
zk-3 zk_myid=3
[zookeeper:children]
cluster1
If you have only one IP address for a host, you can skip the "zk_ip" variable. If there are multiple IPs, specify which one Zookeeper will use using "zk_ip".
Example Playbook
Here’s an example playbook:
- hosts: zookeeper
become: true
roles:
- { role: /path/to/zookeeper-role }
Zookeeper Usage
You can use Zookeeper with the following commands:
# Open the Zookeeper client
zookeeper-client
# Check the status of the Zookeeper server
zookeeper-server status
Testing
To test the setup, you can use the three hosts defined in the "Vagrantfile" in the root directory. Run the following script:
# ./vagrant.sh
License
MIT