User Tools

Site Tools


informatica:servidor_internet_2009_debian_10_part_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
informatica:servidor_internet_2009_debian_10_part_2 [2022/08/09 16:39]
miquel created
informatica:servidor_internet_2009_debian_10_part_2 [2022/08/10 14:43] (current)
miquel [Fix Bumblebee problems]
Line 1: Line 1:
 +====== Servidor web/dades ====== 
 +
 ===== Actualització a Debian 10.12 "buster" - Part 2 - Agost de 2022 ===== ===== Actualització a Debian 10.12 "buster" - Part 2 - Agost de 2022 =====
  
Line 114: Line 116:
 </file> </file>
  
 +==== Fix Bumblebee problems ====
 +
 +El programa Bumblebee (servidor de reserves) dóna diversos errors.
 +
 +<file>
 +# tail /var/log/apache2/error.log
 +[Sun Aug 07 12:20:40.886047 2022] [:error] [pid 15212] [client 158.109.48.53:59698] PHP Fatal error:  Call to undefined function mb_detect_encoding() in /opt/bmbee-117/system-inc/php-gettext
 +/gettext.inc on line 102, referer: http://sermn.uab.cat/wiki/doku.php
 +[Sun Aug 07 12:47:46.637033 2022] [:error] [pid 15210] [client 66.249.65.129:56948] PHP Fatal error:  Call to undefined function mb_detect_encoding() in /opt/bmbee-117/system-inc/php-gettext
 +/gettext.inc on line 102
 +</file>
 +
 +Una consulta a Google indica que [[https://stackoverflow.com/questions/17204437/fatal-error-call-to-undefined-function-mb-detect-encoding | aquest error es deu a que no s'ha instal·lat l'extensió de PHP //mbstring//]] (que no s'instal·la per defecte). Instal·lo l'extensió, reinicio el servidor apache,
 +
 +<file>
 +# apt search php5* | grep mbstring
 +
 +WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
 +
 +php-mbstring/buster,now 2:8.1+92+0~20220117.43+debian10~1.gbpe0d14e all [installed,automatic]
 +php5.6-mbstring/buster 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64
 +php5.6-mbstring-dbgsym/buster 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd amd64
 +  debug symbols for php5.6-mbstring
 +...
 +
 +# apt install php5.6-mbstring
 +Reading package lists... Done
 +Building dependency tree
 +Reading state information... Done
 +The following NEW packages will be installed:
 +  php5.6-mbstring
 +0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
 +Need to get 468 kB of archives.
 +After this operation, 1,514 kB of additional disk space will be used.
 +Get:1 https://packages.sury.org/php buster/main amd64 php5.6-mbstring amd64 5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd [468 kB]
 +Fetched 468 kB in 0s (2,757 kB/s)   
 +Selecting previously unselected package php5.6-mbstring.
 +(Reading database ... 226308 files and directories currently installed.)
 +Preparing to unpack .../php5.6-mbstring_5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd_amd64.deb ...
 +Unpacking php5.6-mbstring (5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd) ...
 +Setting up php5.6-mbstring (5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd) ...
 +
 +Creating config file /etc/php/5.6/mods-available/mbstring.ini with new version
 +Processing triggers for libapache2-mod-php5.6 (5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd) ...
 +Processing triggers for php5.6-cli (5.6.40-60+0~20220627.67+debian10~1.gbp1f7ffd) ...
 +
 +# apache2ctl restart
 +</file>
 +
 +i el problema sembla haver-se resolt, però quan intento crear una reserva surt un nou missatge d'error,
 +
 +<file>
 +2022-08-07 11:47:50 15798 [Warning] Aborted connection 15798 to db: 'bmbdb117' user: 'sermnadmin' host: 'localhost' (Got timeout reading communication packets)
 +</file>
 +
 +Una cerca a Google indica que [[https://dba.stackexchange.com/questions/205398/mysql-got-timeout-reading-communication-packets-when-reading-federated-table | aquest error està relacionat amb la variable "wait_timeout",]] que té un valor per defecte de 40 segons que podria ser insuficient en el nostre cas.
 +
 +La solució és assignar un nou valor a aquesta variable a la secció ''[mysqld]'' del fitxer de configuració,
 +
 +<file>
 +# /etc/mysql/mariadb.conf.d
 +# cp 50-server.cnf 50-server.cnf.BKUP-20220807
 +# vi 50-server.cnf
 +</file>
 +
 +i afegir les línies
 +
 +<code diff>
 +# diff 50-server.cnf 50-server.cnf.BKUP-20220807
 +45,53d44
 +< # * Local Tuning - MCE - 20220807
 +< #
 +< # MySQL Got timeout reading communication packets when reading federated table
 +< # https://dba.stackexchange.com/questions/205398/mysql-got-timeout-reading-communication-packets-when-reading-federated-table
 +< #
 +< wait_timeout=3600       # from 40 seconds may reduce handler_rollback count
 +<
 +<
 +< #
 +73,77c64,68
 +< slow_query_log_file    = /var/log/mysql/mariadb-slow.log
 +< long_query_time        = 10
 +< log_slow_rate_limit    = 1000
 +< log_slow_verbosity     = query_plan
 +< log-queries-not-using-indexes
 +---
 +> #slow_query_log_file    = /var/log/mysql/mariadb-slow.log
 +> #long_query_time        = 10
 +> #log_slow_rate_limit    = 1000
 +> #log_slow_verbosity     = query_plan
 +> #log-queries-not-using-indexes
 +</code>
 +
 +Referències:
 +
 +  * [[https://dba.stackexchange.com/questions/205398/mysql-got-timeout-reading-communication-packets-when-reading-federated-table | MySQL Got timeout reading communication packets when reading federated table - Database Administrators Stack Exchange.]]    
 +  * [[https://support.cpanel.net/hc/en-us/articles/1500012855541-MySQL-error-log-says-Got-timeout-reading-communication-packets- | MySQL error log says "Got timeout reading communication packets" ? cPanel]]
 +  * [[https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout | MySQL :: MySQL 8.0 Reference Manual :: 5.1.8 Server System Variables.]]
 +
 +Amb aquest canvi, desapareix aquest error, però llavors apareix un de nou,
 +
 +<file>
 +[Sun Aug 07 16:04:47.456947 2022] [:error] [pid 25390] [client 158.109.48.53:60540] PHP Fatal error:  Call to undefined function T_() in /opt/bmbee-117/inc/db.php on line 46, referer: http:/
 +/sermn.uab.cat/reserves/index.php?action=book
 +[Sun Aug 07 16:04:55.344007 2022] [:error] [pid 25403] [client 158.109.48.53:60544] PHP Fatal error:  Call to undefined function T_() in /opt/bmbee-117/inc/db.php on line 46, referer: http:/
 +/sermn.uab.cat/reserves/index.php?action=book
 +</file>
 +
 +que sembla indicar que hi ha un problema d'accés a la base de dades, però des de la línia de comandes em puc connectar:
 +
 +<file>
 +# mariadb bmbdb117 -u sermnadmin -p 
 +Enter password:
 +Reading table information for completion of table and column names
 +You can turn off this feature to get a quicker startup with -A
 +
 +Welcome to the MariaDB monitor.  Commands end with ; or \g.
 +Your MariaDB connection id is 670
 +Server version: 10.3.34-MariaDB-0+deb10u1 Debian 10
 +
 +Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 +
 +Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 +
 +MariaDB [bmbdb117]> show tables;
 ++---------------------------+
 +| Tables_in_bmbdb117        |
 ++---------------------------+
 +| ACTIVE_USERS              |
 +| bookings                  |
 +| consumables               |
 +| consumables_use           |
 +| costs                     |
 +| groups                    |
 +| instrumentclass           |
 +| instruments               |
 +| permissions               |
 +| permissions.BKUP-20210517 |
 +| permissions.BKUP-20210607 |
 +| permissions.BKUP-20211215 |
 +| projectgroups             |
 +| projectrates              |
 +| projects                  |
 +| roleusers                 |
 +| userclass                 |
 +| usergroups                |
 +| userprojects              |
 +| users                     |
 +| users.BKUP-20210914       |
 ++---------------------------+
 +21 rows in set (0.000 sec)
 +
 +MariaDB [bmbdb117]> describe bookings ;
 ++------------+----------------------+------+-----+---------+----------------+
 +| Field      | Type                 | Null | Key | Default | Extra          |
 ++------------+----------------------+------+-----+---------+----------------+
 +| id         | int(10) unsigned     | NO   | PRI | NULL    | auto_increment |
 +| bookwhen   | datetime             | NO       | NULL    |                |
 +| duration   | time                 | NO       | NULL    |                |
 +| instrument | smallint(5) unsigned | NO       | NULL    |                |
 +| bookedby   | smallint(5) unsigned | NO       | NULL    |                |
 +| userid     | smallint(5) unsigned | NO       | NULL    |                |
 +| projectid  | smallint(5) unsigned | NO       | NULL    |                |
 +| discount   | float                | YES  |     | 0                      |
 +| ip         | char(16)             | YES  |     | NULL    |                |
 +| comments   | text                 | YES  |     | NULL    |                |
 +| log        | text                 | YES  |     | NULL    |                |
 +| deleted    | tinyint(1)           | YES  |     | 0                      |
 ++------------+----------------------+------+-----+---------+----------------+
 +12 rows in set (0.001 sec)
 +
 +MariaDB [bmbdb117]> quit;
 +Bye
 +</file>
 +
 +Per eliminar l'error associat a la funció "T_(", l'elimino provisionalment del codi,
 +
 +<code diff>
 +# diff db.php db.php.BKUP-20220807
 +46c46
 +<   $errmsg  = sprintf(('<p>Sorry, I couldn\'t connect to the database, so there\'s nothing I can presently do. This could be due to a booking system misconfiguration, or a failure of the da
 +tabase subsystem.</p><p>If this persists, please contact the <a href="mailto:%s">booking system administrator</a>.</p>'), $conf->AdminEmail);
 +---
 +>   $errmsg  = sprintf(T_('<p>Sorry, I couldn\'t connect to the database, so there\'s nothing I can presently do. This could be due to a booking system misconfiguration, or a failure of the 
 +database subsystem.</p><p>If this persists, please contact the <a href="mailto:%s">booking system administrator</a>.</p>'), $conf->AdminEmail);
 +</code>
 +
 +intento crear una reserva sense èxit, i comprovo el missatge d'error al registre de MariaDB:
 +
 +<file>
 +2022-08-07 18:36:08 590 [Warning] Aborted connection 590 to db: 'bmbdb117' user: 'sermnadmin' host: 'localhost' (Got an error reading communication packets)
 +</file>
 +
 +Una consulta a Google indica que [[https://www.percona.com/blog/2016/05/16/mysql-got-an-error-reading-communication-packet-errors/ | aquest error té relació amb la variable [[https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_max_allowed_packet | max_allowed_packet]].
 +
 +Per intentar resoldre l'error, incremento el valor de la variable,
 +
 +<code diff>
 +# diff 50-server.cnf 50-server.cnf.BKUP-20220807
 +34c34
 +< max_allowed_packet     = 64M
 +---
 +> #max_allowed_packet     = 16M
 +45,53d44
 +< # * Local Tuning - MCE - 20220807
 +< #
 +< # MySQL Got timeout reading communication packets when reading federated table
 +< # https://dba.stackexchange.com/questions/205398/mysql-got-timeout-reading-communication-packets-when-reading-federated-table
 +< #
 +< wait_timeout=3600       # from 40 seconds may reduce handler_rollback count
 +<
 +<
 +< #
 +73,77c64,68
 +< slow_query_log_file    = /var/log/mysql/mariadb-slow.log
 +< long_query_time        = 10
 +< log_slow_rate_limit    = 1000
 +< log_slow_verbosity     = query_plan
 +< log-queries-not-using-indexes
 +---
 +> #slow_query_log_file    = /var/log/mysql/mariadb-slow.log
 +> #long_query_time        = 10
 +> #log_slow_rate_limit    = 1000
 +> #log_slow_verbosity     = query_plan
 +> #log-queries-not-using-indexes
 +</code>
 +
 +Però el problema persisteix.
 +
 +Finalment, després d'activar les opcions per mostrar les comandes SQL i altres avisos i errors al programa de reserves:
 +
 +<code php>
 +[error_handling]
 +; Browser error stream:
 +; Set these to 0 for production systems, 1 for development/debugging
 +; Show all SQL statements in the browser
 +; VerboseSQL = 0
 +VerboseSQL = 1
 +; Show all PHP warnings (such as uninitialised variables)
 +AllWarnings = 1
 +; Show a warning if install folder still is in the server location
 +ignore_installer = 1
 +; Show all GET and POST data provided by the browser
 +; VerboseData = 0
 +VerboseData = 0
 +; Use the dBug class from http://dbug.ospinto.com/ to pretty print error
 +; and debug output (designed for developer use only; you need to put dBug.php
 +; somewhere in your include path for this to work).
 +UseDBug = 0
 +</code>
 +
 +aconsegueixo veure que l'error està relacionat amb una configuració més estricta de MariaDB respecte versions anteriors, configuració que no és compatible amb la versió actual del programa. Després de provar a modificar la configuració del gestor de la base de dades sense èxit,
 +
 +  * [[https://mariadb.com/kb/en/sql-mode/ | MariaDB - SQL_MODE]]
 +  * [[https://mariadb.com/kb/en/old-mode/ | MariaDB - OLD_MODE]]
 +
 +trobo que la forma més fàcil de resoldre **provisionalment** el problema, és fer ús de l'opció [[https://mariadb.com/kb/en/ignore/ | IGNORE]] a la comanda INSERT de forma que,
 +
 +<blockquote>
 +Normally INSERT stops and rolls back when it encounters an error.
 +
 +By using the IGNORE keyword all errors are converted to warnings, which will not stop inserts of additional rows.
 +
 +The IGNORE and DELAYED options are ignored when you use ON DUPLICATE KEY UPDATE.
 +
 +Prior to MySQL and MariaDB 5.5.28, no warnings were issued for duplicate key errors when using IGNORE. You can get the old behavior if you set OLD_MODE to NO_DUP_KEY_WARNINGS_WITH_IGNORE.
 +<cite>
 +([[https://mariadb.com/kb/en/insert-ignore/ | INSERT IGNORE]])
 +</cite>
 +</blockquote>
 +
 +Per això cal modificar el fitxer ''/opt/bmbee-117/inc/formslib/dbrow.php'',
 +
 +<code diff>
 +# diff dbrow.php dbrow.php.BKUP-20220807
 +252c252
 +<         $q = 'INSERT IGNORE INTO '.$conf->value('database', 'tableprefix').$this->table.' SET '.$vals;
 +---
 +>         $q = 'INSERT '.$conf->value('database', 'tableprefix').$this->table.' SET '.$vals;
 +</code>
 +
 +Després de fer el canvi, comprovo que es poden crear reserves i un nou compte d'usuari, i assumeixo que la resta de comandes ''INSERT'' també funcionaran correctament.
  
 +<WRAP box >
 +**Continuació:** [[informatica:servidor_internet_2009_debian_10_part_3 | Actualització a Debian 10.12 - Part 3]]
 +</WRAP>
informatica/servidor_internet_2009_debian_10_part_2.1660055976.txt.gz · Last modified: 2022/08/09 16:39 by miquel