Created
March 31, 2016 14:16
-
-
Save zembutsu/e37ac9bc379bd501dc581bfa592ec5c5 to your computer and use it in GitHub Desktop.
Zabbix 3.0をDocker Composeで一度に実行する方法 ref: http://qiita.com/zembutsu/items/686b99be90d72688aee8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
zabbix-db: | |
image: zabbix/zabbix-db-mariadb | |
volumes: | |
- zabbix-db-storage:/var/lib/mysql | |
- backups:/backups | |
- /etc/localtime:/etc/localtime:ro | |
environment: | |
- MARIADB_USER=zabbix | |
- MARIADB_PASS=my_password | |
zabbix-server: | |
image: zabbix/zabbix-3.0:latest | |
depends_on: | |
- zabbix-db | |
ports: | |
- "80:80" | |
- "10051:10051" | |
volumes: | |
- /etc/localtime:/etc/localtime:ro | |
links: | |
- zabbix-db:zabbix.db | |
environment: | |
- ZS_DBHost=zabbix.db | |
- ZS_DBUser=zabbix | |
- ZS_DBPassword=my_password | |
volumes: | |
zabbix-db-storage: | |
driver: local | |
backups: | |
driver: local |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl -sSL https://get.docker.com/ | sh | |
# systemctl start docker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose | |
# chmod +x /usr/local/bin/docker-compose |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker exec \ | |
-ti zabbix3_zabbix-db_1 \ | |
/zabbix-backup/zabbix-mariadb-dump -u zabbix -p my_password -o /backups | |
Configuration: | |
- host: 127.0.0.1 (127.0.0.1) | |
- database: zabbix | |
- user: zabbix | |
- output: /backups | |
Fetching list of existing tables... | |
Starting table backups... | |
0%.....12%.....24%......36%.......48%.....60%.....72%......84%84%......96%.. | |
For the following large tables only the schema (without data) was stored: | |
- acknowledges | |
- alerts | |
- auditlog | |
- auditlog_details | |
- events | |
- history | |
- history_log | |
- history_str | |
- history_text | |
- history_uint | |
- trends | |
- trends_uint | |
Compressing backup file... | |
Backup Completed: | |
/backups/zabbix_cfg_127.0.0.1_20160331-2302_db-3.0.0.sql.gz |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker exec \ | |
-ti zabbix3_zabbix-db_1 \ | |
bash -c "\ | |
mysqldump -u zabbix -pmy_password zabbix | \ | |
bzip2 -cq9 > /backups/zabbix_db_dump_$(date +%Y-%m-%d-%H.%M.%S).sql.bz2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker inspect zabbix3_zabbix-db_1 | |
(略) | |
"Mounts": [ | |
(略) | |
{ | |
"Name": "zabbix3_backups", | |
"Source": "/var/lib/docker/volumes/zabbix3_backups/_data", | |
"Destination": "/backups", | |
"Driver": "local", | |
"Mode": "rw", | |
"RW": true, | |
"Propagation": "rprivate" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls -al /var/lib/docker/volumes/zabbix3_backups/_data | |
total 6404 | |
drwxr-xr-x 2 root root 4096 Mar 31 23:08 . | |
drwxr-xr-x 3 root root 4096 Mar 31 20:58 .. | |
-rw-r--r-- 1 root root 1048474 Mar 31 23:02 zabbix_cfg_127.0.0.1_20160331-2302_db-3.0.0.sql.gz | |
-rw-r--r-- 1 root root 1048472 Mar 31 23:07 zabbix_cfg_localhost_20160331-2307_db-3.0.0.sql.gz | |
-rw-r--r-- 1 root root 1048482 Mar 31 23:08 zabbix_cfg_localhost_20160331-2308_db-3.0.0.sql.gz | |
-rw-r--r-- 1 root root 1131890 Mar 31 23:05 zabbix_db_dump_2016-03-31-23.05.45.sql.bz2 | |
-rw-r--r-- 1 root root 1131862 Mar 31 23:06 zabbix_db_dump_2016-03-31-23.06.29.sql.bz2 | |
-rw-r--r-- 1 root root 1131765 Mar 31 23:06 zabbix_db_dump_2016-03-31-23.06.37.sql.bz2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose version | |
docker-compose version 1.6.2, build 4d72027 | |
docker-py version: 1.7.2 | |
CPython version: 2.7.9 | |
OpenSSL version: OpenSSL 1.0.1e 11 Feb 2013 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir zabbix3 | |
$ cd zabbix3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose pull | |
Pulling zabbix-db (zabbix/zabbix-db-mariadb:latest)... | |
latest: Pulling from zabbix/zabbix-db-mariadb | |
a3ed95caeb02: Pull complete | |
196355c4b639: Pull complete | |
39ac25574789: Pull complete | |
a71e49d71685: Pull complete | |
Digest: sha256:659022fb65ec3843472c42d9722f3bf65f8f9f13187563c7d8e73c6a5ff5c4c1 | |
Status: Downloaded newer image for zabbix/zabbix-db-mariadb:latest | |
Pulling zabbix-server (zabbix/zabbix-3.0:latest)... | |
latest: Pulling from zabbix/zabbix-3.0 | |
a3ed95caeb02: Already exists | |
196355c4b639: Already exists | |
e83e94d3bc97: Pull complete | |
a586f6047ba2: Pull complete | |
b33c7f8446ba: Pull complete | |
92aa3f0ccb13: Pull complete | |
Digest: sha256:2585752c00c8e784f899bef3fef0e1092574ca72396716cdd39a3cd75148b56d | |
Status: Downloaded newer image for zabbix/zabbix-3.0:latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker images | |
REPOSITORY TAG IMAGE ID CREATED SIZE | |
zabbix/zabbix-3.0 latest 7e2d6c4d3b1d 7 hours ago 719.6 MB | |
zabbix/zabbix-db-mariadb latest 85539c34211e 35 hours ago 554.4 MB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose up -d | |
Creating network "zabbix3_default" with the default driver | |
Creating volume "zabbix3_zabbix-db-storage" with local driver | |
Creating volume "zabbix3_backups" with local driver | |
Creating zabbix3_zabbix-db_1 | |
Creating zabbix3_zabbix-server_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose ps | |
Name Command State Ports | |
------------------------------------------------------------------------------------- | |
zabbix3_zabbix-db_1 /run.sh Up 3306/tcp | |
zabbix3_zabbix- /config/bootstrap.s Up 0.0.0.0:10051->1005 | |
server_1 h 1/tcp, 10052/tcp, | |
162/udp, | |
0.0.0.0:80->80/tcp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ docker-compose logs | |
(略) | |
zabbix-server_1 | [WARNING 20:58:27] Zabbix database doesn't exist. Installing and importing default settings | |
zabbix-server_1 | | |
zabbix-server_1 | [LOG 20:58:27] Database and user created, importing default SQL | |
zabbix-server_1 | | |
zabbix-server_1 | [LOG 20:58:38] Import finished, starting | |
zabbix-server_1 | [LOG 20:58:38] Starting Zabbix version 3.0.1 | |
(略) | |
zabbix-db_1 | ======================================================================== | |
zabbix-db_1 | You can now connect to this MariaDB Server using: | |
zabbix-db_1 | mysql -uzabbix -pmy_password -h<host> | |
zabbix-db_1 | | |
zabbix-db_1 | For security reasons, you might want to change the above password. | |
zabbix-db_1 | The 'root' user has no password but only allows local connections | |
zabbix-db_1 | ======================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment