Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zabbix database doesn't exist. Installing and importing default settings #27

Closed
vovanmozg opened this issue Feb 2, 2016 · 6 comments
Closed

Comments

@vovanmozg
Copy link

I try running zabbix container. It does successfully. But after restart container all of the data disappeared

There is part of the log:

zabbix-db_1         | 160202 16:09:56 [Note] /usr/sbin/mysqld: ready for connections.
zabbix-db_1         | Version: '10.0.23-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
zabbix-db_1         | 160202 16:09:56 [Note] /usr/sbin/mysqld: ready for connections.
zabbix-db_1         | Securing and tidying DB...
zabbix-db_1         | Securing and tidying DB... Done!
zabbix-db_1         | Showing DB status...
zabbix-db_1         |
zabbix-db_1         | --------------
zabbix-db_1         | mysql  Ver 15.1 Distrib 10.0.23-MariaDB, for Linux (x86_64) using readline 5.1
zabbix-db_1         |
zabbix-db_1         | Connection id:        6
zabbix-db_1         | Current database:
zabbix-db_1         | Current user:     root@127.0.0.1
zabbix-db_1         | SSL:          Not in use
zabbix-db_1         | Current pager:        stdout
zabbix-db_1         | Using outfile:        ''
zabbix-db_1         | Using delimiter:  ;
zabbix-db_1         | Server:           MariaDB
zabbix-db_1         | Server version:       10.0.23-MariaDB MariaDB Server
zabbix-db_1         | Protocol version: 10
zabbix-db_1         | Connection:       localhost via TCP/IP
zabbix-db_1         | Server characterset:  utf8
zabbix-db_1         | Db     characterset:  utf8
zabbix-db_1         | Client characterset:  utf8
zabbix-db_1         | Conn.  characterset:  utf8
zabbix-db_1         | TCP port:     3306
zabbix-db_1         | Uptime:           1 sec
zabbix-db_1         |
zabbix-db_1         | Threads: 1  Questions: 16  Slow queries: 1  Opens: 1  Flush tables: 1  Open tables: 64  Queries per second avg: 16.000
zabbix-db_1         | --------------
zabbix-db_1         |
zabbix-db_1         | Creating DB admin user...
zabbix-db_1         |
zabbix-db_1         | => Creating MariaDB user 'zabbix' with 'my_password' password.
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         | ========================================================================
zabbix-server_1     | [LOG 16:09:58] Database server is available
zabbix-server_1     | [LOG 16:09:58] Checking if database exists or SQL import is required
zabbix-server_1     | [WARNING 16:09:58] Zabbix database doesn't exist. Installing and importing default settings
zabbix-server_1     |
zabbix-server_1     | [LOG 16:09:58] Database and user created, importing default SQL
zabbix-server_1     |
zabbix-server_1     | [LOG 16:10:19] Import finished, starting
zabbix-server_1     | [LOG 16:10:20] Starting Zabbix version 3.0.0rc1
zabbix-server_1     | 2016
zabbix-server_1     | 2016-02-02 16:10:24,452 CRIT Supervisor running as root (no user in config file)
zabbix-server_1     | 2016-02-02 16:10:24,452 WARN Included extra file "/etc/supervisor.d/zabbix-server.conf" during parsing

I login to container
docker exec -it zabbix30_zabbix-server_1 bash -c "export TERM=xterm; exec bash"

and try run
mysqladmin -hzabbix.db -uzabbix -pmy_password status
and got
Uptime: 968 Threads: 23 Questions: 5744 Slow queries: 1165 Opens: 550 Flush tables: 1 Open tables: 127 Queries per second avg: 5.933

It looks like I'm working with temporary base

What am I doing wrong?

Dockerfile and docker-compose.yml is default:

docker-compose.yml:
https://github.com/zabbix/zabbix-community-docker/blob/360e7f9bada79d794f1e91cf780f6a7862063b26/Dockerfile/zabbix-3.0/docker-compose.yml

Dockerfile:
https://github.com/zabbix/zabbix-community-docker/blob/e5c550404c554ce9ef6da51ebee525e7ea3eef5a/Dockerfile/zabbix-3.0/Dockerfile

Ubuntu 14.04

@jangaraj
Copy link
Member

jangaraj commented Feb 2, 2016

It looks like I'm working with temporary base

No, persistent storage(volume) is used for DB in your case:

zabbix-db-storage:
  image: busybox:latest
  volumes:
    - /var/lib/mysql
...
  volumes_from:
    - zabbix-db-storage

DB is populated automatically during first start (zabbix/zabbix-db-mariadb is empty mysql server):

zabbix-server_1     | [LOG 16:09:58] Checking if database exists or SQL import is required
zabbix-server_1     | [WARNING 16:09:58] Zabbix database doesn't exist. Installing and importing default settings
zabbix-server_1     |
zabbix-server_1     | [LOG 16:09:58] Database and user created, importing default SQL
zabbix-server_1     |
zabbix-server_1     | [LOG 16:10:19] Import finished, starting

Next run Zabbix DB is detected, so DB import won't be executed,

zabbix-server_1     | [LOG 16:49:20] Checking if database exists or SQL import is required
zabbix-server_1     | [LOG 16:49:20] Zabbix database exists, starting server

Test it, but it should be OK.

@jangaraj jangaraj closed this as completed Feb 2, 2016
@vovanmozg
Copy link
Author

yes, config contains a section that specifies to use a persistent storage

zabbix-db-storage:
  image: busybox:latest
  volumes:
    - /var/lib/mysql
...
  volumes_from:
    - zabbix-db-storage

but after stop and start container changes are not saved.

$ docker inspect zabbix30_zabbix-db_1

