メールサーバの移行

イメージ
 自前のメールサーバを停止 これまで、自ドメインのメールサーバはVPS上に構築していた。 ・Ubuntu Server ・Postfix ・Dovecot ・spamAssassinと、BlackListの利用 Spam対策を行ってきたし、サーバ上でメールをトリガーにして各種プログラムを動かしたりしてきた。 メールサーバのメンテナンスは結構面倒くさくて、  ・Disk容量のチェック  ・不正アクセスのチェック  ・各種セキュリティパッチの適用 など、手間がかかる。 そこで、外部のサーバを利用することに…。 結構安くて使い勝手の良さそうなのが、「さくらのメールボックス」 3年契約で、3070円とな…。  メールアドレスは自分のだけなので、20GBまで利用可能!  (Gmailより大きいねぇ) ということで、早速契約。 アカウント設定を行って、既存のDNSを書き換える。WHOISも書き換えて完了。 SMTPとIMAPが利用できればOK。 ちょうど、GoogleがSPF設定していないと受信しないし、DKIMおよびDMARCに対応していないメールを弾くようになったので、対応しているのを確認。 さくらサーバ自体は、これまでお客さんのサーバとして何件も利用しているので、利用方法も難しくはない。  Webメールにも対応しているので、いざという場合にもありがたい。 ということで、各メールソフトの設定を変更。  PC(常時使用する3台)とタブレット、スマートフォンと台数は多いがそれ程手間はかからない。 問題は、旧サーバで送受信したメールの履歴だけれど、これはThunderbrdを使ってローカルに保存することで回避。  本当は、サーバtoサーバでMailboxに残そうとも考えたんだけど、古いメールはそれ程必要ないし、ローカルにバックアップしてあれば凌げるので、良しとする。 移行時にDNSの反映で若干時間がかかったものの、問題なく送受信できるのを確認して、作業完了。  これでメンテナンスの手間が減るので、安いもんです。

csvqのbuild

使おうと思ったら、無かった…

以前あまりに便利だったので、buildして使っていた「csvq」だけど、マシンを入れ替えた際に入れ忘れていたらしい…。

前にbuildした時は、さっくりと動作したので、最新バージョンを持ってきてbuildすればいいやぁと思って作業してみると、エラーを吐きまくる。
バイナリ持ってきてきても良いけど、時間がある今なので、頑張ってみることにした。


Installation

Install executable binary
Download an archive file from release page.
Extract the downloaded archive and add a binary file in it to your path.
Build from source
Requirements

Go 1.11 or later (ref. Getting Started - The Go Programming Language)
Build with one of the following ways
Use go get
$ go get github.com/mithrandie/csvq
Build with strict dependencies
$ go get -d github.com/mithrandie/csvq
Change directory to $GOPATH/src/github.com/mithrandie/csvq
$ env GO111MODULE=on go install




githubに書かれているとおりに、

$ go get github.com/mithrandie/csvq



すると、以下のようなエラーが大量に…。

$ go get github.com/mithrandie/csvq

# github.com/mithrandie/csvq

../../go/src/github.com/mithrandie/csvq/main.go:35:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:39:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:44:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:48:15: cannot use cli.BoolFlag literal (type cli.BoolFlag) as type cli.Flag in slice literal:
cli.BoolFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:52:18: cannot use cli.Float64Flag literal (type cli.Float64Flag) as type cli.Flag in slice literal:
cli.Float64Flag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:57:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:61:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:66:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:71:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:75:17: cannot use cli.StringFlag literal (type cli.StringFlag) as type cli.Flag in slice literal:
cli.StringFlag does not implement cli.Flag (Apply method has pointer receiver)
../../go/src/github.com/mithrandie/csvq/main.go:75:17: too many errors


しかも、最後の行を見るとtoo many errorsとか言ってくるし…。


さて、このErrorの理由をググってみると、

こんな情報をゲット。


良くわからないが、該当する行を全て書き換えてみる。

main.goのAppFlag内のcli.〜に該当する部分を全て&を先頭に付加。

保存して、buildしてみる。


$ make

GOPATH=/home/yoshimura/go/src/github.com/mithrandie/csvq/build go build -ldflags="-X github.com/mithrandie/csvq/lib/query.Version=v1.13.3-3-g119a62d" -o /home/yoshimura/go/src/github.com/mithrandie/csvq/build/bin/csvq
go: downloading github.com/urfave/cli v1.20.0
go: downloading github.com/mithrandie/ternary v1.1.0
go: downloading github.com/mithrandie/go-text v1.3.1
go: downloading github.com/mitchellh/go-homedir v1.0.0
go: downloading github.com/mithrandie/go-file/v2 v2.0.2
go: downloading golang.org/x/crypto v0.0.0-20181112202954-3d3f9f413869
go: downloading github.com/mithrandie/readline-csvq v1.1.1
go: downloading golang.org/x/text v0.3.1
go: downloading golang.org/x/sys v0.0.0-20191029155521-f43be2a4598c


おっ!無事に通った。

build/bin/ を確認すると、csvqが出来上がっている。


念の為、バージョンを確認。

$ ./csvq -v

csvq version v1.13.3-3-g119a62d

ちゃんと、出来上がっているようだ。


helpもInteractiveモードも動作する。


試しに、test.csvを作成し、SQLを叩いてみる。
https://qiita.com/mithrandie/items/146564e748ee235709c0


$ ./csvq
> select * from `test.csv`
+----+------------------+-----------+
| id |       name       | parent_id |
+----+------------------+-----------+
| 1  | ラダトーム       |   NULL    |
| 2  | りゅうおうのしろ |   NULL    |
| 3  | ガライ           | 1         |
| 4  | マイラ           | 1         |
| 5  | リムルダール     | 1         |
| 6  | ドムドーラ       | 1         |
| 7  | メルキド         | 1         |
| 8  | あめのほこら     | 4         |
| 9  | せいなるほこら   | 5         |
+----+------------------+-----------+


問題はなさそう…。

ということで、こいつは~/binに格納しておく。


ただ、ダウンロードしたバイナリと比較してみると微妙にサイズが異なるので、少々心配だけど、動けばOKなので、良しとする。

ちなみに、
csvq-v1.13.1-linux-amd64.tar.gz 内のcsvqは、15,672,673 バイト
自分でbuildしたものは14,517,598バイトなのは、何故かなぁ〜?

ダウンロードしたバイナリのバージョンは、1.13.1とsrcの方が若干新しいのかもしれないと言うことにしておこう。



コメント

このブログの人気の投稿

WPS Officeで日本語入力ができない

Virtualboxとnvidiaドライバ

VirtualBoxでUSBから起動