Mesos/Marathon

# Mesos/Marathon

なぜかうまく動かないんだよな〜

## 環境

|ホスト名 | IP           |zookeeper | mesos  | marathon | OS      |
|---     |---           |  ---     | ---    |  ---     |---    |
| mesos0 | 192.168.1.70 | ○        | master | ○        | CentOS 7.7.1908 |
| mesos1 | 192.168.1.71 | -        | slave  | ○        | CentOS 7.7.1908 |
| mesos2 | 192.168.1.72 | -        | slave  | ○        | CentOS 7.7.1908 |
| mesos3 | 192.168.1.73 | -        | slave  | ○        | CentOS 7.7.1908 |

## mesos0 セットアップ
### ipv6 無効化

```
echo 'net.ipv6.conf.all.disable_ipv6 = 1'     | tee -a /etc/sysctl.d/disable_ipv6.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1' | tee -a /etc/sysctl.d/disable_ipv6.conf
sudo sysctl -p/etc/sysctl.d/disable_ipv6.conf
```

### 名前解決

```
sudo hostnamectl set-hostname mesos0
echo '192.168.1.70 mesos0' | sudo tee -a /etc/hosts
echo '192.168.1.71 mesos1' | sudo tee -a /etc/hosts
echo '192.168.1.72 mesos2' | sudo tee -a /etc/hosts
echo '192.168.1.73 mesos3' | sudo tee -a /etc/hosts
```

### リポジトリ追加

```
sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
```

### zookeeper インストール

```
sudo yum install mesosphere-zookeeper
echo 1 | sudo tee /var/lib/zookeeper/myid
sudo systemctl restart zookeeper
sudo systemctl status zookeeper
ss -lnpt|grep 2181
```

### mesos-master インストール

```
sudo yum install mesos
echo 'zk://192.168.1.70:2181/mesos' | sudo tee /etc/mesos/zk
sudo systemctl stop mesos-slave
sudo systemctl disable mesos-slave
sudo systemctl restart mesos-master
sudo systemctl status mesos-master
```

http://mesos0:5050

### marathon インストール

```
sudo yum install marathon
echo 'MARATHON_MASTER=zk://192.168.1.70:2181/mesos' | sudo tee -a /etc/default/marathon
echo 'MARATHON_ZK=zk://192.168.1.70:2181/marathon'  | sudo tee -a /etc/default/marathon
sudo systemctl restart marathon
sudo systemctl status marathon
journalctl -xefu marathon
```

http://mesos0:8080


## mesos1 - mesos3
### ipv6 無効化

```
echo 'net.ipv6.conf.all.disable_ipv6 = 1'     | tee -a /etc/sysctl.d/disable_ipv6.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1' | tee -a /etc/sysctl.d/disable_ipv6.conf
sudo sysctl -p/etc/sysctl.d/disable_ipv6.conf
```

### 名前解決

```
sudo hostnamectl set-hostname mesos1
# or
sudo hostnamectl set-hostname mesos2
# or
sudo hostnamectl set-hostname mesos3
echo '192.168.1.70 mesos0' | sudo tee -a /etc/hosts
echo '192.168.1.71 mesos1' | sudo tee -a /etc/hosts
echo '192.168.1.72 mesos2' | sudo tee -a /etc/hosts
echo '192.168.1.73 mesos3' | sudo tee -a /etc/hosts
```

### docker インストール

```
sudo yum install yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl restart docker
sudo systemctl status docker
sudo docker run hello-world
sudo docker kill $(docker ps -q)
sudo docker rm $(docker ps -a -q)
sudo docker rmi $(docker images -q)
```

### リポジトリ追加

```
sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
```

### mesos-slave インストール

```
sudo yum install mesos
echo 'zk://192.168.1.70:2181/mesos' | sudo tee /etc/mesos/zk
echo 'docker,mesos' | sudo tee /etc/mesos-slave/containerizers
echo '10mins' | sudo tee /etc/mesos-slave/executor_registration_timeout
sudo rm -f /var/lib/mesos/meta/slaves/latest
sudo systemctl stop mesos-master
sudo systemctl disable mesos-master
sudo systemctl restart mesos-slave
sudo systemctl status mesos-slave
```

### marathon インストール

```
sudo yum install marathon
echo 'MARATHON_MASTER=zk://192.168.1.70:2181/mesos' | sudo tee -a /etc/default/marathon
echo 'MARATHON_ZK=zk://192.168.1.70:2181/marathon'  | sudo tee -a /etc/default/marathon
sudo systemctl restart marathon
sudo systemctl status marathon
journalctl -xefu marathon
```

## 参考
Setting up mesos cluster on Redhat 7 or Centos 7
http://discuss.itversity.com/t/setting-up-mesos-cluster-on-redhat-7-or-centos-7/13175

Get Docker Engine - Community for CentOS
https://docs.docker.com/install/linux/docker-ce/centos/

さくらのクラウドで構築する Mesos+Marathon+Docker クラスタ環境 
https://speakerdeck.com/chibiegg/sakurafalsekuraudodegou-zhu-suru-mesos-plus-marathon-plus-docker-kurasutahuan-jing

Docker ホスティングサービス 'Arukas' での Mesos + Marathon の活用について（Mesos勉強会） 
https://www.slideshare.net/sakura_pr/201608-mesos-studypublic-64721613

https://mesosphere.github.io/marathon/docs/native-docker.html