YANO's digital garage

Copyright ©YANO All rights reserved. https://www.bravotouring.com/~yano/

Last-modified: 2024-04-08 (月)


[一語一絵/IT系]

Ubuntu20.04 / 2021-01-24 (日)

2014年6月にUbuntu 14.04 (Trusty)にアップデートしたbravotouring.comのサーバ。

Hugo乗り換えを大義名分に先送りにしていたアップデートを、気の迷いで1月13日未明にうっかり実施。大胆にもdo-release-upgradeを3回繰り返し、LTS最新版のUbuntu 20.04 (Focal Fossa)という荒業にチャレンジしたメモ。

まず、spamassassinが起動に失敗。うん、CPANが追いついてないので無理だよね、というわけでひとまずuninstallして首絞め。

続いて、DKIMNSDも起動に失敗していて、メールが送受信できない事に気づいて軽く慌てはじめる。/var/log/syslog

Jan 13 03:59:56 vps nsd[2349728]: Error in SSL_CTX use_certificate_file
    crypto error:140AB18F:SSL routines:SSL_CTX_use_certificate:ee key too small
というエラーに気づいた。ググってみると[External]OpenSSL 1.1.1/changelog[28 May 2019]で
Change the default RSA, DSA and DH size to 2048 bit instead of 1024. This changes the size when using the genpkey command when no size is given. It fixes an omission in earlier changes that changed all RSA, DSA and DH generation commands to use 2048 bits by default.
と、鍵長が2048ビット以上でないとダメになったようなので、nsd-control-setupで鍵を作り直してみた。
root@vps:/etc/nsd# nsd-control-setup
setup in directory /etc/nsd
nsd_server.key exists
nsd_control.key exists
create nsd_server.pem (self signed certificate)
create nsd_control.pem (signed client certificate)
Signature ok
subject=CN = nsd-control
Getting CA Private Key
Setup success. Certificates created.
root@vps:/etc/nsd#
…もののエラーは変わらず。結局、スクリプトを読んでみたところ1536→3072と生成する鍵長の設定は強化されていたもののnsd_server.key existsという事で作成されていなかったというオチだったので、
root@vps:~# cd /etc/nsd
root@vps:~# mv nsd_control.key nsd_control.key.2014
root@vps:~# mv nsd_server.key nsd_server.key.2014
root@vps:~# nsd-control-setup
root@vps:~# systemctl start nsd.service
として復活。

dovecotも同様に

DH_KEY_TOO_SMALL
というSSLのエラーだったので、
root@vps:~# cd /etc/dovecot/
root@vps:~# openssl dhparam 4096 > dh.pem
で解決し、
root@vps:~# systemctl start dkim.service
DKMIまでやっと復旧。

しかし、サービスは立ち上がったものの相変わらずメールは不通。Webアクセスはできるので大丈夫と思いきや、DNSで名前解決ができてない事が判明。地道に調べてみると肝心のzoneファイルの書き方がいい加減でエラーになっていた事がわかり、これも真面目に改修してWebとメールが開通したのは明け方だった。

数日置いてspamassassinもCPANではなくaptで再インストール。育ててきた自前のルールがなかなか適用されずしばらく試行錯誤していたのだが、判定スコアのしきい値として/etc/spamassassin/local.cfのrequired_hitsよりも.spamassassin/user_prefsのrequired_scoreが優先されていただけで、自前のルール自体は効くようになっていたようだ。

話は戻って、肝心要のRnotephpが5.5.9から7.4.3に上がり