[
{
    "Id": "380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705",
    "Created": "2016-02-02T20:21:32.309697083Z",
    "Path": "/run.sh",
    "Args": [],
    "State": {
        "Status": "running",
        "Running": true,
        "Paused": false,
        "Restarting": false,
        "OOMKilled": false,
        "Dead": false,
        "Pid": 25422,
        "ExitCode": 0,
        "Error": "",
        "StartedAt": "2016-02-02T20:21:32.750592691Z",
        "FinishedAt": "0001-01-01T00:00:00Z"
    },
    "Image": "a9002ccad7ef2ff66db334a61f8d274accc8189d1815ac5cbb9d19e7d26ef10d",
    "ResolvConfPath": "/mnt/sdb/var/lib/docker/containers/380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705/resolv.conf",
    "HostnamePath": "/mnt/sdb/var/lib/docker/containers/380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705/hostname",
    "HostsPath": "/mnt/sdb/var/lib/docker/containers/380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705/hosts",
    "LogPath": "/mnt/sdb/var/lib/docker/containers/380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705/380f1e435635a94a006a7cbce3f097580c36d730949dbd68ea39507670dce705-json.log",
    "Name": "/zabbix30_zabbix-db_1",
    "RestartCount": 0,
    "Driver": "aufs",
    "ExecDriver": "native-0.2",
    "MountLabel": "",
    "ProcessLabel": "",
    "AppArmorProfile": "",
    "ExecIDs": [
        "b5460cd0b9a60a4d5c21c8145ec9675050e8164c7043954b5dbaa51ce8a20019"
    ],
    "HostConfig": {
        "Binds": [
            "/backups:/backups:rw"
        ],
        "ContainerIDFile": "",
        "LxcConf": null,
        "Memory": 0,
        "MemoryReservation": 0,
        "MemorySwap": 0,
        "KernelMemory": 0,
        "CpuShares": 0,
        "CpuPeriod": 0,
        "CpusetCpus": "",
        "CpusetMems": "",
        "CpuQuota": 0,
        "BlkioWeight": 0,
        "OomKillDisable": false,
        "MemorySwappiness": null,
        "Privileged": false,
        "PortBindings": {},
        "Links": null,
        "PublishAllPorts": false,
        "Dns": null,
        "DnsOptions": null,
        "DnsSearch": null,
        "ExtraHosts": null,
        "VolumesFrom": [
            "d6e3c4c2943f961eeff93951e976577def1ff1c116b1850f8fad835e86d72b42:rw"
        ],
        "Devices": null,
        "NetworkMode": "default",
        "IpcMode": "",
        "PidMode": "",
        "UTSMode": "",
        "CapAdd": null,
        "CapDrop": null,
        "GroupAdd": null,
        "RestartPolicy": {
            "Name": "",
            "MaximumRetryCount": 0
        },
        "SecurityOpt": null,
        "ReadonlyRootfs": false,
        "Ulimits": null,
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "CgroupParent": "",
        "ConsoleSize": [
            0,
            0
        ],
        "VolumeDriver": ""
    },
    "GraphDriver": {
        "Name": "aufs",
        "Data": null
    },
    "Mounts": [
        {
            "Name": "6e72af9cab24e42db9eb790d2c18ac2aa05f87d53332874f6dd3cebec480cf1a",
            "Source": "/mnt/sdb/var/lib/docker/volumes/6e72af9cab24e42db9eb790d2c18ac2aa05f87d53332874f6dd3cebec480cf1a/_data",
            "Destination": "/var/lib/mysql",
            "Driver": "local",
            "Mode": "",
            "RW": true
        },
        {
            "Source": "/backups",
            "Destination": "/backups",
            "Mode": "rw",
            "RW": true
        }
    ],
    "Config": {
        "Hostname": "380f1e435635",
        "Domainname": "",
        "User": "",
        "AttachStdin": false,
        "AttachStdout": false,
        "AttachStderr": false,
        "ExposedPorts": {
            "3306/tcp": {}
        },
        "Tty": false,
        "OpenStdin": false,
        "StdinOnce": false,
        "Env": [
            "MARIADB_PASS=my_password",
            "MARIADB_USER=zabbix",
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "DB_max_allowed_packet=64M",
            "DB_query_cache_size=0",
            "DB_query_cache_type=0",
            "DB_sync_binlog=0",
            "DB_innodb_buffer_pool_size=768M",
            "DB_innodb_log_file_size=128M",
            "DB_innodb_flush_method=O_DIRECT",
            "DB_innodb_old_blocks_time=1000",
            "DB_innodb_flush_log_at_trx_commit=0",
            "DB_open_files_limit=4096",
            "DB_max_connections=300",
            "TERM=xterm"
        ],
        "Cmd": [
            "/run.sh"
        ],
        "Image": "zabbix/zabbix-db-mariadb",
        "Volumes": {
            "/backups": {},
            "/var/lib/mysql": {}
        },
        "WorkingDir": "",
        "Entrypoint": null,
        "OnBuild": null,
        "Labels": {
            "build-date": "2015-12-23",
            "com.docker.compose.config-hash": "ec83508f0f6b96e66c9adabe802b133cddefa3d9a192332effdc939b3d7d4a32",
            "com.docker.compose.container-number": "1",
            "com.docker.compose.oneoff": "False",
            "com.docker.compose.project": "zabbix30",
            "com.docker.compose.service": "zabbix-db",
            "com.docker.compose.version": "1.6.0rc2",
            "license": "GPLv2",
            "name": "CentOS Base Image",
            "vendor": "CentOS"
        }
    },
    "NetworkSettings": {
        "Bridge": "",
        "SandboxID": "3502f1ee986152a62640175e8d69e3bb8eb74ab657a048a8e358e1703fb47b52",
        "HairpinMode": false,
        "LinkLocalIPv6Address": "",
        "LinkLocalIPv6PrefixLen": 0,
        "Ports": {
            "3306/tcp": null
        },
        "SandboxKey": "/var/run/docker/netns/3502f1ee9861",
        "SecondaryIPAddresses": null,
        "SecondaryIPv6Addresses": null,
        "EndpointID": "60ba1308592b9e9a401376d1377f30fd3dcf2866281c20097c8fe79cfd6246e3",
        "Gateway": "172.17.0.1",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,
        "IPAddress": "172.17.0.3",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "MacAddress": "02:42:ac:11:00:03",
        "Networks": {
            "bridge": {
                "EndpointID": "60ba1308592b9e9a401376d1377f30fd3dcf2866281c20097c8fe79cfd6246e3",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.3",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,
                "MacAddress": "02:42:ac:11:00:03"
            }
        }
    }
}
]

