上QQ阅读APP看书,第一时间看更新
Configuring Mesos masters with ZooKeeper
- Edit /var/lib/zookeeper/myid and replace all of the text in the file with a unique integer between 1 and 255. If you plan on building a multi-master Mesos cluster, the integer in this file is arbitrary but it will need to be unique for each ZooKeeper instance on each Mesos master server.
- Edit /etc/zookeeper/conf/zoo.cfg and add a line similar to the following examples for each ZooKeeper instance in your Mesos cluster. The integer that comes after server must match the integers in the myid files created in step 1 for each ZooKeeper instance in your cluster. The following are examples for both single server and multi-master Mesos clusters:
-
- Example 1: This configuration is for a single ZooKeeper instance on a Mesos development machine so you would only need one line with the loopback address. The myid file (step 1) on this development machine would contain the integer 1:
server.1=127.0.0.1:2888:3888
-
- Example 2: This configuration is for a Mesos production cluster with three Mesos/ZooKeeper masters. Each master node is running a ZooKeeper instance with a unique integer in the myid file. The numbers after the server entries must match the integers in the myid files for the three ZooKeeper servers. The three ZooKeeper servers in this example have myid file entries of 1, 2, and 3 respectively. Replace the IP address (10.10.0.x) in the following examples with the real IP addresses of your Mesos masters:
server.1=10.0.0.11:2888:3888
server.2=10.0.0.32:2888:3888
server.3=10.0.0.25:2888:3888
- Edit the 'dataDir=' setting in /etc/zookeeper/conf/zoo.cfg and set it to the directory where you want to store the ZooKeeper snapshot.
- Edit /etc/mesos/zk and modify the default URL to match the IP address of the ZooKeeper/Mesos masters. For standalone Mesos instances, the default url may be left as is. The url for the Mesos production cluster example in step 2 would look like this:
zk://10.0.0.11:2181,10.0.0.32:2181,10.0.0.25:2181/mesos
- Edit /etc/mesos-master/quorum and modify the setting to an integer that is equal to more than half of the Mesos masters but no more than the total number of masters. For a standalone instance, this would be 1. For a production cluster, you generally would not want to include all of the Mesos masters in the quorum so that the cluster will still continue to operate if one master is down. For our three-node Mesos master example, the best setting is 2.
- Create IP, hostname, and cluster files for each of the Mesos masters, changing the IP and hostname values for each master. The cluster name is arbitrary and can be whatever you would like to call your cluster but it must be the same for all masters:
$ echo "10.10.0.71" | sudo tee /etc/mesos-master/ip
$ echo "centos7071" | sudo tee /etc/mesos-
master/hostname
$ echo "MesosCentOS7" | sudo tee /etc/mesos-
master/cluster
- Restart ZooKeeper and the Mesos masters:
-
- Ubuntu 14.04:
$ sudo service zookeeper restart
$ sudo service mesos-master restart
-
- CentOS7/RHEL7/Ubuntu 16.04:
$ sudo systemctl restart zookeeper
$ sudo systemctl restart mesos-master
- Disable Mesos agent (slave) services. If you are configuring a production Mesos cluster, you will want to run the Mesos masters on dedicated servers with the Mesos agent (slave) services disabled:
-
- Ubuntu 14.04:
$ sudo service mesos-slave stop
$ echo manual | sudo tee /etc/init/mesos-
slave.override
-
- CentOS7/RHEL7/Ubuntu 16.04:
$ sudo systemctl stop mesos-slave
$ sudo systemctl disable mesos-slave
- CentOS7/RHEL7/Ubuntu 16.04:
- Repeat steps 1-8 on each Mesos master.
- Once all of the Mesos masters are running, validate your cluster by pointing your browser to port 5050 on any of the master servers. Mesos masters running with ZooKeeper will only have one elected leader at a time. You can see which master is currently the leader by looking at the value for Server: in the upper-right corner of the Mesos UI: