MacOSX に Python2, Python3 仮想環境構築

MacOSX に Python2, Python3 仮想環境構築

経緯

MacOSX デフォルトでは python 2 系。

python 2.7 は 2020 年までのサポート なので
python 3 系 に慣れておこうということで
3 系環境を構築しようと思いました。

ですが
dlib など Python 2 系でないとうまく設定ができなかった経緯があり
(※自分の不手際の可能性もありますが)
両方残そうということで両仮想環境を構築します。

環境

1
2
3
4
5
$ sw_vers

ProductName: Mac OS X
ProductVersion: 10.11.5
BuildVersion: 15F34

Homebrew インストール

以下オフィシャルサイト参照してください。

Homebrew Ja

Python2, 3 インストール

2016/07/28 現在、 python = 2.7.10, python3 = 3.4.3

1
$ brew install python python3 pyenv

設定ファイル

.bashrc もしくは .zshrc に追記します。

以下仮に .bashrc とします。

1
$ vi ~/.bashrc
1
2
3
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
  • 設定読み込み
1
$ source ~/.bashrc

virtualenv インストール

1
sudo easy_install virtualenv

仮想環境構築

  • python2 での仮想環境構築
1
2
3
$ which python

/usr/local/bin/python2.7
1
$ virtualenv -p /usr/local/bin/python2.7 ~/py2env
  • python3 での仮想環境構築
1
2
3
$ which python3

/usr/local/bin/python3
1
$ virtualenv -p /usr/local/bin/python3 ~/py3env

仮想環境切り替え

  • Python 2.7 仮想環境へ切り替え
1
$ source ~/py2env/bin/active
  • Python 3.4 仮想環境へ切り替え
1
$ source ~/py3env/bin/active

今更ですが備忘録的まとめでした。

Zabbix + Reactio 連携

Zabbix + Reactio 連携

概要

Reactio の無料化によりその機能が解放され、様々な監視・アラートツールとの連携が可能になりました。
これを機に Zabbix + Reactio 連携したのでまとめました。

Reactio が無料になります

環境

  • Zabbix 3.0
  • CentOS Linux release 7.2.1511 (Core)

Zabbix 3.0 がインストールされ起動されていることを前提とします。

Zabbix 管理画面で Host 設定

※既に設定されている場合はスキップしてください。

Configuration > Hosts > create

  • Host name: Project1

Reactio プロジェクト作成

プロジェクト毎にインシデントを管理します。

https://<Organization ID>.reactio.jp/settings/project

Zabbix 管理画面で設定している Host 名を Project 名とします。

Reactio API 発行

プロジェクト作成ページと同ページ内にある API 項目の 「+」ボタンクリックし API KEY 発行します。

zabbix-reactio インストール

1
2
$ cd /usr/lib/zabbix/alertscripts
$ git clone http://github.com/zabbix-reactio

Zabbix DB 情報 と Reactio で作成した Project と 発行した API KEY を設定ファイルに設定

1
2
$ cd /usr/lib/zabbix/alertscripts/zabbix-reactio
$ vi config.inc
  • db_info に DB 情報設定
  • <Organization ID> 設定
  • Project = API KEY 設定
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[db_info]
host = <DB Host>
user = <DB user>
pass = <DB pass>
db = <DB name>

[reactio_url]
default = https://<Organization ID>.reactio.jp/api/v1/incidents

[api_key]
Project1 = <Project1's API KEY>
Project2 = <Project2's API KEY>
Project3 = <Project3's API KEY>
...
...

DB カラム追加

  • Zabbix alerts テーブルに Reactio Incident ID カラムを追加します。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ cd /usr/lib/zabbix/alertscripts/zabbix-reactio
$ mysql -h <DB Host> -u <DB user> -p<DB pass> <DB name> -e "`cat add_reactioincidentid.sql`"
$ mysql -h <DB Host> -u <DB user> -p<DB pass> <DB name> -e "SHOW COLUMNS FROM alerts"

+---------------------+---------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+---------------------+------+-----+---------+-------+
| alertid | bigint(20) unsigned | NO | PRI | NULL | |
| actionid | bigint(20) unsigned | NO | MUL | NULL | |
| eventid | bigint(20) unsigned | NO | MUL | NULL | |
| userid | bigint(20) unsigned | YES | MUL | NULL | |
| clock | int(11) | NO | MUL | 0 | |
| mediatypeid | bigint(20) unsigned | YES | MUL | NULL | |
| sendto | varchar(100) | NO | | | |
| subject | varchar(255) | NO | | | |
| message | text | NO | | NULL | |
| status | int(11) | NO | MUL | 0 | |
| retries | int(11) | NO | | 0 | |
| error | varchar(128) | NO | | | |
| esc_step | int(11) | NO | | 0 | |
| alerttype | int(11) | NO | | 0 | |
| reactio_incident_id | int(11) | NO | | 0 | | ← 追加されているのが確認できます
+---------------------+---------------------+------+-----+---------+-------+

Reacito では全てのインシデントは ID で管理されています。
Zabbix で障害アラート通知時に Reactio インシデント作成 API をコールし インシデント ID を保存します。

このインシデント ID は Zabbix で障害回復アラート通知時に Reatio インシデントステータス更新 API をコールする際に利用します。

Zabbix Media types: Reactio 作成

Administration > Media types Create media type ボタンクリック

以下値を入力し Add ボタンクリック

Item Value
Name Reactio
Type Script
Script name zabbix-reactio/reactio.php
Script Parameters 1 {ALERT.SUBJECT}
Script Parameters 2 {ALERT.MESSAGE}

Zabbix Users: Reactio 作成

Administration > Users Create media type ボタンクリック

  • Reactio ユーザ作成
  • Media タブをクリックし Media 情報入力
  • Permission タブをクリックし Zabbix Super Admin 選択
  • Add ボタン クリックし一覧に表示されることを確認

Zabbix Actions: Reactio Notification 作成

Configuration > Actions Create ボタンクリック

  • Action タブ選択し Action 情報入力
Item Value
Name Reactio Notification
Default subject PROBLEM alert - {TRIGGER.NAME} is {TRIGGER.STATUS}
Default message HOST: {HOST.NAME}
TRIGGER_NAME: {TRIGGER.NAME}
TRIGGER_STATUS: {TRIGGER.STATUS}
TRIGGER_SEVERITY: {TRIGGER.SEVERITY}
DATETIME: {DATE} / {TIME}
ITEM_ID: {ITEM.ID1}
ITEM_NAME: {ITEM.NAME1}
ITEM_KEY: {ITEM.KEY1}
ITEM_VALUE: {ITEM.VALUE1}
EVENT_ID: {EVENT.ID}
TRIGGER_URL: {TRIGGER.URL}
Recovery message チェック
Recovery subject RECOVERY alert - {TRIGGER.NAME} is {TRIGGER.STATUS}
Recovery message HOST: {HOST.NAME}
TRIGGER_NAME: {TRIGGER.NAME}
TRIGGER_STATUS: {TRIGGER.STATUS}
TRIGGER_SEVERITY: {TRIGGER.SEVERITY}
DATETIME: {DATE} / {TIME}
ITEM_ID: {ITEM.ID1}
ITEM_NAME: {ITEM.NAME1}
ITEM_KEY: {ITEM.KEY1}
ITEM_VALUE: {ITEM.VALUE1}
EVENT_ID: {EVENT.ID}
TRIGGER_URL: {TRIGGER.URL}
Enabled チェック

以下項目から判断して Reactio API を叩いてます。

  • subject の PROBLEM/RECOVERY
  • HOST: {HOST.NAME}
  • EVENT_ID: {EVENT.ID}

メッセージを整形する場合でも、 上記項目は残しておくようにしてください。

  • Operations タブ選択し Operations 情報入力

以上 Zabbix で Reactio 連携設定完了しました。

実行結果

  • インシデント作成できた!
  • 作成したインシデントのステータスが更新された!

今後

当方、運用し始めです。
障害レベルによってメッセージを変更したりと今後更新検討致します。

是非以下も合わせて Zabbix-Slack 連携もご利用ください。

zabbix3-slack

以上
ご清聴ありがとうございました。

Raspberry Pi 3 B に Raspberry Jessie セットアップ

概要

Amazon Prime 会員の無料体験版で
Raspberry Pi 3 B 買いました♪

開発 Ready な状態を作るべく
そのセットアップ方法をまとめました。

環境

  • MacBook Pro : MacOSX 10.11.5
  • Wifi 環境

買ったもの

以下最低限必要なものです。

計 8,459円

  • Raspberry Pi 3 Model B (ケース付き): 5,980円
  • SD カード (32GB) : 1,080円
  • 電源 (2.5A対応): 1,399円

電源はPCのUSBポートからでも良いかな、と思ってましたが
Pi3Bの推奨電流が 2.5 A となった為、2.5 A 対応電源が必要になりました。

その他

大体持ち合わせてるのでは、と思います。
会社のゴミ山に捨ててあるのではないでしょうか。

  • HDMI ケーブル : 691円
  • USBキーボード : 530円
  • USBマウス : 698円

その他含めても 10,378円。こりゃやるっきゃない。

早速セットアップ手順へ

SDカード フォーマット

SD カードフォーマットアプリ インストール

以下サイトからSDカードフォーマッターアプリをダウンロードしフォーマットします。

SD Memory Card Formatter

Macであれば for Mac を選択し
同意してダウンロードします。

ファイルシステム確認

フォーマットするSDカードがどれか知る必要がある為、
SDカードを差し込む前にターミナルから以下実行

1
$ df -h

SDカードをMacに差し込む

※MacBook AirではSDカード差し込み口がないのでカードリーダで読込みます。

もう一度 df -h すると
新たに追加されたのが SDカード のファイルシステムです。

SDFormatter でフォーマット

※ 自分は名前を「RASP3B」としました。

もう一度 df -h

ディスクイメージ名が変更されているのがわかります。

以上でSDカードフォーマット完了です。

ディスクイメージに Raspbian Jessie (Latest OS) を書き込み

Raspbian Jessie ダウンロード

オフィシャルサイトから最新 Raspbian OS をインストールします。
数分掛かります。

Raspbian

1
2
3
4
5
$ cd ~/Downloads
$ unzip 2016-05-27-raspbian-jessie.zip
$ ls -al 2016-05-27-raspbian-jessie.*
-rw-r--r--@ 1 kenzo staff 4019191808 5 27 20:50 2016-05-27-raspbian-jessie.img
-rw-r--r--@ 1 kenzo staff 1393896178 7 10 19:27 2016-05-27-raspbian-jessie.zip

アンマウント

先ほど確認した ファイルシステム名 /dev/disk2s1 から s1 を取り除いた、
イメージ対象をアンマウントする

1
$ diskutil umountDisk /dev/disk2

ダウンロードしたイメージを書き込み

1
$ sudo dd if=/Users/<User>/Downloads/2016-05-27-raspbian-jessie.img of=/dev/rdisk2 bs=1m
  • disk2r を頭に足すとアンバッファモードで実行し速度アップします。
  • bs=1m … 1度に書き込むサイズ

257 秒かかった 汗

以上で Raspberry Pi に挿す SDカード が作成できました。

SDカード取り出し

1
$ diskutil eject /dev/disk2

Raspberry PI 3 に 各種接続

全て接続し終わるまでRaspberry Pi に電流を流さないでください。

SDカード挿入

USBキーボード・マウス、SDカード、電源 接続

全てが深く刺さっているのを確認した後
いよいよ電源を電源アダプタに接続します。

ついた!

なにやら読み込みが始まった!

※我が家はテレビがディスプレイ代わりです。

おぉ〜GUIのトップ画面がでてきた!

まず成功♪

Raspberry Pi 各種設定

Menu > Preferences > Raspberry Pi Configuration クリック

SDカードの全容量を利用可能にする

  • System タブの Expand Filesystem ボタンクリック

以上でSDカードの全容量を利用可能になります。

Locale設定

  • Localisation タブの Set Locale ボタンをクリックします。
  • Language : ja (Japanese) 選択
  • Country : JP (Japan) 選択
  • Character Set : UTF-8 選択

上記選択し OK ボタンクリック

Timezone設定

  • Localisation タブ > Set Timezone ボタン クリック

再度 Set Timezone ボタンをクリックすると Asia/Tokyo が選択されています。

キーボード設定

  • Localisation タブの Set Keyboard ボタンをクリック

  • Country : Japan 選択

  • Variant : Japanese 選択

以上選択しOK ボタンクリック

