diff --git a/extras/docker/Dockerfile b/extras/docker/Dockerfile index 9db256ea17..f91fa55d1b 100644 --- a/extras/docker/Dockerfile +++ b/extras/docker/Dockerfile @@ -20,22 +20,30 @@ RUN cd /tmp/pandorafms/pandora_agents/unix && \ # Set the server's name in Apache's configuration file to avoid warnings. RUN sed -i "s/#ServerName.*/ServerName localhost:80/" /etc/httpd/conf/httpd.conf +COPY my.cnf /etc/my.cnf + # Install the Pandora FMS Console. -RUN service mysqld start && \ -/usr/bin/mysqladmin -u root password "$DB_PASS" && \ -service httpd start && \ -cp -r /tmp/pandorafms/pandora_console /var/www/html && \ -chown -R apache.apache /var/www/html/pandora_console/ && \ -python /tmp/pandorafms/tests/install_console.py +RUN rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql && \ + mkdir -p /var/log/mysql/ && chown mysql. /var/log/mysql && \ + chown mysql. -R /var/lib/mysql && \ + sudo -u mysql mysqld --initialize --explicit_defaults_for_timestamp && \ + sudo -u mysql mysqld --daemonize & \ + sleep 15 && \ + mysql_default_pass=$(cat /var/log/mysql/mysqld.log | grep "temporary password" | awk '{print $NF}') && \ + mysqladmin -u root -p"$mysql_default_pass" --user=root password 'pandora' && \ + httpd -k start && \ + cp -r /tmp/pandorafms/pandora_console /var/www/html && \ + chown -R apache.apache /var/www/html/pandora_console/ && \ + python /tmp/pandorafms/tests/install_console.py # Redirect HTTP requests to / to the Pandora FMS Console. RUN echo '<meta http-equiv="refresh" content="0;url=/pandora_console">' > /var/www/html/index.html # Create the entrypoint script. RUN echo -e '#/bin/bash\n \ -service mysqld start &&\n \ -service httpd start &&\n \ -service crond start &&\n \ +sudo -u mysql mysqld --daemonize &&\n \ +httpd -k start &&\n \ +/usr/sbin/crond &&\n \ /etc/init.d/pandora_agent_daemon start && \ /etc/init.d/pandora_server start && \ tail -f /var/log/pandora/pandora_server.log' \ diff --git a/extras/docker/my.cnf b/extras/docker/my.cnf new file mode 100644 index 0000000000..e39bd8fea9 --- /dev/null +++ b/extras/docker/my.cnf @@ -0,0 +1,46 @@ +[mysqld] +pid-file=/var/run/mysqld/mysqld.pid +log-error=/var/log/mysql/mysqld.log +datadir=/var/lib/mysql +socket=/var/lib/mysql/mysql.sock +user=mysql +character-set-server=UTF8MB4 +skip-character-set-client-handshake +# Mysql optimizations for Pandora FMS +# Please check the documentation in http://pandorafms.com for better results + +max_allowed_packet = 32M +innodb_buffer_pool_size = 256M +innodb_lock_wait_timeout = 120 +innodb_file_per_table +innodb_flush_log_at_trx_commit = 2 +innodb_flush_method = O_DIRECT +innodb_log_file_size = 64M +innodb_log_buffer_size = 16M +#innodb_io_capacity = 100 +#thread_cache_size = 8 +thread_stack = 256K +max_connections = 130 + +key_buffer_size=128K +read_buffer_size=128K +read_rnd_buffer_size=128K +sort_buffer_size=256K +join_buffer_size=2M + +sql_mode="" + +# testing +#innodb_lru_scan_depth = 256 +#innodb_page_cleaners = 8 +#innodb_buffer_pool_instances = 4 + +skip_name_resolve +innodb=1 +thread_cache_size = 120 +table_definition_cache = 4000 +table_open_cache = 4000 + +[mysqld_safe] +log-error=/var/log/mysql/mysqld.log +pid-file=/var/run/mysqld/mysqld.pid