前回はConsulの登場背景や使いどころについて扱いました。今回はConsulを実際に使うために,
動作確認のための最小構成
Consulの基本動作を確認するための最小環境は,
なお,
Consulのセットアップ
Consulを使い始めるには,
以下はLinux
$ wget -O 0.5.0_linux_amd64.zip https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip $ unzip 0.5.0_linux_amd64.zip $ sudo cp consul /usr/bin/consul
以上でセットアップ作業は完了です。Consulはconsul
という名前のバイナリのみで動作するため,consul version
と実行します。
$ consul version Consul v0.5.0 Consul Protocol: 2 (Understands back to: 1)
ここで
Web UIのセットアップ
Consulは,
$ wget -O 0.5.0_web_ui.zip https://dl.bintray.com/mitchellh/consul/0.5.0_web_ui.zip $ unzip 0.5.0_web_ui.zip $ sudo mv dist /opt/consul/dist
移動したディレクトリを控えておき,
Consulサーバの起動
Consulエージェントをサーバとして起動するには,consul agent
コマンドを使う時,
-server
エージェントをサーバ状態にします
(必須)。 -bootstrap-expect=1
Consulサーバを1台で構成することを明示します
(必須)。 -data-dir=/tmp/
consul データ保管場所を指定します
(必須)。 -bind=192.
168. 39. 3 複数のネットワークインターフェースがある環境では,
どのIPアドレスを利用するか選べます。
これらのオプションを使って起動すると,
# consul agent -server -bootstrap-expect=1 -data-dir=/tmp/consul -bind=192.168.39.3 ==> WARNING: BootstrapExpect Mode is specified as 1; this is the same as Bootstrap mode. ==> WARNING: Bootstrap mode enabled! Do not enable unless necessary ==> Starting Consul agent... ==> Starting Consul agent RPC... ==> Consul agent running! Node name: 'sion.pocketstudio.net' Datacenter: 'dc1' Server: true (bootstrap: true) Client Addr: 127.0.0.1 (HTTP: 8500, HTTPS: -1, DNS: 8600, RPC: 8400) Cluster Addr: 192.168.39.3 (LAN: 8301, WAN: 8302) Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false Atlas: <disabled> ==> Log data will now stream in as it occurs:
Consulエージェントを終了するには,Ctrl+C
キーで中断するか,kill
コマンドで停止できます。