Wifi 設定

  • Wifi 選択しパスフレーズ入力し Wifi接続
  • Wifi 接続が確認できます

MacOS → Raspberry Pi SSH 接続

  • Raspberry Pi で Terminal 起動
1
$ ifconfig
  • Mac から raspberry pi に SSH接続
1
2
3
4
5
6
7
8
9
10
[MacOSX local]$ ssh pi@192.168.xxx.xxx
pi@192.168.11.18's password: <デフォルトパスワードは "raspberry">

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Jul 11 23:08:51 2016

SSH ログインが確認できました!

追記 (2016-07-08)

あとあと気づいたのだけど
わざわざ画面をiPhoneで撮影せずとも
Remote Desktop して綺麗なものを取ればよかった。。

ということで
SSH ついでに Remote Desktop 機能を要する tightvncserver インストール

1
2
3
4
5
$ sudo apt-get install tightvncserver
$ vncserver

// 起動
$ vncserver :1
  • 設定したホスト名を指定してRemote Desktop し画面共有
1
vnc://raspberrypi.local:5901

ブラウザを開いてみる

インターネットに接続されているのがわかります。

ただし
日本語がもれなく豆腐。。

Zabbix でも以前日本語フォントがなくて同様の事象がありました。。

日本語フォントをインストールする必要があります。

Raspberry Pi に日本語フォントインストール

1
2
3
4
5
6
$ sudo apt-get update
$ sudo apt-get install fonts-vlgothic
$ sudo apt-get install ibus-mozc

// 再起動
$ sudo shutdown -r now

もう一度ブラウザを開いてみる

  • 日本語がちゃんと表示されています。
  • 日本語入力できるよう、日本語 - Mozc 選択

以上でセットアップ完了です。

ご清聴ありがとうございました。

CentOS5 系 に pip インストール

CentOS5 系 に pip インストール

2017 年 3 月にサポート終了する CentOS5 ですが
今なお利用されているサーバは多々あるかと思います。

今回の目的

デフォルトインストールされている Python 2.4.3 を残した状態で
Python 2.6 をインストールし、pip の上位バージョンを利用できるようにする、
ことを目的とします。

EPEL リポジトリ追加

1
$ sudo rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm

通常アップデートで EPEL からアップグレードするのを避ける様設定

1
2
3
4
5
$ sudo vi /etc/yum.repos.d/epel.repo

[epel]
...
enabled=0

EPEL リポジトリから python26 インストール

1
$ sudo yum install python26 -y --enablerepo=epel

バージョン確認

1
2
3
4
5
$ python26 -V
Python 2.6.8

$ python -V
Python 2.4.3

あくまで python26 は pip を利用するようにする為に共存させています。

pip インストール

1
2
3
$ wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
$ sudo python26 ez_setup.py --insecure
$ sudo easy_install-2.6 pip
1
2
$ pip --version
pip 8.1.2 from /usr/lib/python2.6/site-packages/pip-8.1.2-py2.6.egg (python 2.6)

MySQL テーブル単位の容量確認

  • SQL
1
2
3
4
5
6
7
8
9
10
11
mysql> use zabbix
Database changed

mysql> select
-> table_name, engine, table_rows as tbl_rows, avg_row_length as rlen,
-> floor((data_length+index_length)/1024/1024) as allMB, #総容量
-> floor((data_length)/1024/1024) as dMB, #データ容量
-> floor((index_length)/1024/1024) as iMB #インデックス容量
-> from information_schema.tables
-> where table_schema=database()
-> order by (data_length+index_length) desc;
  • 実行結果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
+----------------------------+--------+----------+-------+-------+------+------+
| table_name | engine | tbl_rows | rlen | allMB | dMB | iMB |
+----------------------------+--------+----------+-------+-------+------+------+
| history | InnoDB | 23815217 | 51 | 1802 | 1179 | 623 |
| history_uint | InnoDB | 21709131 | 51 | 1646 | 1075 | 571 |
| trends_uint | InnoDB | 45152 | 650 | 28 | 28 | 0 |
| trends | InnoDB | 30965 | 914 | 27 | 27 | 0 |
| history_str | InnoDB | 129224 | 109 | 19 | 13 | 5 |
| items | InnoDB | 2242 | 708 | 2 | 1 | 0 |
| images | InnoDB | 144 | 11036 | 1 | 1 | 0 |
| items_applications | InnoDB | 2468 | 66 | 0 | 0 | 0 |
| triggers | InnoDB | 805 | 223 | 0 | 0 | 0 |
| graphs_items | InnoDB | 948 | 103 | 0 | 0 | 0 |
| functions | InnoDB | 833 | 98 | 0 | 0 | 0 |
| events | InnoDB | 718 | 114 | 0 | 0 | 0 |
| alerts | InnoDB | 88 | 930 | 0 | 0 | 0 |
| graphs | InnoDB | 329 | 248 | 0 | 0 | 0 |

