Heron集群中安装配置Aurora
系统环境
Heron集群提供了一个抽象的调度器概念,使其可以使用Aurora或Mesos作为其调度器。这两个调度器的使用都需要Heron部署运行在Mesos集群之上,同时因为Aurora需要运行在Mesos之上,因此这里介绍Heron集群中关于Aurora的安装和配置,为高可用集群后续的配置安装提供基础。
基础环境设置:
1. 各个主机中/etc/hostname和/etc/hosts文件中已经配置好对应主机名称和IP信息。
heron01: HERON01_IP
heron02: HERON02_IP
heron03: HERON03_IP
2. 配置三台主机之间SSH免密登录
3. 安装jdk1.8
4. 安装配置zookeeper集群环境:Ubuntu16.04安装配置使用Zookeeper集群
说明:该文章为Heron高可用集群配置的一部分内容,因此集群环境沿用集群配置中的内容。
安装Aurora Scheduler和Aurora Executor
Aurora是运行在Mesos之上的一个提供高可用调度的组件,他和Mesos配合使用,关系图如下。具体的Aurora的介绍可详见:Aurora Document。
不同于Mesos,Aurora的Scheduler和Executor需要使用不同的包进行安装,所以,下面我们将在Master节点(heron01)中安装Scheduler,在Slaves节点(heron02和heron03)中安装Executor。
安装Aurora Scheduler
在开始安装Aurora的各个组件之前,先在master节点中启动已经安装完成的mesos集群。具体的安装过程见之前的一篇文章:Heron集群中编译方式安装配置Mesos集群。mesos集群启动命令如下:
[email protected]:/home/yitian# ./mesosinstall/sbin/mesos-start-cluster.sh
注意:以下步骤在Master主机(heron01)中完成!!!
1. 查看Master主机中mesos的运行状态
[email protected]:~/mesosinstall/sbin$ ps -e |grep mesos
4848 ? 00:00:02 mesos-master
2. 安装ZooKeeper和mesos。这里仍然需要使用命令安装zookeeper和mesos,因为aurora-scheduler会依赖zookeeper和mesos的安装,否则在运行后续aurora安装命令时会出现错误。虽然在之前已经成功配置了zookeeper和mesos集群环境,但这里仍需要执行如下的命令:
mesos的命令安装方式见个人Blog中的文章:Ubuntu16.04 使用apt-get命令安装Mesos。如下为安装zookeeper的命令:
sudo apt-get install -y zookeeperd
注:在这里安装完成mesos和zookeeper后,可以不对其进行使用和配置,这里使用命令安装mesos和zookeeper仅是因为aurora的安装命令会依赖zookeeper和mesos的安装。mesos集群的使用仍依赖于上述编译安装的方式。zookeeper的配置和使用同样是以之前的安装的步骤为准,启动时也是依赖于此:Ubuntu16.04安装配置使用Zookeeper集群。
3. 安装Aurora Scheduler
sudo add-apt-repository -y ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install -y openjdk-8-jre-headless wget
sudo update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
wget -c https://apache.bintray.com/aurora/ubuntu-trusty/aurora-scheduler_0.17.0_amd64.deb
sudo dpkg -i aurora-scheduler_0.17.0_amd64.deb
安装aurora-scheduler时,遇到的错误及解决:Aurora scheduler安装遇到的问题
4. 停止scheduler进行配置:
(1)停止aurora-scheduler:
[email protected]:~$ sudo service aurora-scheduler stop
(2)配置aurora-scheduler:(Finalizing)
[email protected]:~$ sudo -u aurora mkdir -p /var/lib/aurora/scheduler/db
[email protected]:~$ sudo -u aurora mesos-log initialize --path=/var/lib/aurora/scheduler/db
I0212 07:19:34.222137 7540 replica.cpp:795] Replica recovered with log positions 0 -> 0 with 1 holes and 0 unlearned
I0212 07:19:34.224320 7544 replica.cpp:322] Persisted replica status to VOTING
进行第(2)步操作的依据,见Aurora的文档中所述:
By default, the scheduler will start in an uninitialized mode. This is because external coordination is necessary to be certain operator error does not result in a quorum of schedulers starting up and believing their databases are empty when in fact they should be re-joining a cluster.
Because of this, a fresh install of the scheduler will need intervention to start up. First, stop the scheduler service. Ubuntu:
sudo stop aurora-scheduler
CentOS:sudo systemctl stop aurora
Now initialize the database:
sudo -u aurora mkdir -p /var/lib/aurora/scheduler/db sudo -u aurora mesos-log initialize --path=/var/lib/aurora/scheduler/db
Now you can start the scheduler back up. Ubuntu:
sudo start aurora-scheduler CentOS: sudo systemctl start aurora
5. 修改scheduler配置中的ZooKeeper URL。配置文件目录:[email protected]:/etc/default$ sudo vim /etc/default/aurora-scheduler。查找并修改如下内容:
LIBPROCESS_PORT=8083
#LIBPROCESS_IP=127.0.0.1
LIBPROCESS_IP=192.168.201.136 <strong># 这里设置了LIBPROCESS_IP
...
# ZK_ENDPOINTS="127.0.0.1:2181"
ZK_ENDPOINTS="heron01:2181" <strong># 这里重新设置了ZK_ENDPOINTS
...
# THERMOS_EXECUTOR_FLAGS="--announcer-ensemble 127.0.0.1:2181"
THERMOS_EXECUTOR_FLAGS="--announcer-ensemble MASTER_IP:2181" # 这里将IP换成了Master主机的IP
6. 启动aurora-scheduler
[email protected]:/etc/default$ sudo service aurora-scheduler start
启动后aurora界面:
注:安装Aurora Scheduler中的前三步来自Aurora的官方文档:Installing Aurora
安装Aurora Executor和Observer
注:该部分步骤进行在各个slave主机中。
1. 启动mesos集群后,查看slave中mesos的运行状态:
[email protected]:~/mesosinstall/sbin$ ps -e |grep mesos
3471 ? 00:00:05 mesos-agent
2. 安装Aurora executor和observer:
sudo apt-get install -y python2.7 wget
# NOTE: This appears to be a missing dependency of the mesos deb package and is needed
# for the python mesos native bindings.
sudo apt-get -y install libcurl4-nss-dev
wget -c https://apache.bintray.com/aurora/ubuntu-trusty/aurora-executor_0.17.0_amd64.deb
sudo dpkg -i aurora-executor_0.17.0_amd64.deb
Aurora与Mesos的工作配置
为了确保在Slave主机中的Thermos可以配置到正确的Mesos工作目录。默认情况下,Mesos slave的工作目录为/tmp/mesos(
Installing Aurora中Worker Configuration部分)。但这里在对mesos进行配置时,将agent主机中配置的工作目录设置为/home/yitian/mesosdata/run,因此进行如下配置:
1. 查找并修改master中的配置文件:/etc/default/thermos:
# MESOS_ROOT=/var/lib/mesos
MESOS_ROOT=/home/yitian/mesosdata/run <strong># 修改了MESOS_ROOT,与Mesos集群中的设置保持一致
2. 查找并修改slave中的配置文件:/etc/init/thermos.conf:
description "Aurora Thermos observer"
start on stopped rc RUNLEVEL=[2345]
respawn
post-stop exec sleep 5
pre-start exec mkdir -p /var/run/thermos
script
[ -r /etc/default/thermos ] && . /etc/default/thermos
exec start-stop-daemon --start --exec /usr/sbin/thermos_observer -- \
--port=${OBSERVER_PORT:-1338} \
--mesos-root=${MESOS_ROOT:-/home/yitian/mesosdata/run</} \ # 这里将MESOS_ROOT修改为在Mesos集群配置时设置的相关目录
--log_to_disk=NONE \
--log_to_stderr=google:INFO
end script
3. 在各个slave主机中启动thermos-observer:
[email protected]:~$ thermos_observer --ip=SLAVE_IP --mesos-root=/home/yitian/mesosdata/run
注:这里需要在各个slave主机中运行该命令,否则会在点击aurora ui中agent中各个主机的链接时出现页面找不到的异常。
安装Aurora Client
安装Aurora Client的主机为用户提供提交Jobs的服务,这里安装在heron01中:
sudo apt-get install -y python2.7 wget
wget -c https://apache.bintray.com/aurora/ubuntu-trusty/aurora-tools_0.17.0_amd64.deb
sudo dpkg -i aurora-tools_0.17.0_amd64.deb
安装完成后进行如下配置,编辑/etc/aurora/clusters.json配置文件:
[
{
"auth_mechanism": "UNAUTHENTICATED",
"name": "aurora", # 设置集群名称
"scheduler_zk_path": "/aurora/scheduler",
"slave_root": "/home/yitian/mesosdata/run", # 设置slave主机中的mesos路径
"slave_run_directory": "latest",
"zk": "ZOOKEEPER_IP" # 设置zookeeper URL
}
]
完成Aurora的安装
在正常安装配置Mesos和Aurora的集群后,在浏览器中查看如下地址:
- heron01:http://heron01:5050
- heron01:http://heron01:8081
(1) 在mesos中查看frameworks:
(2)查看aurora scheduler:
(3)查看aurora agents:
(4) 点击aurora中的agent
至此,Aurora在Heron集群中的安装和配置完成。