なんとな~くしあわせ?の日記

「そしてそれゆえ、知識そのものが力である」 (Nam et ipsa scientia potestas est.) 〜 フランシス・ベーコン

Hadoop関連ソフトウェアを手っ取り早くパッケージでインストールする

Apache Bigtop

Bigtop - Apache Bigtop

Bigtop is an Apache Foundation project for Infrastructure Engineers and Data Scientists looking for comprehensive packaging, testing, and configuration of the leading open source big data components. Bigtop supports a wide range of components/projects, including, but not limited to, Hadoop, HBase and Spark.

Bittopは包括的なパッケージ、テストそしてオープンソースビッグデータ構成要素の設定を探しているインフラエンジニアやデータサイエンティストのためのApacheソフトウェア財団のプロジェクトです。Bigtopは広い範囲の構成要素/プロジェクトを含んでおり、しかしながらその範囲はHadoop、HBaseやSparkに限りません。

Debianにインストール

# cd /etc/apt/sources.list.d
# wget http://www.apache.org/dist/bigtop/bigtop-1.1.0/repos/debian8/bigtop.list
# apt-get update
# apt-get install pig

Apache PigでShift_JISテキストをUTF-8化

Apache PigでShift_JISテキストをUTF-8

hdfs上にファイルを取り込む際、デフォルトの文字コードUTF-8らしい。
どうやって取り込むか悩んだが、UDFという方法を見つけた。

User Defined Function:UDF

ひしだまさんのサイトに載っている通りEvalFuncを継承するクラスを作成し、exec関数を実装する。

Conv2Utf8
  • このソースをmavenを使ってjarファイル化し、「conv2utf8-1.0-SNAPSHOT.jar」とかにしておく
package your.package.name;

import java.io.IOException;
import org.apache.pig.impl.util.WrappedIOException;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.data.DataType;
import org.apache.pig.data.DataByteArray;

public class Conv2Utf8 extends EvalFunc<String> {

    public String exec(Tuple input) throws IOException {
	if (input == null || input.size() == 0) {
	    return null;
	}
	DataByteArray barray = (DataByteArray) input.get(0);
	byte[] bytes = barray.get();
	return new String(bytes, "MS932");
    }
}
test.pig

REGISTER conv2utf8-1.0-SNAPSHOT.jar

TEMP = LOAD 's3://xxxxx/sample.txt' AS (raw_data:bytearray);
DATA = FOREACH TEMP GENERATE your.package.name.Conv2Utf8(raw_data);

DUMP DATA;

Pigのデータ型

Pig Latin Basics

これを使えばzipファイル等も解凍できるなあと思った

Msys2でSSL certificate problem: unable to get local issuer certificateが出たとき

エラー内容

git cloneしようとして、以下のようなエラー

fatal: unable to access 'https://gitlab-xxxx/yyyy/xxxx.git/': SSL certificate problem: unable to get local issuer certificate

原因

対象のGitサーバが使用している証明書のRoot証明書がmsys2に登録されてない。

対策

.gitconfigをちゃんと設定すればよし

qiita.com

対策の内容
  • 普段はGit(というより、システムの)デフォルトCA証明書を使用してGitサーバにアクセスする
  • 特定のサイトだけ、必要なCA証明書を指定してGitでアクセスするようにする
    • 必要な証明書は複数の場合があります、ブラウザから必要な証明書出してcer形式で出力しcatで結合するとよい

上のサイトに書いてあるように、こんなpemファイル(拡張子は何でもよい)を作る

簡単に言えば,以下のようにSSLサーバ証明書,1つ上の中間CA証明書,さらにその上の中間CA証明書を (テキストとして) 結合し保存して下さい.

-----BEGIN CERTIFICATE-----
SSLサーバ証明書の内容
-----END CERTIFICATE-----

-----BEGIN CERTIFICATE-----
1つ上の中間CA証明書の内容
-----END CERTIFICATE-----

-----BEGIN CERTIFICATE-----
さらにその上の中間CA証明書の内容
-----END CERTIFICATE-----
動作チェック
  • git ls-remote を実行してやればOK
$ git ls-remote https://github.com/Hiroyuki-Nagata/foobar.git
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        HEAD
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/master

$ git ls-remote https://gitlab.intra.com/foobar.git
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        HEAD
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx        refs/heads/master