...
...

ちなみに上記は Zabbix DBの結果
history (履歴) にデータが肥大化傾向にあるので
パーティション や Zabbix housekeeping での
保存期間設定を調整するなど必要なことがわかります。

2016年5月現在、SSL評価Fを取らない為に

2016年5月現在、SSL評価Fを取らない為に

それは、ある日 QUALYS SSL LABS で SSL チェックしたとき

F になってる…

常に A+ を保っていたのに…

どうやら 2016/5/3 時点で新たに脆弱性が発見されたとのこと。

今回指摘されている CVE-2016-2107 :

AES-NI CBC MAC チェックで MITM 攻撃者がパディングオラクル攻撃可能なことがわかりました。この問題は、CVE-2013-0169(Lucky 13 パディング)の修正のために導入された箇所の不具合から発生しました。

上記対応策をまとめました。

対応策

  • OpenSSL version up

※試験 OS 環境: CentOS7

以下記事では 「OpenSSL のバージョンを 1.0.2h/1.0.1t にあげてください。」とありますが、

general-security-20160504

段階的に試した所
以下コマンドで openssl のバージョンアップをした所
エラーが消え B となりました。

事前に Nginx を 1.11.1 にアップデートした為でしょうか汗

1
2
3
4
# yum upgrade openssl -y

# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
  • ssl_ciphers の設定変更

config generator で 生成される ssl_ciphers ディレクティブをそのまま設定すると評価が B 止まりでした。

https://ssl-config.mozilla.org/

諸々含めたくない暗号化法があるようです。

1
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';

_以下最終的に設定した ssl_ciphers_ すると A+ に戻りました。

1
ssl_ciphers 'ECDH !aNULL !eNULL !SSLv2 !SSLv3';

OpenSSL の脆弱性はチェックし続けていかねば

補足

HTTP Strict Transport Security を 有効化 (常時 SSL) にしないと
A+ は取れません。

常時 SSL はパフォーマンスにも影響するので
せめて A まで取る、という指針を決めてから着手してください。

Nginx 1.9.6 → 1.11.1 へバージョンアップ 脆弱性対応

Nginx 1.9.6 → 1.11.1 へバージョンアップ 脆弱性対応

脆弱性 CVE-2016-4450 に対応した Nginx 1.11.1 が 2016-05-31 リリースされたということで
早速バージョンアップを試みました。

SIOS Tech. Lab - エンジニアのためになる技術トピックス

ダウンタイムゼロで実行できました。

現状の Nginx configure 確認

1
2
3
4
# nginx -V
nginx version: nginx/1.9.6

configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

[ より nginx-1.11.1 をダウンロード

1
2
3
4
# cd /usr/local/src
# wget http://nginx.org/download/nginx-1.11.1.tar.gz
# tar xvf nginx-1.11.1.tar.gz
# cd nginx-1.11.1

Nginx 1.11.1 で利用モジュールやサードパーティ(GeoIP-devel)をインストール

以下実行しないと nginx の configure が通りませんでした。

1
# yum install pcre-devel zlib-devel openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel -y
  • gd-devel がインストールされていない場合の Nginx configure error
1
2
./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
  • libxslt-devel がインストールされていない場合の Nginx configure error
1
2
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.

configure

「現状の Nginx configure 確認」で取得した configure parameter から
「–add-dynamic-module=njs-1c50334fbea6/nginx」を削除

  • --add-dynamic-module=njs-1c50334fbea6/nginx を指定した場合の Nginx configure error
1
2
adding module in njs-1c50334fbea6/nginx
./configure: error: no njs-1c50334fbea6/nginx/config was found

「–add-dynamic-module=njs-1c50334fbea6/nginx」を削除して configure 実施

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

...
...

checking for GeoIP library ... found
checking for GeoIP IPv6 support ... found
creating objs/Makefile

Configuration summary
+ using threads
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library

nginx path prefix: "/etc/nginx"
nginx binary file: "/usr/sbin/nginx"
nginx modules path: "/usr/lib64/nginx/modules"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/cache/nginx/client_temp"
nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"
nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"
nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"
nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"

ビルド

1
2
# make
# make install

Nginx バージョン確認

1
2
3
4
5
# nginx -V

nginx version: nginx/1.11.1

configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'

構文チェック

こける。。

1
2
3
4
# nginx -t

nginx: [emerg] unknown directive "geoip_country" in /etc/nginx/nginx.conf:15
nginx: configuration file /etc/nginx/nginx.conf test failed

サードパーティに依存するディレクティブについては
load_module で SharedObject(*.so) を呼び出す必要があります。

  • /etc/nignx/nginx.conf の冒頭に以下追加
1
load_module "modules/ngx_http_geoip_module.so";

再度構文チェック

1
2
3
4
# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginx 設定再読み込み

1
# systemctl reload nginx

以上で Nginx バージョンアップが無事完了しました。

Ansible+Vagrant でシンプルなPrometheusモニタリング環境構築

Ansible+Vagrant でシンプルなPrometheusモニタリング環境構築

概要

Prometheus 入門 にあるチュートリアルを
Ansible で簡単に構築できるようにした、
というものです。

先日 2016 年 6 月 14 日、
LINE 株式会社でのPrometheus Casual Talks #1に参加し
ナレッジのおさらいなどしたく、
構築法をまとめました。

Prometheus とは

最近話題の Pull 型の Query Filtering 可能で Grafana 等と連携できる モニタリング/Alert ツールです。

構成

Imgur

  • Prometheus Server × 1
  • Prometheus Client × 2

環境

  • CentOS 6.5
  • Prometheus Server 0.20.0
  • Supervisor 3.3.0
  • Go 1.6.2
  • Ansibl 2.1.0.0
  • Vagrant 1.8.1
  • MacOSX 10.11.5

前提条件

以下ツールをインストールしておいてください。

  • VirtualBox
  • Vagrant
  • Ansible

使い方

1. git repository を clone

[https://github.com/kenzo0107/Vagrant-Prometheus]

1
$ git clone https://github.com/kenzo0107/Vagrant-Prometheus

2. Vagrant VM 起動

1
2
$ cd Vagrant-Prometheus
$ vagrant up

3 node running !

  • 1 node: Prometheus Server
    • 192.168.11.30
  • other 2 nodes: Prometheus Client Server
    • 192.168.33.31
    • 192.168.33.32

3. ssh.config 追加

1
$ vagrant ssh-config > ssh.config

4. ping 疎通試験

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ ansible default -m ping

server | SUCCESS => {
"changed": false,
"ping": "pong"
}
client1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
client2 | SUCCESS => {
"changed": false,
"ping": "pong"
}

ok, success.

5. 2node に PrometheusClient 設定

1
$ ansible-playbook set_clients_prometheus.yml

6. PrometheusClient の起動確認

以下 PrometheusClient を起動しているサーバにアクセスし
起動されているか確認します。

以下のように表示されれば成功です。

7. PrometheusServer 設定

1
$ ansible-playbook set_server_prometheus.yml

8. PrometheusServer 確認

http://192.168.33.30:9090 にアクセス

以下のように表示されれば成功です。

是非多少なりとも一助となれば何よりです!
いじくり倒してみてください!

以上

Jenkins - Short cycles in the day-of-month field will behave oddly near the end of a month

Jenkins - Short cycles in the day-of-month field will behave oddly near the end of a month

完全なる備忘録です。

Jenkins で 毎月第 1 月曜日のみ設定しようとしたら

1
Short cycles in the day-of-month field will behave oddly near the end of a month

次の様に分けるとエラーが消えます。

概要

アメリカでは
月間の期間を 4,5 週間の単位で
売り上げの結果を考える慣習があります。

その際に月初にレポートが欲しい
なんてときに今回このような処理をする必要がありました。

以上です。