FHEM Forum

FHEM => Sonstiges => Thema gestartet von: Lucky2k12 am 25 September 2019, 09:16:08

Titel: [gelöst] DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 25 September 2019, 09:16:08
Hallo, Fortsetzungsthread von hier:
https://forum.fhem.de/index.php/topic,78630.msg977116.html#msg977116

Zitat von: DS_Starter am 24 September 2019, 23:49:21
Hallo miteinander,

ich habe mal ein bisschen was gelesen und vermute dass der Beitrag #133 von Lucky2k12 das Problem ist um das es momentan geht.
Das deutet darauf hin , dass DbLog bei dir im synchronen Modus läuft, was der Standard ist. Allerdings ist es auch unter diesen Umständen nicht in Ordnung dass die Werte auffällig sind.
Um mehr herauszubekommen setze im ersten Schritt bitte die Attribute:

showproctime = 1
showNotifyTime = 1


Wenn das gemacht ist führe bitte ein

set <name> configCheck

aus und poste mal die Ausgabe.
Das ist ein "Fliegenschiß"  ;)
Meine MariaDB auf einer VM mit 750M RAM verarbeitet 4000 gecachte Events innerhalb von 0.7136 Sekunden (im asynchronen Mode)

Um die Datenbank-Einstellungen selbst zu checken bietet sich das Script mysqltuner an.
Du kannst es installieren mit:

sudo apt-get install mysqltuner

Aufruf als root mit:

mysqltuner --user <DB-Adminuser> --pass <DB-Adminuser-Passwort>

Der Check bringt dann Hinweise was man an der DB-Konfiguration ändern sollte. Diese Dinge werden wahrscheinlich in der Datei
/etc/mysql/mariadb.conf.d/50-server.cnf

eingetragen. MariaDB inkludiert mehrere Verzeichnisse in denen Konfigurationsdateien sein können. Ausgangspunkt ist die
/etc/mysql/my.cnf. Dort steht drin welche Verzeichnisse durchsucht werden:

Danke Heiko, sehr viel versprechend.
Das probiere ich heute abend aus und berichte.
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 25 September 2019, 12:07:54
mariaDB und mysql benehmen sich im Inkludieren gleich, nur können eventuell die Verzeichnisnamen anders sein. /etc/mysql dagegen ist (eigentlich) immer gleich.

Bitte bei jeder Vorgeschlagenen Änderung die mysqltuner angibt, sich das optimum für "seinen" Server überlegen.

Wenn der Server z.B. mehr als mysql (MariaDB) und fhem macht, sollte man mit dem Speicher nicht so großzügig vorgehen, wie von mysqltuner gewünscht. Dafür ist dieses Toll auch für jeden mysql-Server, also unabhängig von fhem.
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 25 September 2019, 20:39:59
OK, hier kommen die Ergebnisse:

configCheck:

Result of version check

Used Perl version: 5.24.1
Used DBI (Database independent interface) version: 1.636
Used DBD (Database driver) version mysql: 4.041
Used DbLog version: 4.7.0.
Your local DbLog module is up to date.
Recommendation: No update of DbLog is needed.

Result of configuration read check

Connection parameter store type: file
Connection parameter: Connection -> mysql:database=fhem;host=192.168.178.101;port=3306, User -> userxxx, Password -> read o.k.

Result of connection check

Connection to database fhem successfully done.
Recommendation: settings o.k.

Result of encoding check

Encoding used by Client (connection): UTF8
Encoding used by DB fhem: UTF8
Recommendation: settings o.k.

Result of logmode check

Logmode of DbLog-device DBLogging is: synchronous
Recommendation: Switch DBLogging to the asynchronous logmode by setting the 'asyncMode' attribute. The advantage of this mode is to log events non-blocking.
There are attributes 'syncInterval' and 'cacheLimit' relevant for this working mode.
Please refer to commandref for further information about these attributes.

Result of plot generation method check

WEB: plotfork=1
Recommendation: settings o.k.

Result of table 'history' check

Column width set in DB history: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by DBLogging: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of table 'current' check

Column width set in DB current: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by DBLogging: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of check 'Search_Idx' availability