Uncaught exception: Call to undefined function ereg()
という事になり、Rnoteが動かなくなりこちらも地道に対応していたのだが、10日かかってようやく改修完了となった。 ereg、eregi、ereg_replaceをmbereg、mberegi、mbereg_replaceに置き換えるのはなんてことなかったのだが、変数を文字列で初期化していた
function SkinTagChk($tag,&$str,&$opt){
/*  $opt = '';  // php5.x  */
    $opt = [];  // php7.x
    if(! preg_match('/<%=\$'.$tag.'\s*(.*?)%>/s',$str,$optstr)) return '';
    $tagstr = $optstr[0];
    $tmp = $optstr[1];
function Plugin($name,$func,$opt){
/*  static $g_plugin = '';  // php5.x  */
    static $g_plugin;       // php7.x
    require_once(DIR_PLUGINS.$name.'.php');
    if(!isset($g_plugin[$name])){
        $g_plugin[$name] = new $name;
    }
    return $g_plugin[$name]->$func($opt);
}
の2箇所に手こずった。

あとは2001年5月から、かれこれ20年も使い続けている「CGIでも使えるPNG式画像カウンタ」(pngcntr)が動かなくなっているな…

【参照】
●Qiita https://qiita.com/
OpenSSL 0.9.8で作成した鍵をOpenSSL 1.1.1 でも使う方法
Ubuntu 18.04(LTS)→20.04(LTS)アップグレード方法 2020年5月7日
●OpenSSL https://www.openssl.org/
OpenSSL 1.1.1/changelog
●GitHub https://github.com/
SSL routines:SSL_CTX_use_certificate:ee key too small #33 2019年9月26日
●Ask Ubuntu https://askubuntu.com/
dovecot - imap-login: Error: Failed to initialize SSL server context: Can't load SSL certificate ee key too mall 2020年10月14日
●Ubuntu Wiki https://wiki.ubuntu.com/
FocalFossa/ReleaseNotes/Ja
●Wikipedia http://ja.wikipedia.org/wiki/
Ubuntu
Ubuntuのバージョン履歴
DKIM


[一語一絵/IT系]

VAAPIとffmpeg / 2021-01-24 (日)

昨年12月に続いてASRock H97 Pro4にXeon E3-1265L v3を載せたHaswellでのQSVなハードウェアエンコードの続き。

h264_vaapiffmpegの準備。2017年に倣ってbuildしないとなぁ…と思ってたんだけれども、

ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
  configuration: --extra-libs='-lpthread -lm' --enable-libmfx --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'
root@haswell:~# ffmpeg -encoders 2>/dev/null | grep vaapi
V..... h264_vaapi           H.264/AVC (VAAPI) (codec h264)
V..... hevc_vaapi           H.265/HEVC (VAAPI) (codec hevc)
V..... mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
V..... mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
V..... vp8_vaapi            VP8 (VAAPI) (codec vp8)
V..... vp9_vaapi            VP9 (VAAPI) (codec vp9)
root@haswell:~#
aptで導入されたffmpegでもVAAPI対応しているみたいだ。

とりあえず↓あたりで試してみたところ15倍速くらいでエンコードできた。

root@haswell:~# ${FFMPEG} -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -i ${INPUTFILE} -vf 'format=nv12|vaapi,hwupload,scale_vaapi=w=720:h=480' -c:v h264_vaapi -profile:v 100 -level 40 -qp 20 -aspect 16:9 -c:a copy -y out.mp4
~~
frame= 9883 fps=466 q=-0.0 Lsize= 48007kB time=00:05:29.69 bitrate=1192.8kbits/s dup=17 drop=0 speed=15.5x
video:42022kB audio:5790kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.407860%
root@haswell:~#

【参照】
●web net FORCE https://webnetforce.net/
UbuntuでQSVを利用したエンコードでtsをmp4に爆速変換 2018年7月8日
●mecablog https://blog.misosi.ru/
VAAPIとDockerでDebianでもQSVを使ったh.264エンコードを行う 2017年4月25日
●Qiita https://qiita.com/
QSV 対応 Intel CPU で H.264 のハードウェアエンコード on Linux 2016年9月25日
●FFmpeg https://ffmpeg.org/
https://ffmpeg.org/releases/ffmpeg-4.3.1.tar.gz
CompilationGuide/Ubuntu
●Wikipedia https://en.wikipedia.org/wiki/
Video Acceleration API