You are here

Oli's Spickliste

Mein Hirn wird langsam alt und matschig, daher fange ich an, mir Zeugs aufzuschreiben...

Inhaltsliste


File Limit für MySQL hoch setzen

shell> su - mysql
shell> ulimit -Sn
1024
shell> ulimit -Hn
4096

shell> cat /etc/security/limits.d/mysql.conf
#
# /etc/security/limits.d/mysql.conf
#

mysql            hard    nofile          16384
mysql            soft    nofile          16384

shell> grep pam_limits /etc/pam.d/common-session
session required        pam_limits.so

Login reicht und Reboot sollte auf Ubuntu 14.04 nicht notwendig sein.

shell> su - mysql
shell> ulimit -Sn
16384
shell> ulimit -Hn
16384

Entropie auf virtuellen Maschinen (VM guests)

Ein neues Phänomen, mit welchem wir möglicherweise in Zukunft zu kämpfen haben, ist die Entropie in virtuellen Maschinen. Diese wird für Verschlüsselung benötig. Da wir aus Sicherheitsgründen vermehrt https und SSL etc. verwenden sollten, und alle Welt Virtualisierung so super cool findet, wird dieses Problem in naher Zukunft verstärkt auftreten. Insbesondere auch mit MySQL ab der Version 5.7 bei welcher ja SSL per default eingeschaltet ist.

Je nach Quelle sollte die Entropie nicht unter 1000 oder nicht unter 100 fallen. Wie dem auch sei: Monitoren kann nicht schaden:

shell> cat /proc/sys/kernel/random/entropy_avail
956

Siehe dazu auch:


Unleserliche Firefox Tooltips unter KDE/Kubuntu

Deutsch: KDE-Menü: Einstellungen -> Systemeinstellungen -> Allgemeines Aussehen und Verhalten -> Anwendungs-Aussehen (öffnet neues Fenster) -> Farben (in Auswahl links) -> Farben (als Reiter) -> Tooltip Hintergrund und Tooltip Text

English: KDE-Menue: Settings -> System Settings -> Common Appearance and Behavior -> Application Appearance -> Colors (left column) -> Colors (tab) -> Tooltip Background and Tooltip Text

Apache mod_rewrite Beispiele

Gilt nur für Apache 2.4 und neuer: Rewrite trace aktivieren (nicht auf der Produktion!)

#
#/etc/apache2/conf-available/rewrite_log.conf 
#
LogLevel rewrite:trace8

shell> a2enconf rewrite_log
shell> service apache2 restart

Logged ins Apache Error Log (/var/log/apache2/error.log) und sieht wie folgt aus:

[Thu Feb 23 11:24:15.615062 2017] [rewrite:trace3] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] strip per-dir prefix: /var/www/html/forumdisplay.php -> forumdisplay.php
[Thu Feb 23 11:24:15.615147 2017] [rewrite:trace3] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] applying pattern 'forumdisplay.php' to uri 'forumdisplay.php'
[Thu Feb 23 11:24:15.615181 2017] [rewrite:trace4] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] RewriteCond: input='fid=1q' pattern='fid=1' => matched
[Thu Feb 23 11:24:15.615195 2017] [rewrite:trace2] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] rewrite 'forumdisplay.php' -> 'https://fromdual.com/forum/416'
[Thu Feb 23 11:24:15.615216 2017] [rewrite:trace2] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] discarding query string
[Thu Feb 23 11:24:15.615229 2017] [rewrite:trace2] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] explicitly forcing redirect with https://fromdual.com/forum/416
[Thu Feb 23 11:24:15.615241 2017] [rewrite:trace1] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] escaping https://fromdual.com/forum/416 for redirect
[Thu Feb 23 11:24:15.615255 2017] [rewrite:trace1] [pid 19548] mod_rewrite.c(468): [client 127.0.0.1:46136] 127.0.0.1 - - [localhost/sid#7efc6e9452d8][rid#7efc6e6710a0/initial] [perdir /var/www/html/] redirect to https://fromdual.com/forum/416 [REDIRECT/301]

Einige Rewrite Regeln:

#
# ./.htaccess
#

# To activate .htaccess it needs:
# AllowOverride All
# on <Directory ... />

# Activate the following line to test if .htaccess is read (Error 500):
# Break.

RewriteEngine On

# Forum rewrite: /forumdisplay.php&fid=1 -> https://fromdual.com/forum/416
# Do NOT attach query string (QSD), Redirect permanently (R), Do not continue if match
RewriteCond "%{QUERY_STRING}" ="fid=1"
RewriteRule "forumdisplay.php" "https://fromdual.com/forum/416" [QSD,R=301,L]

...

RewriteCond "%{QUERY_STRING}" ="fid=99"
RewriteRule "forumdisplay.php" "https://fromdual.com/forum/775" [QSD,R=301,L]

# Catch-all
RewriteRule ".*" "https://fromdual.com/forum" [QSD,R=301,L]

Historische Performance-Daten mittels sar

Allenfalls vorgängig sar entsprechend konfigurieren (Ubuntu):

# /etc/default/sysstat
ENABLED="true"

# /etc/cron.d/sysstat
# Activity reports every 2 minutes everyday
*/2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1

Die sar History-Files (31 verfügbare Tage) liegen hier:

# Ubuntu
shell> ll -ltr /var/log/sysstat/sa??

# CentOS
shell> ll -ltr /var/log/sa/sa??

Network

shell> sar -n DEV,EDEV -s 09:00:00 -e 10:59:59 -f /var/log/sysstat/sa03 | grep -e IFACE -e eth0

09:56:01        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
09:58:01         eth0      2.45      2.74      0.69      0.52      0.00      0.00      0.01      0.00
10:00:01         eth0      7.47      6.95      0.84      0.87      0.00      0.00      0.01      0.00
10:02:01         eth0      4.78      5.03      0.85      1.05      0.00      0.00      0.01      0.00
10:04:01         eth0      6.42      5.70      2.90      0.79      0.00      0.00      0.01      0.00
Average:         eth0      5.28      5.10      1.32      0.81      0.00      0.00      0.01      0.00

09:56:01        IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
09:58:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:00:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:02:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:04:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

shell> sar -n DEV,EDEV -s 09:00:00 -e 10:59:59 -4 | grep -e IFACE -e eth0
Linux 3.13.0-110-generic (chef)         03/03/17        _x86_64_        (4 CPU)

09:54:24          LINUX RESTART

09:56:01        IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s   %ifutil
09:58:01         eth0      2.45      2.74      0.69      0.52      0.00      0.00      0.01      0.00
10:00:01         eth0      7.47      6.95      0.84      0.87      0.00      0.00      0.01      0.00
10:02:01         eth0      4.78      5.03      0.85      1.05      0.00      0.00      0.01      0.00
10:04:01         eth0      6.42      5.70      2.90      0.79      0.00      0.00      0.01      0.00
10:06:01         eth0      5.21      3.20      0.62      0.49      0.00      0.00      0.01      0.00
Average:         eth0      5.26      4.72      1.18      0.74      0.00      0.00      0.01      0.00

09:56:01        IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
09:58:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:00:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:02:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:04:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
10:06:01         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
Average:         eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Disk

shell> sar -d -p -1 -f /var/log/sysstat/sa03  | grep -e DEV -e sdb

09:56:01          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
09:58:01          sdb      3.92      1.73    100.04     25.94      0.04      9.63      0.75      0.29
10:00:01          sdb      3.39      0.00     76.45     22.55      0.05     14.07      0.47      0.16
10:02:01          sdb      5.46      0.00    294.50     53.94      0.11     20.54      0.76      0.42
10:04:01          sdb      3.20      0.00     91.65     28.65      0.04     11.02      0.71      0.23
10:06:01          sdb      3.98      1.07    105.26     26.69      0.06     14.45      0.59      0.23
Average:          sdb      3.99      0.56    133.67     33.62      0.06     14.56      0.67      0.27

Debian Pakete mit Abhängigkeiten installieren

shell> dpkg -i some_package.deb
shell> apt-get install -f

Linux Filesystem Cache flushen

shell> sudo echo 3 > /proc/sys/vm/drop_caches

MySQL/MariaDB CLI mini-Benchmark mit Microsekunden Präzision

mysql> SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6)) INTO @begin; DO BENCHMARK(10, SLEEP(1)); SELECT UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6)) INTO @end; SELECT ROUND(@end - @begin, 6) AS elapsed;
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (10.00 sec)
Query OK, 1 row affected (0.00 sec)
+-----------+
| elapsed   |
+-----------+
| 10.000955 |
+-----------+
1 row in set (0.00 sec)