The index 'Search_Idx' is missing.
Recommendation: You can create the index by executing statement 'CREATE INDEX Search_Idx ON `history` (DEVICE, READING, TIMESTAMP) USING BTREE;'
Depending on your database size this command may running a long time.
Please make sure the device 'DBLogging' is operating in asynchronous mode to avoid FHEM from blocking when creating the index.
Note: If you have just created another index which covers the same fields and order as suggested (e.g. a primary key) you don't need to create the 'Search_Idx' as well !


Result of check 'Report_Idx' availability for DbRep-devices

At least one DbRep-device assigned to DBLogging is used, but the recommended index 'Report_Idx' is missing.
Recommendation: You can create the index by executing statement 'CREATE INDEX Report_Idx ON `history` (TIMESTAMP,READING) USING BTREE;'
Depending on your database size this command may running a long time.
Please make sure the device 'DBLogging' is operating in asynchronous mode to avoid FHEM from blocking when creating the index.
Note: If you have just created another index which covers the same fields and order as suggested (e.g. a primary key) you don't need to create the 'Report_Idx' as well !


mysqltuner:

>>  MySQLTuner 1.6.18 - Major Hayden <major@mhtx.net>
>>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
>>  Run with '--help' for additional options and output filtering

[--] Skipped version check for MySQLTuner script
[OK] Logged in using credentials passed on the command line
[OK] Currently running supported MySQL version 10.1.41-MariaDB-0+deb9u1
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Status: +Aria +CSV +InnoDB +MEMORY +MRG_MyISAM +MyISAM +PERFORMANCE_SCHEMA +SEQUENCE
[--] Data in InnoDB tables: 97M (Tables: 3)
[OK] Total fragmented tables: 0

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] User 'usrxxx@%' hasn't specific host restriction.
[!!] User 'root@%' hasn't specific host restriction.
[--] There are 612 basic passwords in the list.

