概要

github/orchestrator(MySQL replication topology management and HA ) を少し触ってみたのでメモ。

主な機能としては以下の通り。

  • Discovery orchestrator actively crawls through your topologies and maps them. It reads basic MySQL info such as replication status and configuration.
  • Refactoring orchestrator understands replication rules. It knows about binlog file:position, GTID, Pseudo GTID, Binlog Servers.
  • Recovery orchestrator uses a holistic approach to detect master and intermediate master failures. Based on information gained from the topology itself, it recognizes a variety of failure scenarios.
  • The interface orchestrator supports:
    • Command line interface
    • Web API
    • Web interface

環境

GCE 上に 3台の MySQL 環境を構築
(MySQLMaster: db-01 / MySQLSlave: db-02, db-03)

  • OS : CentOS Linux release 7.2.1511 (Core)
  • orchestrator version : 2.0.1-1

環境構築

GCE ということで DeploymentManager で環境構築してみる

config.yaml

imports:
- path: templates/network.jinja
- path: templates/instance.jinja
- path: templates/firewall.jinja

resources:
- name: mysql-network
  type: templates/network.jinja
  properties:
    region: asia-northeast1
    range: 10.255.0.0/24

- name: mysql-instance
  type: templates/instance.jinja
  properties:
    instances:
     - name: db-01
     - name: db-02
     - name: db-03
    machineType: f1-micro
    region: asia-northeast1
    zone: asia-northeast1-a

- name: mysql-firewall
  type: templates/firewall.jinja

templates/network.yaml

resources:
- type: compute.v1.network
  name: {{ env["name"] }}
  properties:
    autoCreateSubnetworks: false

- type: compute.v1.subnetwork
  name: {{ env["name"] }}-subnet
  properties:
    network: $(ref.mysql-network.selfLink)
    ipCidrRange: {{ properties["range"] }}
    region: {{ properties["region"] }}

templates/instance.yaml

resources:
{% for instance in properties["instances"] %}
  {%set name = instance["name"] %}

- type: compute.v1.instance
  name: {{ name }}
  properties:
    zone: {{ properties["zone"] }}
    machineType: https://www.googleapis.com/compute/v1/projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/machineTypes/{{ properties["machineType"] }}

    tags:
      items:
        - mysql

    disks:
    - type: PERSISTENT
      deviceName: {{ name }}-disk
      boot: true
      mode: READ_WRITE
      autoDelete: true
      initializeParams:
        sourceImage: https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-7-v20161129
        diskType: projects/{{ env["project"] }}/zones/{{ properties["zone"] }}/diskTypes/pd-standard
        diskSizeGb: 10

    canIpForward: true

    networkInterfaces:
    - network: $(ref.mysql-network.selfLink)
      subnetwork: $(ref.mysql-network-subnet.selfLink)
      accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT

    metadata:
      items:
      - key: startup-script
        value: |
          #!/bin/bash
          timedatectl set-timezone Asia/Tokyo          

    scheduling:
      preemptible: false
      onHostMaintenance: MIGRATE
      automaticRestart: true

    serviceAccounts:
    - email: default
      scopes:
        - https://www.googleapis.com/auth/logging.write
        - https://www.googleapis.com/auth/monitoring.write
{% endfor %}

templates/firewall.yaml

resources:
- name: {{ env["name"] }}-ssh
  type: compute.v1.firewall
  properties:
    network: $(ref.mysql-network.selfLink)
    sourceRanges: ["0.0.0.0/0"]
    allowed:
    - IPProtocol: TCP
      ports: ["22"]

- name: {{ env["name"] }}-internal
  type: compute.v1.firewall
  properties:
    network: $(ref.condor-network.selfLink)
    sourceRanges: ["10.255.0.0/24"]
    allowed:
    - IPProtocol: TCP
      ports: ["0-65535"]
    - IPProtocol: UDP
      ports: ["0-65535"]
    - IPProtocol: ICMP

プレビュー実行

$ gcloud deployment-manager deployments create mysql-cluster --config=config.yaml --preview

NAME                       TYPE                   STATE      ERRORS  INTENT
db-01                      compute.v1.instance    COMPLETED  []
db-02                      compute.v1.instance    COMPLETED  []
db-03                      compute.v1.instance    COMPLETED  []
mysql-firewall-management  compute.v1.firewall    COMPLETED  []
mysql-network              compute.v1.network     COMPLETED  []
mysql-network-subnet       compute.v1.subnetwork  COMPLETED  []

WEBからデプロイ実行

orchestrator インストール

MySQL Replication 環境の構築は割愛

orchestrator インストールは以下の通り

$ curl -s https://packagecloud.io/install/repositories/github/orchestrator/script.rpm.sh | sudo bash
$ sudo yum install orchestrator orchestrator-cli

orchestrator 設定

以下を参照

UI から確認してみる

http://{サーバIPアドレス}:3000/ にアクセス

Discover より構築した3台のインスタンスを登録

Cluster の確認

Slave 障害時

とりあえず動作したので、詳細は別途。。。