Linux Tips

Revision as of 15:34, 9 March 2018 by Nxhack (talk | contribs)
  • varnish が 404 のまま


sub vcl_backend_response {
    # Don't cache 404 responses
    if ( beresp.status == 404 ) {
        set beresp.ttl = 3s;
    }
}
  • ubuntu 16.04 systemd 環境の varnish と logrotate
mkdir /run/varnish
chown varnishlog:varnish /run/varnish
Type=forking
ExecStartPre=/usr/bin/install -o varnishlog -g varnish -d /run/varnish
ExecStart=/usr/bin/varnishlog -D -a -w /var/log/varnish/varnish.log -P /run/varnish/varnishlog.pid
PIDFile=/run/varnish/varnishlog.pid
Type=forking
ExecStartPre=/usr/bin/install -o varnishlog -g varnish -d /run/varnish
ExecStart=/usr/bin/varnishncsa -D -a -w /var/log/varnish/varnishncsa.log -P /run/varnish/varnishncsa.pid
PIDFile=/run/varnish/varnishncsa.pid
  postrotate
    /bin/kill -HUP `cat /run/varnish/varnishlog.pid 2>/dev/null` 2> /dev/null || true
  endscript
  postrotate
    /bin/kill -HUP `cat /run/varnish/varnishncsa.pid 2>/dev/null` 2> /dev/null || true
  endscript


  • ccache

.bashrc に

USE_CCACHE=1
export USE_CCACHE
PATH="/usr/lib/ccache:$PATH"
export PATH
  • Fail2Ban

今更ながらですが、Fail2ban実験中。

いままで、つつかれるのは仕方がないと放置してたのですが...
  • たんなるメモ

OpenWrt / LEDE とかクロスコンパイル環境では、やたらと PATH が深くなりがち。このためにいろいろトラブルがでる。

execvp: printf: Argument list too long.
これはパス名がながくて、引数のサイズ制限をこえたということ。対処は PATH を短くするか、xargs つかってうまく逐次処理する。
getconf ARG_MAX
bad interpreter: No such file or directory
shellbang でもインタープリターのフルパス名でハマることもある。逃げ方は exec hoge 等のラッパかます等。
80桁


  • たんなるメモ
Use 'apt-get autoremove' to remove them.
  • VirtualBox + Ubuntu システム時刻

Windows のシステム時刻がローカルタイム(JST)なので、Ubuntu の /etc/default/rcS で

# assume that the BIOS clock is set to UTC time (recommended)
#UTC=yes
UTC=no
  • Ubuntu unattended-upgrades サードパーティ レポジトリの扱い

Origin と Suite を指定してくれてないものをどうすればよいのか...

Unattended-Upgrade::Allowed-Origins {
    "*:*";
};

大胆に *:* してテスト中。

    "Sensu:sensu";
    "LP-PPA-ondrej-php:${distro_codename}";
    "elastic:stable";


  • たんなるメモ
dpkg-reconfigure keyboard-configuration
  • Hey! MAN!!!

漢なら run as root B)

漢なら Disable Ubuntu command-not-found

.bashrc に

unset command_not_found_handle
  • メモリー系いろいろ
echo -17 > /proc/<PID>/oom_adj

sshd とかは起動スクリプトで -17 に設定されている

vm.overcommit_memory=2
vm.overcommit_ratio=90

overcommit_ratio は環境による。メモリー逼迫してる場合はこれやると危険かも。

  • service - run a System V init script

ふむ

man 8 service
service SCRIPT COMMAND

# service mysql restart

  • cron-apt
apt-get install cron-apt
/etc/cron-apt/config

APTCOMMAND=/usr/bin/aptitude
MAILTO="someone@somewhere"
/etc/cron-atp/action.d/5-upgrade

safe-upgrade -y -o APT::Get::Show-Upgraded=true
/etc/cron.d/cron-apt

実行時間適当に変えてくれてる
  • つかえるかな?
cpulimit
  • Cluster SSH

おもろい

Cluster SSH - Cluster Admin Via SSH
  • たんなるメモ
vm.swappiness=0
kernel.panic_on_oops=1
kernel.panic=1
mount -o barrier=0
調査中...
  • OOM Killer を避ける
# echo -17 > /proc/<pid of sshd>/oom_adj
Linux performance tuning & stabilization tips (mysqlconf2010)
デフォでなってるな
  • 127.0.1.1 の話と、localdomain の話
いろいろ厳密化してるなぁ
localhost. と hostname 名前解決の分離
Debian Reference - Network configuration
UbuntuNote - Ubuntuのメモ
めも - 127.0.1.1
Net::SMTPでSMTPのHELO/EHLOにデフォルトで不正なホスト名を使用
たぶん、この議論を引き起こした遠因はこれかな
SecuriTeam - Common DNS Misconfiguration can Lead to "same Site" Scripting
yebo blog: Same-Site Scripting
  • mount bind
ふむ リハビリ中
mount --bindが便利 - komamitsu.log
Linux/ディレクトリにディレクトリをマウントする - discypus
  • relatime
ほー知らんかった3...(かなりリハビリ必要やな)
relatimeがどこで実装されているのか調べてみた
最新のFedoraとUbuntuではrelatimeもnoatimeもいらない?
relatimeが標準に
  • ディスクI/Oとniceレベル
ほー知らんかった2...
ドライバに変数を渡すのにうってつけの方法
ほえほえ ionice
mediate disk access with ionice(1).
  • Linuxにおけるメモリの開放
ほー知らんかった...
第10回:メモリ管理で安定稼動
DB2 V9.1以降でSTMMを使用する場合のOSのメモリー関連設定の注意事項 (DM-08-009)
続 @ITのmeminfoの見方の説明が完全に間違っている件について
sysctl -w vm.drop_caches=1
  • Linux TCP Tuning
TCP Tuning Guide - Linux TCP Tuning
  • Jetty TCP Tuning
Jetty - Addressing High TCP Slot Usage
  • たんなるメモ15
わすれもの
/usr/bin/setterm -blank 0 -store > /dev/tty1
  • よけいなお世話:)
tune2fs -c -1 -i 0 デバイス

過去ログ

昔のものは、雑多なメモ