-------- CVE Security Recommendations --------------------------------------------------------------
[OK] NO SECURITY CVE FOUND FOR YOUR VERSION

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 11h 10m 51s (49K q [1.233 qps], 4K conn, TX: 17M, RX: 3M)
[--] Reads / Writes: 19% / 81%
[--] Binary logging is disabled
[--] Physical Memory     : 3.3G
[--] Max MySQL memory    : 1.7G
[--] Other process memory: 1.7G
[--] Total buffers: 1.3G global + 2.8M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 1.4G (40.84% of installed RAM)
[OK] Maximum possible memory usage: 1.7G (51.44% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (461/49K)
[OK] Highest usage of available connections: 14% (22/151)
[OK] Aborted connections: 0.00%  (0/4851)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache efficiency: 0.4% (8 cached / 2K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 1% (22 temp sorts / 1K sorts)
[OK] No joins without indexes
[OK] Temporary tables created on disk: 0% (1 on disk / 8K total)
[OK] Thread cache hit rate: 95% (204 created / 4K connections)
[OK] Table cache hit rate: 78% (30 open / 38 opened)
[OK] Open file limit used: 0% (25/4K)
[OK] Table locks acquired immediately: 100% (10K immediate / 10K locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 2 thread(s).
[--] Using default value is good enough for your version (10.1.41-MariaDB-0+deb9u1)

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (3M used / 16M cache)
[OK] Key buffer size / total MyISAM indexes: 16.0M/123.0K

-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[OK] Aria pagecache hit rate: 98.3% (58 cached / 1 reads)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[OK] InnoDB buffer pool / data size: 1.0G/97.3M
[!!] InnoDB buffer pool <= 1G and innodb_buffer_pool_instances(!=1).
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (1025862227 hits/ 1025862920 total)
[!!] InnoDB Write Log efficiency: 84.25% (54288 hits/ 64440 total)
[OK] InnoDB log waits: 0.00% (0 waits / 10152 writes)

-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.

-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] This is a standalone server.

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Restrict Host for user@% to user@SpecificDNSorIp
    MySQL started within last 24 hours - recommendations may be inaccurate
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
Variables to adjust:
    query_cache_limit (> 1M, or use smaller result sets)
    innodb_buffer_pool_instances (=1)



Ich werde jetzt auf asynchron umstellen und die Indices neu anlegen, ok?

Edit:
Gesagt, getan, nun meckert er nix mehr an:

Result of version check

Used Perl version: 5.24.1
Used DBI (Database independent interface) version: 1.636
Used DBD (Database driver) version mysql: 4.041
Used DbLog version: 4.7.0.
Your local DbLog module is up to date.
Recommendation: No update of DbLog is needed.

Result of configuration read check

Connection parameter store type: file
Connection parameter: Connection -> mysql:database=fhem;host=192.168.178.101;port=3306, User -> usrxxx, Password -> read o.k.

Result of connection check

Connection to database fhem successfully done.
Recommendation: settings o.k.

Result of encoding check

Encoding used by Client (connection): UTF8
Encoding used by DB fhem: UTF8
Recommendation: settings o.k.

Result of logmode check

Logmode of DbLog-device DBLogging is: asynchronous
Recommendation: settings o.k.

Result of plot generation method check

WEB: plotfork=1
Recommendation: settings o.k.

Result of table 'history' check

Column width set in DB history: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by DBLogging: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of table 'current' check

Column width set in DB current: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by DBLogging: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of check 'Search_Idx' availability

Index 'Search_Idx' exists and contains recommended fields 'DEVICE', 'TIMESTAMP', 'READING'.
Recommendation: settings o.k.

Result of check 'Report_Idx' availability for DbRep-devices

At least one DbRep-device assigned to DBLogging is used. Index 'Report_Idx' exists and contains recommended fields 'TIMESTAMP', 'READING'.
Recommendation: settings o.k.



FHEM reagiert jetzt wieder, load ist bei 1.5,
allerdings "sql_processing_time 7.3589" gibt mir zu denken.

iotop -a:

Total DISK READ :       0.00 B/s | Total DISK WRITE :       0.00 B/s
Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s
  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND
  245 be/3 root          0.00 B    300.00 K  0.00 % 38.16 % [jbd2/sda1-8]
20188 be/4 mysql         0.00 B      0.00 B  0.00 % 20.60 % mysqld
7939 be/4 fhem          0.00 B    348.00 K  0.00 %  9.78 % perl fhem.pl fhem.cfg
20200 be/4 mysql         0.00 B   1376.00 K  0.00 %  9.41 % mysqld
20183 be/4 mysql         0.00 B      0.00 B  0.00 %  7.62 % mysqld
20196 be/4 mysql         0.00 B     40.00 K  0.00 %  5.86 % mysqld
22828 be/4 root          0.00 B      0.00 B  0.00 %  5.08 % [kworker/u4:0]
22612 be/4 root          0.00 B      0.00 B  0.00 %  3.52 % [kworker/u4:3]
20189 be/4 mysql         0.00 B      0.00 B  0.00 %  3.50 % mysqld
20212 be/4 mysql         0.00 B     24.00 K  0.00 %  2.89 % mysqld


fhem ist immerhin wieder in den top 10, insofern ein Erfolg.
Aber was beschäftigt den mysqld so stark? Wie kann ich das rausfinden?
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 25 September 2019, 21:42:40
Jetzt sind die Auswirkungen des Problems beseitigt, aber das Problem an sich noch nicht.

Zitatallerdings "sql_processing_time 7.3589" gibt mir zu denken.
Das ist vollkommen induskutabel, viel zu hoch. Die DB reagiert nicht wie sie soll.

Zitat
Variables to adjust:
    query_cache_limit (> 1M, or use smaller result sets)
    innodb_buffer_pool_instances (=1)
Diese Variablen wären anzupassen.

Zeige mal bitte den Inhalt von  /etc/mysql/my.cnf und der Datei /etc/mysql/mariadb.conf.d/50-server.cnf wenn es die gibt.

Der Index ist jetzt angelegt oder ?  habs gesehen
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 25 September 2019, 21:53:47
/etc/mysql/my.cnf

# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/


/etc/mysql/mariadb.conf.d/50-server.cnf

#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 192.168.178.101

#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam_recover_options  = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10

#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 128M # 16M
# Tipp Wernieman
query_cache_type        = 1

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Enable the slow query log to see queries with especially long duration
#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
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = exclude_database_name

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!

#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates you can use for example the GUI tool "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# Accept only connections using the latest and most secure TLS protocol version.
# ..when MariaDB is compiled with OpenSSL:
# ssl-cipher=TLSv1.2
# ..when MariaDB is compiled with YaSSL (default in Debian):
# ssl=on

#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
#
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci

#################### Tuning lt. https://mariadb.com/kb/en/library/configuring-mariadb-for-optimal-perfor              mance/
innodb_buffer_pool_size=1G

#
# * Unix socket authentication plugin is built-in since 10.0.22-6
#
# Needed so the root database user can authenticate without a password but
# only when running as the unix root user.
#
# Also available for other users if required.
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]


Index ist jetzt da, ja.
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 25 September 2019, 22:04:01
Ich suche den Eintrag von  innodb_buffer_pool_instances.
In der Datei ist er nicht.

Mach mal noch ls der Verzeichnisse  /etc/mysql/conf.d/ , /etc/mysql/mariadb.conf.d/.

Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 25 September 2019, 22:07:43
root@t610:/etc/mysql# grep -R innodb_buffer_pool .
./mariadb.conf.d/50-server.cnf:innodb_buffer_pool_size=1G

.. instances gibts wohl nicht...

und die ls commands:
root@t610:/etc/mysql# ls /etc/mysql/conf.d/
mysql.cnf  mysqldump.cnf
root@t610:/etc/mysql# ls /etc/mysql/mariadb.conf.d/
50-client.cnf  50-mysql-clients.cnf  50-mysqld_safe.cnf  50-server.cnf


OK, Ich Depp sollte das in die config einfügen. Moment...

Hm, keine nennenswerte Verbesserung.
sql_processing_time
1.8640
2019-09-25 22:19:08


root@t610:/etc/mysql# grep -R innodb_buffer_pool .
./mariadb.conf.d/50-server.cnf:innodb_buffer_pool_size=1G
./mariadb.conf.d/50-server.cnf:innodb_buffer_pool_instances=1
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 25 September 2019, 22:27:58
Setze bitte

innodb_buffer_pool_size=128M

und dann die Db/Dienst  restarten.

systemctl restart mysql
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 25 September 2019, 22:35:32
Und im DbLOg bitte das Attribut setzen:

bulkInsert = 1
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 25 September 2019, 22:57:10
Ok, done.

sql_processing_time
1.8534
2019-09-25 22:52:16

Vielen Dank für deinen Support!

Der Patient blutet nicht mehr, aber gesund ist er auch nicht...
Ich bin gerne bereit, den Fehler weiter einzugrenzen, aber heute nicht mehr  8)
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 25 September 2019, 22:59:09
Verstehe ich, bin auch müde.

