[gelöst] DBLog / MariaDB zieht load nach oben, FHEM laggt extrem

Begonnen von Lucky2k12, 25 September 2019, 09:16:08

Vorheriges Thema - Nächstes Thema

Lucky2k12

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.
HP T610, HM, Jeelink, LGW, mapleCUL868+434

Wernieman

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.
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

Lucky2k12

#2
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?
HP T610, HM, Jeelink, LGW, mapleCUL868+434

DS_Starter

#3
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
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Lucky2k12

/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.
HP T610, HM, Jeelink, LGW, mapleCUL868+434

DS_Starter

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/.

Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Lucky2k12

#6
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
HP T610, HM, Jeelink, LGW, mapleCUL868+434

DS_Starter

Setze bitte

innodb_buffer_pool_size=128M

und dann die Db/Dienst  restarten.

systemctl restart mysql
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

DS_Starter

Und im DbLOg bitte das Attribut setzen:

bulkInsert = 1
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Lucky2k12

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)
HP T610, HM, Jeelink, LGW, mapleCUL868+434

DS_Starter

Verstehe ich, bin auch müde.

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

LG,
Heiko
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Beta-User

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...)
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors

Wernieman

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" ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

DS_Starter

#13
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
Proxmox+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Beta-User

#14
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.
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors