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)

Bilder auf 1200x900 skalieren

for i in 745 819 837 ; do
  convert P1040${i}.JPG -resize 1200x900 P1040${i}_1200x900.JPG
done

StarOffice Dokumente nach LibreOffice ODF konvertieren

LibreOffice 5.3 soll StarCalc (.sdc), StarDraw/StarImpress (.sda, .sdd, .sdp) und StarWriter (.sdw) wieder unterstützen. Vielleicht ist das der einfachere Weg?

Basis: VirtualBox Debian 9 VM. StarOffice Download.

wget https://downloadarchive.documentfoundation.org/libreoffice/old/3.6.7.2/deb/x86_64/LibO_3.6.7.2_Linux_x86-64_install-deb_en-US.tar.gz
wget https://downloadarchive.documentfoundation.org/libreoffice/old/3.6.7.2/deb/x86_64/LibO-SDK_3.6.7.2_Linux_x86-64_install-deb_en-US.tar.gz

tar xf LibO_3.6.7.2_Linux_x86-64_install-deb_en-US.tar.gz 
tar xf LibO-SDK_3.6.7.2_Linux_x86-64_install-deb_en-US.tar.gz 

dpkg -i libobasis3.6-core01_3.6.7.2-2_amd64.deb libreoffice3.6-ure_3.6.7.2-2_amd64.deb
dpkg -i libobasis3.6-core0?_3.6.7.2-2_amd64.deb
dpkg -i libreoffice3.6-writer_3.6.7.2-2_amd64.deb libobasis3.6-writer_3.6.7.2-2_amd64.deb libreoffice3.6_3.6.7.2-2_amd64.deb libobasis3.6-images_3.6.7.2-2_amd64.deb 
dpkg -i libobasis3.6-writer_3.6.7.2-2_amd64.deb libreoffice3.6-base_3.6.7.2-2_amd64.deb libobasis3.6-base_3.6.7.2-2_amd64.deb
dpkg -i *.deb
dpkg -i libobasis3.6-sdk_3.6.7.2-2_amd64.deb 
apt-get install openjdk-8-jre

Dann von einer neuen Konsole aus:

ssh -X root@192.168.56.101
/opt/libreoffice3.6/program/swriter

Dokumente finden

find . \( -name "*.sdw" -o -name "*.sdc" -o -name "*.sdd" \)

Zu alte Dokumente (2001) haben nicht funktioniert. Um noch zumindest an den Text zu gelangen wurde wie folgt vorgegangen:

strings rumtopf.sdw > rumtopf.txt

HPLIP Farbdruckproblem-Workaround

  • VirtualBox Ubuntu 16.04 starten.
  • HPLIP installieren (deinstallieren hat nicht funktioniert):
    sudo hp-uninstall
    dpkg -l | grep hpli
    ./hplip-3.17.11.run
    hp-setup
    
  • Drucker konfigurieren:
    ssh -X oli@192.168.1.131
    hp-setup
    hp-testpage
    
  • Show all status information:
    shell> lpstat -t
  • Show printers:
    shell> lpstat -p
  • Show default destination:
    shell> lpstat -d
  • Set default destination:
    shell> lpoptions -d<printer>
  • List print jobs:
    shell> lpq -P<printer>
    shell> lpq -l -P<printer>
    
  • Delete a job:
    shell> lprm -P<pritner> <job_id>
  • Print a file:
    shell> lpr -P<printer> <file>
  • Drucken:
    shell> lp -d HP_PageWide_Pro_477dw_MFP *.pdf

ISO Image aus CD/DVD bauen

Geklaut bei Thomas Krenn (hat sehr oft sehr gute Artikel dort!).

shell> isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size'
Logical block size is: 2048
Volume size is: 327867
shell> dd if=/dev/cdrom of=test.iso bs=<block size> count=<volume size>

Pile of Poo Emoji

Caution: My current Drupal 7 cannot Emojis!

mysql> SET NAMES utf8mb4;
mysql> ALTER TABLE test CONVERT TO CHARACTER SET utf8mb4;
mysql> INSERT INTO test VALUES (NULL, 0xF09F92A9, NULL);
mysql> -- <pile of poo sign>
mysql> -- U+1F4A9
mysql> -- 0xF09F92A9
mysql> SELECT id, HEX(data), data FROM test;
+----+-----------+------+
| id | hex(data) | data |
+----+-----------+------+
|  1 | F09F92A9  | <PoP>|
+----+-----------+------+

echo before cat

shell> echo 'SET SESSION sql_log_bin = 0;' | gzip --to-stdout | \
       zcat - full_dump.sql.gz | mysql --user=root

or alternatively:

shell> cat full_dump.sql | mysql -u root --init-command='SET SESSION sql_log_bin=0; \
          SET GLOBAL innodb_flush_log_at_trx_commit=0; SET GLOBAL super_read_only = off;'

File download from Xiaomi Mi Mix 2 on Linux

On my Linux I get some strange error messages when I want to download the photos from my mobile via USB. So I had to find another way.
I installed an ssh server and then I can easily download my photos and GPS tracks. Unfortunately this ssh server only allows the weak dss (DSA) keys. It seems like somebody wants to participate in my pleasure:

shell> scp -o HostKeyAlgorithms=+ssh-dss -P 2222 ssh@192.168.1.119:/storage/emulated/0/DCIM/Camera/* .
ssh@192.168.1.119's password: 
IMG_20180530_174731.jpg                       100% 5274KB   5.2MB/s   00:01    
IMG_20180603_110345_1.jpg                     100% 6294KB   3.1MB/s   00:02    

shell> scp -o HostKeyAlgorithms=+ssh-dss -P 2222 ssh@192.168.1.119:/storage/emulated/0/Android/data/net.osmand/files/tracks/rec/*.gpx .
ssh@192.168.1.119's password:                                                                                                   
2018-06-02_21-17_Sat.gpx                      100%   14KB  14.1KB/s   00:00     
2018-06-03_09-27_Sun.gpx                      100%  122KB 122.0KB/s   00:00