Dann erstmal gute Nacht ... und DANKE !  :D

LG,
Heiko
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Beta-User am 26 September 2019, 07:38:29
Moin zusammen,

habe auch mal auf async umgestellt (wieso ist das eigentlich nicht default gesetzt) und die beiden Attribute gesetzt. An den mariaDB-settings habe ich nichts verändert. So sieht das Bild auf meiner Mühle aus:

ZitatInternals:
   COLUMNS    field length used for Device: 64, Type: 64, Event: 512, Reading: 64, Value: 128, Unit: 32
   CONFIGURATION ./db.conf
   DEF        ./db.conf Bad_.*:(temp|hum).*|(Licht_Bad_.*|Licht_WoZi_.*_.*):.(on|off)|Jalousie_.*:(dim|level).*|MYSENSOR_9[5-9]:.*|MySensorsRS485GW:.*
   FUUID      5d440885-f33f-d171-b650-d85e20f79a7cc993
   FVERSION   93_DbLog.pm:v4.7.0-s20114/2019-09-06
   MODE       asynchronous
   MODEL      MYSQL
   NAME       LogDB
   NR         423
   NTFY_ORDER 50-LogDB
   PID        29155
   REGEXP     Bad_.*:(temp|hum).*|(Licht_Bad_.*|Licht_WoZi_.*_.*):.(on|off)|Jalousie_.*:(dim|level).*|MYSENSOR_9[5-9]:.*|MySensorsRS485GW:.*
   STATE      connected
   TYPE       DbLog
   UTF8       1
   dbconn     mysql:database=fhem;host=localhost;port=3306
   dbuser     fhem_log
   HELPER:
     COLSET     1
     DEVICECOL  64
     EVENTCOL   512
     OLDSTATE   connected
     PACKAGE    main
     READINGCOL 64
     TC         current
     TH         history
     TYPECOL    64
     UNITCOL    32
     VALUECOL   128
     VERSION    4.7.0
   READINGS:
     2019-09-26 07:29:50   CacheUsage      0
     2019-09-26 07:29:50   NextSync        2019-09-26 07:30:20 or if CacheUsage 500 reached
     2019-09-26 07:29:50   background_processing_time 0.0462
     2019-08-03 09:25:23   countCurrent    67
     2019-08-03 09:25:23   countHistory    8268783
     2019-09-26 07:29:36   notify_processing_time 0.0006
     2019-09-26 07:29:50   sql_processing_time 0.0152
     2019-09-26 07:29:50   state           connected
   cache:
     index      6616
Attributes:
   DbLogType  Current/History
   asyncMode  1
   icon       edit_save
   room       Steuerung->Z_Logs
   showNotifyTime 1
   showproctime 1

ZitatResult of version check

Used Perl version: 5.28.1
Used DBI (Database independent interface) version: 1.642
Used DBD (Database driver) version mysql: 4.050
Used DbLog version: 4.7.0.
Your local DbLog module is up to date.
Recommendation: No update of DbLog is needed.

Result of configuration read check

Connection parameter store type: configDB (don't forget upload configuration file if changed. Use "configdb filelist" and look for your configuration file.)
Connection parameter: Connection -> mysql:database=fhem;host=localhost;port=3306, User -> fhem_log, Password -> read o.k.

Result of connection check

Connection to database fhem successfully done.
Recommendation: settings o.k.

Result of encoding check

Encoding used by Client (connection): UTF8
Encoding used by DB fhem: UTF8
Recommendation: settings o.k.

Result of logmode check

Logmode of DbLog-device LogDB is: asynchronous
Recommendation: settings o.k.

Result of plot generation method check

WEB: plotfork=1
Recommendation: settings o.k.

Result of table 'history' check

Column width set in DB history: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by LogDB: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of table 'current' check

Column width set in DB current: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Column width used by LogDB: 'DEVICE' = 64, 'TYPE' = 64, 'EVENT' = 512, 'READING' = 64, 'VALUE' = 128, 'UNIT' = 32
Recommendation: settings o.k.

Result of check 'Search_Idx' availability

Index 'Search_Idx' exists and contains recommended fields 'DEVICE', 'TIMESTAMP', 'READING'.
Recommendation: settings o.k.

Result of check 'Report_Idx' availability for DbRep-devices

No DbRep-device assigned to LogDB is used. Hence an index for DbRep isn't needed.
Recommendation: settings o.k.

Gestern abend gg. 22:00 Uhr habe ich ein FHEM-update gemacht samt restart.

top zeigte 4.9% Speichernutzung durch Perl an (+ kurzzeitig einen weiteren Prozess mit eigenem Memory-Verbrauch, wenn irgendwas im Hintergrund am laufen wahr).

Jetzt habe ich aktuell 5.4% Spericherbelegung durch FHEM (=knapp 200k, wenn ich das "Virt" richtig interpretiere).

(Soll erst mal nur ein Vergleichswert sein, k.A., ob da was im Argen ist...)
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 26 September 2019, 08:05:24
Sag mal .. meistens schreiben diese DBs doch nur?

Ihr könnt mal probieren, folgendes zu ändern:
query_cache_limit       = 1M
query_cache_size        = 128M # 16M
query_cache_type        = 1


Zu
query_cache_limit       = 0
query_cache_size        = 0
query_cache_type        = 0


Und dann mal sehen, ob es besser wird. habe es gestern "gelernt" ...
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 26 September 2019, 08:20:10
Moin zusammen,

@Beta-User

Zitathabe auch mal auf async umgestellt (wieso ist das eigentlich nicht default gesetzt)
Das hat historische Gründe und ist auch der Tatsache geschuldet, dass man im asynchron Mode mehr Speicher braucht, 1. wegen dem cachen von Daten und 2. durch eine zweiten Prozess (Blocking Call).

Zitat(+ kurzzeitig einen weiteren Prozess mit eigenem Memory-Verbrauch, wenn irgendwas im Hintergrund am laufen wahr).
Ja, das ist der besagte BlockingCall. Der kommt im Abstand des Attributes syncInterval.

Sieht doch gut aus deine Installation.  :)

EDIT: mit bulkInsert = 1 könntest du evtl. noch etwas rausholen.


@Wernieman,  Lucky2k12:
Es müsste auch noch berücksichtigt werden ob die Schreibperformance der Platte in Ordnung ist. Nicht das es dort einen Bottleneck gibt.
Dann ist noch die Frage, ob kein SWAP-Space bereitszustellen ein gute Idee ist. (ich glaube ich habe mal ein top ohne Swap gesehen).
Vielleicht bekommt ihr hier noch etwas raus. Ich kann erst morgen weiter unterstützen ... heute Abend ist ja FHEM-Stammtisch.  :D

LG,
Heiko
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Beta-User am 26 September 2019, 09:04:56
Dachte mir, dass das historische Gründe hat; wäre es hier nicht eine Idee, beim Start zu prüfen, was es für ein System ist und dann entsprechend zu reagieren?

Das mit dem 2. Prozess ist eigentlich auch sinnvoll, wenn man mehr als einen Kern hat, oder?

bulkInsert habe ich jetzt auch mal gesetzt.

Ergo scheinen diese Parameter auf halbwegs aktuellen Systemen so eine Art Empfehlung zu sein:
asyncMode  1
DbLogType  Current/History
bulkInsert 1
(Wenn ja: Mal sehen, ob ich das irgendwie (notfalls erst mal im ThinClient-Bereich) ins Wiki packe).
An den DB-Einstellungen schraube ich erst mal nicht rum, werde erst mal weitere Devices von FileLog nach DbLog umstellen, und dann mal wieder schauen, wie sich das entwickelt. (Mein Angang ist tendenziell immer, möglichst wenig an der Konfiguration "drumrum" zu ändern, selbst wenn das nicht ganz optimal ist. Aber so könnte ich jederzeit leichter wieder die Hardware wechseln, ohne mir allzu intensiv zu überlegen, was ich denn in welcher Reihenfolge benötige... (will ich eigentlich nicht, aber man kann nie wissen)).

Wie gesagt: Ging eher darum, Referenzdaten bereitzustellen. Bin nicht davon ausgegangen, dass da irgendwas ernsthaft im argen wäre.

Btw. was Referenzdaten angeht noch ein Nachtrag zu vorhin: Vor dem Neustart (also auch vor asyncMode) gestern lag ich bei etwas über 10% Speicherbelegung durch den perl-Prozess (ursprünglich ebenfalls mal bei 4.9%). Das ist hier aber OT, das betrifft eher das memoryleak-Thema, das auch kurz angerissen gewesen war. Also würde ich mal sagen, dass da durchaus irgendwas ist, was man nicht ganz ignorieren sollte.
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 26 September 2019, 09:38:29
@DS_Starter

Die Plattenperformance spielt natürlich eine Roile, aber meistens kann man dort nicht mehr dran drehen, ohne den Server zu tauschen.

Eventuell wäre noch interessant, welches Filesystem etc. ....
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 26 September 2019, 09:49:22
Danke für die Vergleichswerte.
Mit der Vermutung HD hat einen Schuss bist du auf der richtigen Spur, Heiko.

dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc
1024+0 Datensätze ein
1024+0 Datensätze aus
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 241,245 s, 4,5 MB/s