@jangaraj
Copy link
Member

jangaraj commented Feb 3, 2016

I don't understand. What did you change and what is expected result?

@vovanmozg
Copy link
Author

I'm sorry that I did not accurately describe the problem.

I pull zabbix images and did not modify any configs

i want to zabbix database stored on the host. Persistent storage (volume) is used for DB in docker-compose.yml:

zabbix-db-storage:
  image: busybox:latest
  volumes:
    - /var/lib/mysql
...
  volumes_from:
    - zabbix-db-storage

I ran zabbix-server container, go to URL http://zabbix and configure it (create host TEST) in zabbix admin panel.

I expect to files in /var/lib/mysql on host changed, but these files not change. Then i stopped the containers, removed them and start. I go to Zabbix admin panel, but there are not old settings (host TEST).

If I understand correctly my data must store in /var/lib/mysql on host. But data stored only in container

@jangaraj
Copy link
Member

jangaraj commented Feb 3, 2016

Then i stopped the containers, removed them and start.

Don't remove zabbix30_zabbix-db-storage_1 container and you will be fine.

If I understand correctly my data must store in /var/lib/mysql on host. But data stored only in container

Yes, you can store them in /var/lib/mysql on your host - but you need to configure it your docker-compose.yml file. Also now are stored data on your host, my example:

docker inspect zabbix30_zabbix-db-storage_1
...
    "Mounts": [
        {
            "Name": "3b48d36682826bcf00c4c29ca427848dc589e377b13114f6ba3b80504ff7aeae",
            "Source": "/mnt/sda1/var/lib/docker/volumes/3b48d36682826bcf00c4c29ca427848dc589e377b13114f6ba3b80504ff7aeae/_data",
            "Destination": "/var/lib/mysql",
            "Driver": "local",
            "Mode": "",
            "RW": true
        }
    ],
...
root@default:~# ls -lah /mnt/sda1/var/lib/docker/volumes/3b48d36682826bcf00c4c29ca427848dc589e377b13114f6ba3b80504ff7aeae/_data
total 340024
drwxr-xr-x    5 997      root        4.0K Feb  2 16:57 .
drwxr-xr-x    3 root     root        4.0K Feb  2 16:45 ..
-rw-rw----    1 997      995        16.0K Feb  2 16:57 aria_log.00000001
-rw-rw----    1 997      995           52 Feb  2 16:57 aria_log_control
-rw-r--r--    1 997      root        3.7K Feb  2 16:57 error.log
-rw-r--r--    1 997      root        2.0K Feb  2 16:47 error.log.old
-rw-rw----    1 997      995       128.0M Feb  2 16:57 ib_logfile0
-rw-rw----    1 997      995       128.0M Feb  2 16:47 ib_logfile1
-rw-rw----    1 997      995        76.0M Feb  2 16:57 ibdata1
-rw-rw----    1 997      995            0 Feb  2 16:47 multi-master.info
drwx------    2 997      root        4.0K Feb  2 16:47 mysql
drwx------    2 997      995         4.0K Feb  2 16:47 performance_schema
drwx------    2 997      995        12.0K Feb  2 16:48 zabbix

It's advance concept (volumes-from) of storing data in Docker world. It's not simple concept (volume), so don't be confused.

I recommend you to dig into documentation and guides how to use volumes in the Docker. Then you can implement concept, which will fit for your case and needs.

@vovanmozg
Copy link
Author

I figure out. I thought that the mysql data will be stored in /var/lib/mysql.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants