〇コンテナの構築
LXDで以下のコマンドを実行して、CouchDBがインストールされたコンテナを構築します。
lxc init ubuntu:16.04 zookeeper
lxc config set zookeeper user.user-data - < config.yml
lxc start zookeeper
config.yml
#cloud-config
package_upgrade: true
hostname: zookeeper
manage_etc_hosts: true
write_files:
- path: /etc/systemd/system/zookeeper.service
content: |
[Unit]
Description=Apache Zookeeper
Requires=network.target
After=network.target
[Service]
Type=forking
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop
WorkingDirectory=/opt/zookeeper
[Install]
WantedBy=multi-user.target
- path: /tmp/zoo.cfg
content: |
tickTime=2000
dataDir=/var/zookeeper
clientPort=2181
runcmd:
- 'apt-get update'
- 'apt-get -y install openjdk-8-jdk'
- 'apt-get -y install unzip'
- 'wget http://ftp.riken.jp/net/apache/zookeeper/zookeeper-3.4.11/zookeeper-3.4.11.tar.gz'
- 'tar xvfz zookeeper-3.4.11.tar.gz'
- 'mv zookeeper-3.4.11 /opt/zookeeper'
- 'mv /tmp/zoo.cfg /opt/zookeeper/conf'
- systemctl enable zookeeper.service
- systemctl start zookeeper.service
- "while netstat -lnt | awk '$4 ~ /:2181$/ {exit 1}'; do sleep 10; done"
- "sleep 10"
- "/opt/zookeeper/bin/zkCli.sh -server localhost:2181 create /test mydata"
- "/opt/zookeeper/bin/zkCli.sh -server localhost:2181 ls /"
- "/opt/zookeeper/bin/zkCli.sh -server localhost:2181 get /test"
final_message: "completed."
〇コンテナに入る
lxc exec zookeeper /bin/bash
〇コンテナのIPを調べる
コンテナのIPは以下のコマンドで調べることができます。
lxc list
〇コンテナの停止
lxc stop zookeeper
〇コンテナの削除
lxc delete zookeeper
0 件のコメント:
コメントを投稿