雑記

インフラのことだったりプログラムのことだったりどうでもいいこと書いたり。要は雑記。

AMIにaws-sdk for rubyをインストールしようとしたらエラーがでた

タイトル通りなんだけど、その時の対応メモ。

そもそもの依存関係のパッケージインストール

$ sudo yum install libxml2-devel
$ sudo yum install libxslt-devel

aws-sdkをインストール

aws-sdkをインストール

$ sudo gem i aws-sdk

ただ、依存関係にあるパッケージのnokogiriのインストールに失敗してこける

Building native extensions.  This could take a while...
ERROR:  Error installing aws-sdk:
  ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.0 extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
  - 0001-Revert-Missing-initialization-for-the-catalog-module.patch
  - 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.
************************************************************************
Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2... OK
Running patch with /usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
  --with-opt-dir
  --without-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib64
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/usr/bin/ruby2.0
  --help
  --clean
  --use-system-libraries
  --enable-static
  --disable-static
  --with-zlib-dir
  --without-zlib-dir
  --with-zlib-include
  --without-zlib-include=${zlib-dir}/include
  --with-zlib-lib
  --without-zlib-lib=${zlib-dir}/lib
  --enable-cross-build
  --disable-cross-build
/usr/local/share/ruby/gems/2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:279:in `block in execute': Failed to complete patch task (RuntimeError)
  from /usr/local/share/ruby/gems/2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `chdir'
  from /usr/local/share/ruby/gems/2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:271:in `execute'
  from extconf.rb:311:in `block in patch'
  from extconf.rb:308:in `each'
  from extconf.rb:308:in `patch'
  from /usr/local/share/ruby/gems/2.0/gems/mini_portile-0.6.2/lib/mini_portile.rb:108:in `cook'
  from extconf.rb:278:in `block in process_recipe'
  from extconf.rb:177:in `tap'
  from extconf.rb:177:in `process_recipe'
  from extconf.rb:475:in `<main>'


Gem files will remain installed in /usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/gem_make.out

libxml2のバージョンが合わないからっぽい。 とりあえず指示通り、nokogiriを単体で--use-system-librariesをつけてインストールしたらいけた

$ sudo gem i nokogiri -- --use-system-libraries

その後、再度aws-sdkのインストールを実行したら通っていけました。

OpsCenterをNginxでproxyする

はまったのでメモ

普通にproxyすると

こんな設定で普通にproxyすると、各ノードの状態を取得することができません。

    location / {
        proxy_pass http://localhost:8888;
    }

/tcp/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xhrstream?nocache=0.9999999999999999といったリクエストがタイムアウトします。

どうするか?

proxy_buffering offを設定します。

    location / {
        proxy_pass http://localhost:8888;
        proxy_buffering off;
    }

これで通信が通ります。

proxy_bufferingって?

要はproxy先のレスポンスをnginxでキャッシュせず、クライアントに即座に返すってことかな。

bowerでgitプロトコルではなくhttpsでパッケージを取得する

デフォルトだとbowerを実行すると、git://でパッケージを取得しにいきます。 ただ、これだとネットワーク環境によってはうまく取得できない場合があります。 例えば、社外へアクセスするポートに制限がかかっているときなど(gitだとポート9418を利用する。自分の職場だとこの制限がある。。)

そのままではbowerが利用できないので、gitプロトコルでなく、httpsで取得するように変更します。

以下のコマンドを実行するだけ

git config --global url."https://".insteadOf git://

参考

MEANスタック環境の構築

MEANスタック環境を構築してみる

ちょっとした管理ツールを作る必要が出てきたので、どうせなら面白く作りたいなーと思い話題のMEANスタックで作ってみようかなーと。 今回はお試しで環境の構築まで。

前提環境

  • OSはCentOS6
  • Vagrant環境
  • ほぼまっさらな状態で作業

環境の構築

node.jsのインストール

$ sudo yum install nodejs npm

mongodbのインストール

/etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=0
$ sudo yum install mongo-10gen --enablerepo=mongodb
# /etc/init.d/mongd start
# chkconfig mongod on

gruntのインストール

$ npm install grunt-cli

環境よごしたくないので、-gオプションはつけていません

mean-cliのインストール

$ npm install mean-cli

環境よごしたくないので、-gオプションはつけていません

node_moduleのPATHを通す

.zprofile

PATH=$HOME/node_modules/.bin:$PATH

読み込み

source .zprofile

ひな形作成~起動

ひな形作成

$ mean init sampleMean

ここでプロジェクト名とどのビルドツールを利用するか聞かれます

パッケージインストール

$ cd sampleMean && npm install

ListenIP変更

sampleMean/config/env/development.js

hostname: '0.0.0.0',

上記を追記。

起動

$ grunt

アクセス

datastax-agent(OpsCenterのagent)を手動でインストールする

OpsCenterを利用するときに、Agentもインストールする必要があります。 基本的にはOpsCenterの管理画面からインストールすることになるのですが、rootアカウント、もしくはsudoersの権限を持ったアカウントを設定しないとインストールできないです。

セキュリティ的にそんなアカウントを作成していない、というケースもあるかと思いますので、そんな場合に手動でAgentをインストールする場合の作業記録です。

前提環境

  • CentOS6系
  • OpsCenterはyumでインストール
  • OpsCenterのバージョンは5.0.2

OpsCenterをインストールしたサーバでの作業

agentファイルを対象のクライアントに持っていきます。

# cd /usr/share/opscenter
# scp agent.tar.gz hoge@xxx.xxx.xxx.xxx:/var/tmp

Agentをインストールするサーバでの作業

agentをインストールします。

# cd /var/tmp
# tar zxf agent.tar.gz
# cd agent/bin
# ./install_agent.sh [OpsCenterをインストールしたサーバのIP]

後はOpsCenterの管理画面から追加されていることを確認しましょう。