Schnarchlangsam!
@Beta-User: Könntest du bitte wieder den Vergleichs-Benchmark liefern?

Edit: FS ist ext4.
Die ganzen Memorysettings zu optimieren, kann so ja keinen spürbaren Effekt haben.

Ich denke, ich ziehe die Installation auf die bereits verbaute 2.5" SSD per dd um.

Ursprünglich war der Plan, dort eine 2. Parallel-Installation mit docker containern aufzubauen und das Produktivsystem solange auf der serienmäßigen SSD zu belassen. Das muss ich dann eben verschieben...

Das mit dem swap off war eher eine Vorsichtsmaßnahme um die SSD zu schonen(und ggf den Platz zu nutzen), ist aber vermutlich unnötig.


Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: DS_Starter am 26 September 2019, 10:57:29
Bei diesem Datendurchsatz ist freilich kein Blumentopf zu gewinnen.  ;)

@Beta-User,

für diesen Einstellungscheck gibt es den configCheck. Ich erweitere ihn noch um bulkInsert.
Die Empfehlung diesen auszuführen, steht in der Hilfe zu DbLog.

Bezüglich memoryleak habe ich dblog auch schon unter die Lupe genommen, aber nichts feststellen können. Eine Kleinigkeit habe ich momentan noch im Test und werde sie demnächst einchecken. Hatte bei mir zwar keinen Effekt, aber vorsichtshalber ändere ich eine kleine Sache.

Hier https://forum.fhem.de/index.php/topic,84372.msg974569.html#msg974569
hatte ich ein Hilfsmittel bereitgestellt um Devices/Module bzüglich memory verbrauch beurteilen zu können. Vllt. hilft es dir.

Grüße,
Heiko
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wzut am 26 September 2019, 11:30:30
Zitat von: Lucky2k12 am 26 September 2019, 09:49:22
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 241,245 s, 4,5 MB/s
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 5,44676 s, 197 MB/s
interne 2,5" SSD auf einem HP T610
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 26 September 2019, 11:54:48
@Lucky2k12

Es ist eine SSD? Mit den Werten?

Es is doch eine aktuelle Linux-Distri? Ansonsten mal "fstrim -av" gestartet?
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 26 September 2019, 12:15:40
Es ist die im T610 serienmäßig verbaute SSD, sollte eine Apacer 8c.f1dd2.lr10b, 16GB MLC SATA module, hf wie hier sein.
https://assets.catawiki.nl/assets/2017/8/31/2/7/7/2778e53c-2f44-40ec-bae5-6afc2af81db5.jpg
Ich guck heut abend mal, ob ich noch eigene Fotos finde.
"fstrim -av" hat nur auf meiner 2.5" SSD Blöcke freigegeben, nicht auf dieser.


OS ist "SMP Debian 4.9.144-3-1"
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 26 September 2019, 14:38:56
16GB ... dürfte etwas älter sein? Dann kennt sie eventuell das SATA-Trimm-Kommando nicht .. und damit bringt Dir der fstrim wenig.

Außerdem .. ist sie gebraucht? Dann hat sie eventuell in der Richtung ein "Problem" ....
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 26 September 2019, 19:26:43
Ja klar, genauso alt wie der T610, den ich für 58Eur gebraucht aber angeblich getestet aus der Bucht gefischt habe.
Aber gut zu wissen, dass es SSDs gibt auf denen fstrim nichts bewirkt, Danke.
Und viel Spass beim Treffen :)
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 26 September 2019, 20:15:57
Zitat von: DS_Starter am 26 September 2019, 08:20:10
Ich kann erst morgen weiter unterstützen ... heute Abend ist ja FHEM-Stammtisch.  :D
Ja, viel Spaß dabei (läuft ja schon)
und ich bin bis Sonntag abend unterwegs und weitgehend offline, bitte nicht wundern.

Aber die Ursache scheint ja weitgehend eingegrenzt :)
Danke für eure Hilfe!!!
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Wernieman am 26 September 2019, 20:44:17
Du solltest in eine neue SSD investieren ...
Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 26 September 2019, 21:06:47
Ja, wie gesagt, es steckt schon eine 2.5" Samsung drin.
Ich muss nur noch das System umziehen.   ;D


sudo smartctl -a /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.9.0-8-amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     16GB SATA Flash Drive
Serial Number:    E0113428800700000188
Firmware Version: SFDDA01A
User Capacity:    16.013.942.784 bytes [16,0 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS (minor revision not indicated)
SATA Version is:  SATA 2.6, 3.0 Gb/s
Local Time is:    Thu Sep 26 21:44:23 2019 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity
                                        was never started.
                                        Auto Offline Data Collection: Disabled.
Total time to complete Offline
data collection:                (   30) seconds.
Offline data collection
capabilities:                    (0x00)         Offline data collection not supported.
SMART capabilities:            (0x0003) Saves SMART data before entering
                                        power-saving mode.
                                        Supports SMART auto save timer.
Error logging capability:        (0x00) Error logging NOT supported.
                                        No General Purpose Logging support.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   050    Pre-fail  Always       -       16777215
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0007   100   100   050    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0013   100   100   050    Pre-fail  Always       -       0
  7 Unknown_SSD_Attribute   0x000b   100   100   050    Pre-fail  Always       -       0
  8 Unknown_SSD_Attribute   0x0005   100   100   050    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       6523
10 Unknown_SSD_Attribute   0x0013   100   100   050    Pre-fail  Always       -       0
12 Power_Cycle_Count       0x0012   100   100   000    Old_age   Always       -       288
168 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
175 Program_Fail_Count_Chip 0x0003   100   100   010    Pre-fail  Always       -       0
192 Power-Off_Retract_Count 0x0012   100   100   000    Old_age   Always       -       0
194 Temperature_Celsius     0x0022   040   100   000    Old_age   Always       -       40 (Min/Max 30/60)
197 Current_Pending_Sector  0x0012   100   100   000    Old_age   Always       -       0
240 Unknown_SSD_Attribute   0x0013   100   100   050    Pre-fail  Always       -       0
160 Unknown_Attribute       0x0000   100   100   010    Old_age   Offline      -       234
161 Unknown_Attribute       0x0000   100   100   010    Old_age   Offline      -       234
162 Unknown_Attribute       0x0000   100   100   005    Old_age   Offline      -       28
163 Unknown_Attribute       0x0000   100   100   001    Old_age   Offline      -       23411
164 Unknown_Attribute       0x0000   100   100   001    Old_age   Offline      -       23169
165 Unknown_Attribute       0x0000   100   100   001    Old_age   Offline      -       23169
241 Total_LBAs_Written      0x0000   100   100   000    Old_age   Offline      -       13730772840

SMART Error Log not supported

SMART Self-test Log not supported

Selective Self-tests/Logging not supported



sudo smartctl -i /dev/sdb

smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.9.0-8-amd64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 840 EVO 250GB
Serial Number:    S1DBNEADA09734T
LU WWN Device Id: 5 002538 8500a6577
Firmware Version: EXT0CB6Q
User Capacity:    250.059.350.016 bytes [250 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2, ATA8-ACS T13/1699-D revision 4c
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Sep 26 21:07:29 2019 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

Titel: Antw:DBLog / MariaDB zieht load nach oben, FHEM laggt extrem
Beitrag von: Lucky2k12 am 01 Oktober 2019, 20:17:00
So, Umzug dank clonezilla geschafft.
(mit dd und resize2fs hats mir immer die UUIDs in grep zerhauen.)

Aktuelles Ergebnis auf der 2.5" Samsung SSD 840 EVO 250GB

dd if=/dev/zero of=tempfile bs=1M count=1024 conv=fdatasync,notrunc
1024+0 Datensätze ein
1024+0 Datensätze aus
1073741824 Bytes (1,1 GB, 1,0 GiB) kopiert, 4,82667 s, 222 MB/s

Das sieht doch wesentlich freundlicher aus :)
Auch der load liegt jetzt unter 0.2, wa bei 0.0

Lessons learned: Scheint so als wäre die Uralt SSD im T610 doch der bottleneck bei mysql gewesen.

Danke für eure Unterstützung, ich setze das hier auf solved.