| 要件 |
手順 No. |
#command |
期待される値 |
注意書き |
備考 |
| 実行環境構築 |
1. |
|
|
|
|
| Pythonが実行可能であることを確認。 |
1-1 |
#which python |
/usr/bin/python |
|
Cent OS 6を選択していれば標準で入っているはずです。 |
| jubatusのServerとClientを導入する。 |
1-2. |
|
|
|
|
| jubatusのリポジトリを追加する。 |
1-2-1. |
# rpm -Uvh
http://download.jubat.us/yum/rhel/6/stable/x86_64/jubatus-release-6-2.el6.x86_64.rpm |
|
養成読本のp172のバージョンは入手できません。
|
|
| jubatusをインストール |
1-2-2. |
# yum install jubatus jubatus-client |
読み込んだプラグイン:fastestmirror, refresh-packagekit, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
* base: www.ftp.ne.jp
* extras: www.ftp.ne.jp
* updates: www.ftp.ne.jp
jubatus | 2.9 kB 00:00
jubatus/primary_db | 17 kB 00:00
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package jubatus.x86_64 0:0.8.8-1.el6 will be インストール
--> 依存性の処理をしています: zookeeper-client = 3.4.8 のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: ux = 0.1.9 のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: msgpack = 0.5.9 のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: mecab-ipadic = 2.7.0.20070801 のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: mecab = 0.996 のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: log4cxx = 0.10.0 のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: jubatus-msgpack-rpc = 0.4.4 のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: jubatus-mpio = 0.4.5 のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: jubatus-core = 0.2.8 のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: oniguruma >= 5.9 のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libzookeeper_mt.so.2()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libux.so()(64bit) のパッケージ: jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libmsgpack.so.3()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libmecab.so.2()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: liblog4cxx.so.10()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_text.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_system.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_math.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_lang.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_data.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_util_concurrent.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_msgpack-rpc.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_mpio.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: libjubatus_core.so.0()(64bit) のパッケージ:
jubatus-0.8.8-1.el6.x86_64
---> Package jubatus-client.x86_64 0:0.8.8-1.el6 will be インストール
--> 依存性の処理をしています: msgpack-devel = 0.5.9 のパッケージ:
jubatus-client-0.8.8-1.el6.x86_64
--> 依存性の処理をしています: jubatus-msgpack-rpc-devel = 0.4.4 のパッケージ:
jubatus-client-0.8.8-1.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package jubatus-core.x86_64 0:0.2.8-1.el6 will be インストール
---> Package jubatus-mpio.x86_64 0:0.4.5-1.el6 will be インストール
---> Package jubatus-msgpack-rpc.x86_64 0:0.4.4-1.el6 will be インストール
---> Package jubatus-msgpack-rpc-devel.x86_64 0:0.4.4-1.el6 will be
インストール
--> 依存性の処理をしています: jubatus-mpio-devel = 0.4.5 のパッケージ:
jubatus-msgpack-rpc-devel-0.4.4-1.el6.x86_64
---> Package log4cxx.x86_64 0:0.10.0-1.el6 will be インストール
---> Package mecab.x86_64 0:0.996-1.el6 will be インストール
---> Package mecab-ipadic.x86_64 0:2.7.0.20070801-1.el6 will be インストール
---> Package msgpack.x86_64 0:0.5.9-1.el6 will be インストール
---> Package msgpack-devel.x86_64 0:0.5.9-1.el6 will be インストール
---> Package oniguruma.x86_64 0:5.9.1-3.1.el6 will be インストール
---> Package ux.x86_64 0:0.1.9-1.el6 will be インストール
---> Package zookeeper-client.x86_64 0:3.4.8-1.el6 will be インストール
--> トランザクションの確認を実行しています。
---> Package jubatus-mpio-devel.x86_64 0:0.4.5-1.el6 will be インストール
--> 依存性解決を終了しました。
依存性を解決しました
================================================================================
パッケージ アーキテクチャ
バージョン リポジトリー
容量
================================================================================
インストールしています:
jubatus x86_64 0.8.8-1.el6 jubatus 2.2
M
jubatus-client x86_64 0.8.8-1.el6 jubatus 11
k
依存性関連でのインストールをします。:
jubatus-core x86_64 0.2.8-1.el6 jubatus 1.0
M
jubatus-mpio x86_64 0.4.5-1.el6 jubatus 40
k
jubatus-mpio-devel x86_64 0.4.5-1.el6 jubatus 54
k
jubatus-msgpack-rpc x86_64 0.4.4-1.el6 jubatus 88
k
jubatus-msgpack-rpc-devel x86_64 0.4.4-1.el6 jubatus 120
k
log4cxx x86_64 0.10.0-1.el6 jubatus 446
k
mecab x86_64 0.996-1.el6 jubatus 222
k
mecab-ipadic x86_64 2.7.0.20070801-1.el6 jubatus 11
M
msgpack x86_64 0.5.9-1.el6 jubatus 22
k
msgpack-devel x86_64 0.5.9-1.el6 jubatus 61
k
oniguruma x86_64 5.9.1-3.1.el6 base 123
k
ux x86_64 0.1.9-1.el6 jubatus 49
k
zookeeper-client x86_64 3.4.8-1.el6 jubatus 80
k
トランザクションの要約
================================================================================
インストール 15 パッケージ
総ダウンロード容量: 15 M
インストール済み容量: 71 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
(1/15): jubatus-0.8.8-1.el6.x86_64.rpm | 2.2 MB 00:02
(2/15): jubatus-client-0.8.8-1.el6.x86_64.rpm | 11 kB 00:00
(3/15): jubatus-core-0.2.8-1.el6.x86_64.rpm | 1.0 MB 00:00
(4/15): jubatus-mpio-0.4.5-1.el6.x86_64.rpm | 40 kB 00:00
(5/15): jubatus-mpio-devel-0.4.5-1.el6.x86_64.rpm | 54 kB 00:00
(6/15): jubatus-msgpack-rpc-0.4.4-1.el6.x86_64.rpm | 88 kB 00:00
(7/15): jubatus-msgpack-rpc-devel-0.4.4-1.el6.x86_64.rpm | 120 kB 00:00
(8/15): log4cxx-0.10.0-1.el6.x86_64.rpm | 446 kB 00:00
(9/15): mecab-0.996-1.el6.x86_64.rpm | 222 kB 00:00
(10/15): mecab-ipadic-2.7.0.20070801-1.el6.x86_64.rpm | 11 MB 00:05
(11/15): msgpack-0.5.9-1.el6.x86_64.rpm | 22 kB 00:00
(12/15): msgpack-devel-0.5.9-1.el6.x86_64.rpm | 61 kB 00:00
(13/15): oniguruma-5.9.1-3.1.el6.x86_64.rpm | 123 kB 00:00
(14/15): ux-0.1.9-1.el6.x86_64.rpm | 49 kB 00:00
(15/15): zookeeper-client-3.4.8-1.el6.x86_64.rpm | 80 kB 00:00
--------------------------------------------------------------------------------
合計 1.5 MB/s | 15 MB 00:10
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
警告: RPMDB は yum 以外で変更されました。
インストールしています : msgpack-0.5.9-1.el6.x86_64 1/15
インストールしています : jubatus-mpio-0.4.5-1.el6.x86_64 2/15
インストールしています : jubatus-msgpack-rpc-0.4.4-1.el6.x86_64 3/15
インストールしています : msgpack-devel-0.5.9-1.el6.x86_64 4/15
インストールしています : mecab-0.996-1.el6.x86_64 5/15
インストールしています : oniguruma-5.9.1-3.1.el6.x86_64 6/15
インストールしています : jubatus-core-0.2.8-1.el6.x86_64 7/15
インストールしています : mecab-ipadic-2.7.0.20070801-1.el6.x86_64 8/15
インストールしています : jubatus-mpio-devel-0.4.5-1.el6.x86_64 9/15
インストールしています : jubatus-msgpack-rpc-devel-0.4.4-1.el6.x86_6 10/15
インストールしています : ux-0.1.9-1.el6.x86_64 11/15
インストールしています : zookeeper-client-3.4.8-1.el6.x86_64 12/15
インストールしています : log4cxx-0.10.0-1.el6.x86_64 13/15
インストールしています : jubatus-0.8.8-1.el6.x86_64 14/15
インストールしています : jubatus-client-0.8.8-1.el6.x86_64 15/15
Verifying : log4cxx-0.10.0-1.el6.x86_64
1/15
Verifying : jubatus-mpio-devel-0.4.5-1.el6.x86_64
2/15
Verifying : mecab-ipadic-2.7.0.20070801-1.el6.x86_64
3/15
Verifying : jubatus-core-0.2.8-1.el6.x86_64
4/15
Verifying : zookeeper-client-3.4.8-1.el6.x86_64
5/15
Verifying : jubatus-client-0.8.8-1.el6.x86_64
6/15
Verifying : jubatus-msgpack-rpc-devel-0.4.4-1.el6.x86_6
7/15
Verifying : jubatus-mpio-0.4.5-1.el6.x86_64
8/15
Verifying : jubatus-0.8.8-1.el6.x86_64
9/15
Verifying : jubatus-msgpack-rpc-0.4.4-1.el6.x86_64
10/15
Verifying : msgpack-devel-0.5.9-1.el6.x86_64
11/15
Verifying : msgpack-0.5.9-1.el6.x86_64
12/15
Verifying : oniguruma-5.9.1-3.1.el6.x86_64
13/15
Verifying : ux-0.1.9-1.el6.x86_64
14/15
Verifying : mecab-0.996-1.el6.x86_64
15/15
インストール:
jubatus.x86_64 0:0.8.8-1.el6 jubatus-client.x86_64 0:0.8.8-1.el6
依存性関連をインストールしました:
jubatus-core.x86_64 0:0.2.8-1.el6
jubatus-mpio.x86_64 0:0.4.5-1.el6
jubatus-mpio-devel.x86_64 0:0.4.5-1.el6
jubatus-msgpack-rpc.x86_64 0:0.4.4-1.el6
jubatus-msgpack-rpc-devel.x86_64 0:0.4.4-1.el6
log4cxx.x86_64 0:0.10.0-1.el6
mecab.x86_64 0:0.996-1.el6
mecab-ipadic.x86_64 0:2.7.0.20070801-1.el6
msgpack.x86_64 0:0.5.9-1.el6
msgpack-devel.x86_64 0:0.5.9-1.el6
oniguruma.x86_64 0:5.9.1-3.1.el6
ux.x86_64 0:0.1.9-1.el6
zookeeper-client.x86_64 0:3.4.8-1.el6
完了しました!
|
途中に対話型の操作があるのでバッチで実行する場合は適宜
yumのyオプションを検討してください。
この操作で見つかりませんなどのエラーが返る場合は2-1のスペルミスを確認します。
また、配布バージョンが上がっている可能性もあるのでhttp://jubat.us/ja/quickstart.html#jubatusのRed Hat
Enterprise Linuxの手順も確認します。CentOSとRed Hat
Enterprise Linuxの関係の説明については前提1により省略します。 |
|
| pipをインストールしてjubatsus関連のライブラリをpythonで使えるようにする。 |
|
|
|
|
|
| pipが導入「されていない」ことを確認する。 |
1-3-1. |
#which pip |
/usr/bin/which: no pip in
(/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/cou/bin) |
もし、/usr/bin/pipと返ってくる場合、pipはすでに導入されているので手順をジャンプして1-3-3から再開してください。 |
|
| pipを入れるためにez_setupを取得する。 |
1-3-2-1. |
# wget
http://peak.telecommunity.com/dist/ez_setup.py |
--2016-03-22 23:22:28-- http://peak.telecommunity.com/dist/ez_setup.py
peak.telecommunity.com をDNSに問いあわせています... 209.190.5.234
peak.telecommunity.com|209.190.5.234|:80 に接続しています... 接続しました。
HTTP による接続要求を送信しました、応答を待っています... 200 OK
長さ: 10240 (10K) [text/plain]
`ez_setup.py' に保存中
100%[======================================>] 10,240 --.-K/s 時間 0s
2016-03-22 23:22:30 (205 MB/s) - `ez_setup.py' へ保存完了 [10240/10240]
|
|
|
| easy_installを導入する。 |
1-3-2-2. |
# python ez_setup.py |
Setuptools version 0.6c11 or greater has been
installed.
(Run "ez_setup.py -U setuptools" to reinstall or upgrade.) |
|
|
| easy_installを使ってpipを導入する。 |
1-3-2-3. |
# easy_install pip |
Searching for pip
Reading http://pypi.python.org/simple/pip/
Best match: pip 8.1.1
Downloading
https://pypi.python.org/packages/source/p/pip/pip-8.1.1.tar.gz#md5=6b86f11841e89c8241d689956ba99ed7
Processing pip-8.1.1.tar.gz
Running pip-8.1.1/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-SemgER/pip-8.1.1/egg-dist-tmp-qupkJK
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
Adding pip 8.1.1 to easy-install.pth file
Installing pip script to /usr/bin
Installing pip2.6 script to /usr/bin
Installing pip2 script to /usr/bin
Installed /usr/lib/python2.6/site-packages/pip-8.1.1-py2.6.egg
Processing dependencies for pip
Finished processing dependencies for pip
|
|
|
| pipが導入されたことを確認する。 |
1-3-2-4. |
# which pip |
/usr/bin/pip |
|
|
| pipを使ってjubatusのライブラリを導入する。 |
1-3-3. |
# pip install jubatus |
DEPRECATION: Python 2.6 is no longer supported
by the Python core team, please upgrade your Python. A future version of pip
will drop support for Python 2.6
Collecting jubatus
/usr/lib/python2.6/site-packages/pip-8.1.1-py2.6.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:315:
SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name
Indication) extension to TLS is not available on this platform. This may cause
the server to present an incorrect TLS certificate, which can cause validation
failures. For more information, see
https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip-8.1.1-py2.6.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120:
InsecurePlatformWarning: A true SSLContext object is not available. This
prevents urllib3 from configuring SSL appropriately and may cause certain SSL
connections to fail. For more information, see
https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading jubatus-0.8.2.tar.gz
Collecting msgpack-rpc-python>=0.3.0 (from jubatus)
Downloading msgpack-rpc-python-0.4.tar.gz
Collecting msgpack-python (from msgpack-rpc-python>=0.3.0->jubatus)
Downloading msgpack-python-0.4.7.tar.gz (126kB)
100% |████████████████████████████████| 133kB 906kB/s
Collecting tornado>=3 (from msgpack-rpc-python>=0.3.0->jubatus)
Downloading tornado-4.3.tar.gz (450kB)
100% |████████████████████████████████| 460kB 972kB/s
Requirement already satisfied (use --upgrade to upgrade): ordereddict in
/usr/lib64/python2.6/site-packages (from
tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Collecting backports.ssl-match-hostname (from
tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Downloading backports.ssl_match_hostname-3.5.0.1.tar.gz
Collecting singledispatch (from
tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting certifi (from
tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Downloading certifi-2016.2.28-py2.py3-none-any.whl (366kB)
100% |████████████████████████████████| 368kB 1.1MB/s
Collecting backports-abc>=0.4 (from
tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Downloading backports_abc-0.4-py2.py3-none-any.whl
Collecting six (from
singledispatch->tornado>=3->msgpack-rpc-python>=0.3.0->jubatus)
Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: msgpack-python, backports.ssl-match-hostname,
six, singledispatch, certifi, backports-abc, tornado, msgpack-rpc-python,
jubatus
Running setup.py install for msgpack-python ... done
Running setup.py install for backports.ssl-match-hostname ... done
Running setup.py install for tornado ... done
Running setup.py install for msgpack-rpc-python ... done
Running setup.py install for jubatus ... done
Successfully installed backports-abc-0.4 backports.ssl-match-hostname-3.5.0.1
certifi-2016.2.28 jubatus-0.8.2 msgpack-python-0.4.7 msgpack-rpc-python-0.4
singledispatch-3.4.0.3 six-1.10.0 tornado-4.3
/usr/lib/python2.6/site-packages/pip-8.1.1-py2.6.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120:
InsecurePlatformWarning: A true SSLContext object is not available. This
prevents urllib3 from configuring SSL appropriately and may cause certain SSL
connections to fail. For more information, see
https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning |
|
|
| jubatusのサーバー(サービス)を起動させる。 |
|
|
|
jubatusは用途に応じて「コマンド」と「conf」の両方を変更する必要があります。異常検知以外の機能を使いたい場合にはコマンドとconfの両方を変更しなければなりません。 |
|
| |
1-4-1. |
# lsof -i:9199 |
(何も返ってこないこと) |
ここで何か返って来る場合、すでに別のサービスが9199番ポートを使っている可能性があります。
既存の9199番ポートをとめるか、ここ以後の手順をすべて別のポートに変えて読み替える必要があります。
|
|
| |
1-4-2. |
ファイルを新規作成して、p178のリスト1のanomaly_conf.jsonを作成する。 |
|
pythonコードではなくjsonであることに注意してください。そのためインデントなどは気にしなくても動きます。 |
|
| |
1-4-3. |
# jubaanomaly --configpath anomaly_conf.json
& |
2016-03-26 14:30:12,411 4956 INFO [server_util.cpp:373] starting
jubaanomaly 0.8.8 RPC server at 192.168.111.131:9199
pid : 4956
user : cou
mode : standalone mode
timeout : 10
thread : 2
datadir : /tmp
logdir :
log config :
zookeeper :
name :
interval sec : 16
interval count : 512
zookeeper timeout : 10
interconnect timeout : 10
2016-03-26 14:30:12,411 4956 INFO [server_util.cpp:130] load config from
local file: /home/cou/anomaly_conf.json
2016-03-26 14:30:12,420 4956 INFO [anomaly_serv.cpp:141] config loaded: {
"converter" : {
"string_rules" : [
{ "key" : "*", "type" : "str", "sample_weight" : "bin" , "global_weight" :
"bin" }
],
"num_rules" : [
{ "key" : "*", "type" : "num" }
]
},
"parameter" : {
"nearest_neighbor_num" : 5,
"reverse_nearest_neighbor_num" : 5,
"method" : "euclid_lsh",
"parameter" : {
"hash_num" : 512
}
},
"method" : "light_lof"
}
2016-03-26 14:30:12,421 4956 INFO [server_helper.hpp:223] start listening at
port 9199
2016-03-26 14:30:12,421 4956 INFO [server_helper.hpp:230] jubaanomaly RPC
server startup
|
jubaanomaly RPC server startup
の表示を確認できたらEnterキーを押せばコマンドプロンプトに戻れます。
【注意】
OSを再起動するたびにこの操作が必要です。 面倒な場合はOS起動時にサービスを起動するように設定しておきます。
【注意】 誤ってjubaclassifierコマンドなどでjsonファイルを読み込むと以下のような文言を含むエラーが返ってきます。
unsupported method (classifier(light_lof))
特に、養成読本を読みながら手を動かすと、p171でインストールチェックをするためにjubaclassifierを実行したあとにコマンドを履歴から呼び出すと起こしやすいミスです。
(養成読本の第2部特集5第3章ではjubaanomalyのコマンドについての記述が一切ないので注意してください)
|
|
| ポートがLISTENしていることの確認 |
1-4-4. |
# lsof -i:9199 |
COMMAND PID USER FD TYPE DEVICE SIZE/OFF
NODE NAME
jubaanoma *** *** 6u IPv4 26404 0t0 TCP *:9199 (LISTEN) |
これが期待値と異なる場合、1-4-3に失敗している可能性があります。 |
|