CloudflareとLet’s Encryptを同時に使ってると、Let’s Encryptが更新できない件
- tls: handshake failure
- There were too many requests of a given type :: Error creating new authz :: Too many invalid authorizations recently.. Skipping.
tls: handshake failure
Let's Encryptで更新かけるとき、こんなエラーログが出る
# cd /opt/letsencrypt/ # ./certbot-auto renew (省略) Attempting to renew cert from /etc/letsencrypt/renewal/freestylewiki.xyz.conf produced an unexpected error: Failed authorization procedure. freestylewiki.xyz (tls-sni-01): urn:acme:error:tls :: The server experienced a TLS error during domain verification :: remote error: tls: handshake failure. Skipping.
remote error: tls: handshake failure. で検索をかけると原因がわかった。
解決策
I had Cloudflare running on the site, once I paused it I could renew the certs.
Cloudflareを一時停止状態にすればよいらしい。助かった〜
Cloudflare側の設定
これ
- 一旦DevelopmentModeに変えて
- Pauseを押す
この後、certbot-auto renew を再実行するとうまく更新できた。
There were too many requests of a given type :: Error creating new authz :: Too many invalid authorizations recently.. Skipping.
何回もcertbot-auto renewしてたら、以下のようなわかりやすいエラーが出た。メンゴメンゴ。
Attempting to renew cert from /etc/letsencrypt/renewal/freestylewiki.xyz.conf produced an unexpected error: urn:acme:error:rateLimited :: There were too many requests of a given type :: Error creating new authz :: Too many invalid authorizations recently.. Skipping.
解決策
1時間だけ待つ
だるいな。
Cloudflare側に証明書もたせる設定もできそうだし、そのほうがいいのかねえ…
AOJ - DSL_1_A (Union-Find) を解いてみた
DSL_1_Aは、Coursera Algorithm I で最近習ったばかりのUnion-Findです
AOJ - DSL_1_A
互いに素な集合 Union Find| データ構造ライブラリ | Aizu Online Judge
quick find で求めてみる
時間切れでアウトです
- 授業でも言われてましたが、quick-findは要素の更新を行う操作がどうしても遅いのです
id.collect! { |element|
(element == updated) ? updating : element
}
quick-unionで求めてみる
これだと余裕で解けました。
追記 2018/07/11
- 嘘です、07:93秒もかかってるので使い物になりません。。。
quick-unionのミソは、unionにしてもfindの操作にしてもどちらの場合でも最初に木構造の最上位を求めることだと思われます。(それをしないと、配列上で複数の親をもつ構造が表現できない)
# coding: utf-8 class QuickUnion attr :id def initialize(n) @id = (0...n).to_a end def root(i) while i != @id[i] do i = @id[i] end i end # find, check if p and q has the same root def same?(p, q) root(p) == root(q) end # union, to merge components containing p and q # set id of p's root to the id of q's root def unite(p, q) i = root(p) j = root(q) @id[i] = j end end lines = $stdin.read array = lines.split("\n") n = array[0].split(" ")[0].to_i q = array[0].split(" ")[1].to_i un = QuickUnion.new(n) for i in 1..q com = array[i].split(" ")[0] x = array[i].split(" ")[1].to_i y = array[i].split(" ")[2].to_i if com == '0' # unite(4,3) id[4] = 3, 4の頭を3にする un.unite(x, y) else # same puts un.same?(x, y) ? "1" : "0" end end
しかしやっぱりRubyは使いやすい
計算量の削減 O(α(N))
経路圧縮とrankの実装を行うことで処理時間をO(α(N))まで削減できます。
・00:22秒で終了しました。これでようやくAtCoderで使えるレベル
# coding: utf-8 class UnionFind attr :id, :rank def initialize(n) @id = (0..n).to_a @rank = Array.new(n,0) end def root(i) if @id[i] == i or i == @id[@id[i]] i else @id[i] = root(@id[i]) @id[i] end end # find, check if p and q has the same root def same?(p, q) root(p) == root(q) end # union, to merge components containing p and q # set id of p's root to the id of q's root def unite(p, q) i = root(p) j = root(q) return if i == j if @rank[i] < @rank[j] @id[i] = j else @id[j] = i; @rank[i]+=1 if @rank[i] == @rank[j] end end end lines = $stdin.read array = lines.split("\n") n = array[0].split(" ")[0].to_i q = array[0].split(" ")[1].to_i un = UnionFind.new(n) for i in 1..q com = array[i].split(" ")[0] x = array[i].split(" ")[1].to_i y = array[i].split(" ")[2].to_i if com == '0' # unite(4,3) id[4] = 3, 4の頭を3にする un.unite(x, y) else # same puts un.same?(x, y) ? "1" : "0" end end
Hadoop Hive用にDockerのイメージを作ってみた
動機
- Hiveのテスト時にいちいちEMRを起動したくない
参考にしたもの
DockerとDocker Composeについては以下のサイト
Apache Bigtopについては以下のサイト
how i install bigtop 1.1.0 on ubuntu 16.04 · GitHub
Running various Bigtop components - Apache Bigtop - Apache Software Foundation
使い方
Windowsの場合はsudoいらない
$ sudo docker pull hiroyuking/docker-hiveserver2 $ sudo docker-compose -f docker-compose.yml up $ sudo docker exec -it dockerhiveserver2_hiveserver2_1 /bin/bash
意外ににDockefileは簡単に書けるようだ。しかしADDやCMDという動的な処理は1ファイルにつき1回に制限されている。
この特性を理解すれば本番環境でDockerというのもいいかもしれない。
今のところよさげな特徴
- 起動が早い
- 共有が簡単
- VMをパッケージ化できる