カテゴリー
Mac MongoDB インストールメモ

[mac]Mountain LionにmacportsでMongoDBをインストール

### インストール
ビルドにそこそこ時間がかかる。6時間なんてエントリーもあったけどそんなにかからなかった。15-20分位?環境はMacBookPro Retina, 13-inch, Early 2013。他のエントリーでは依存問題が...的なのがあったけど、特に問題がなかった。

$ sudo port install mongodb
Warning: port definitions are more than two weeks old, consider using selfupdate
--->  Cleaning bzip2
--->  Unable to uninstall bzip2 @1.0.6_0, the following ports depend on it:
--->  	pcre @8.12_1
--->  	python27 @2.7.2_2
--->  	freetype @2.4.9_1
--->  	php5 @5.3.10_0+apache2
Warning: Uninstall forced.  Proceeding despite dependencies.
--->  Deactivating bzip2 @1.0.6_0
--->  Unable to deactivate bzip2 @1.0.6_0, the following ports depend on it:
--->  	pcre @8.12_1
--->  	python27 @2.7.2_2
--->  	freetype @2.4.9_1
--->  	php5 @5.3.10_0+apache2
Warning: Deactivate forced.  Proceeding despite dependencies.
--->  Cleaning bzip2
--->  Uninstalling bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Fetching archive for bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/bzip2
--->  Attempting to fetch bzip2-1.0.6_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/bzip2
--->  Installing bzip2 @1.0.6_0
--->  Activating bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Computing dependencies for libedit
--->  Fetching archive for libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/libedit
--->  Attempting to fetch libedit-20121213-3.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/libedit
--->  Installing libedit @20121213-3.0_0
--->  Cleaning libedit
--->  Computing dependencies for libedit
--->  Deactivating libedit @20110802-3.0_0
--->  Cleaning libedit
--->  Activating libedit @20121213-3.0_0
--->  Cleaning libedit
--->  Computing dependencies for pcre
--->  Fetching archive for pcre
--->  Attempting to fetch pcre-8.32_1.darwin_12.x86_64.tbz2 from http://packages.macports.org/pcre
--->  Attempting to fetch pcre-8.32_1.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/pcre
--->  Installing pcre @8.32_1
--->  Cleaning pcre
--->  Computing dependencies for pcre
--->  Deactivating pcre @8.12_1
--->  Cleaning pcre
--->  Activating pcre @8.32_1
--->  Cleaning pcre
--->  Computing dependencies for mongodb
--->  Dependencies to be installed: libpcap scons snappy v8
--->  Fetching archive for libpcap
--->  Attempting to fetch libpcap-1.3.0_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/libpcap
--->  Attempting to fetch libpcap-1.3.0_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/libpcap
--->  Installing libpcap @1.3.0_0
--->  Activating libpcap @1.3.0_0
--->  Cleaning libpcap
--->  Fetching archive for scons
--->  Attempting to fetch scons-2.2.0_0.darwin_12.noarch.tbz2 from http://packages.macports.org/scons
--->  Attempting to fetch scons-2.2.0_0.darwin_12.noarch.tbz2.rmd160 from http://packages.macports.org/scons
--->  Installing scons @2.2.0_0
--->  Activating scons @2.2.0_0
--->  Cleaning scons
--->  Fetching archive for snappy
--->  Attempting to fetch snappy-1.0.5_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/snappy
--->  Attempting to fetch snappy-1.0.5_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/snappy
--->  Installing snappy @1.0.5_0
--->  Activating snappy @1.0.5_0
--->  Cleaning snappy
--->  Fetching archive for v8
--->  Attempting to fetch v8-3.17.15_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/v8
--->  Attempting to fetch v8-3.17.15_0.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/v8
--->  Installing v8 @3.17.15_0
--->  Activating v8 @3.17.15_0
--->  Cleaning v8
--->  Fetching archive for mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://packages.macports.org/mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/mongodb
--->  Attempting to fetch mongodb-2.4.1_0.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/mongodb
--->  Fetching distfiles for mongodb
--->  Attempting to fetch mongodb-src-r2.4.1.tar.gz from http://distfiles.macports.org/mongodb
--->  Verifying checksum(s) for mongodb
--->  Extracting mongodb
--->  Applying patches to mongodb
--->  Configuring mongodb
--->  Building mongodb
--->  Staging mongodb into destroot
--->  Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting mongodb with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load mongodb
###########################################################
--->  Installing mongodb @2.4.1_0
--->  Activating mongodb @2.4.1_0
--->  Cleaning mongodb
--->  Updating database of binaries: 100.0%
--->  Scanning binaries for linking errors: 100.0%
--->  Found 137 broken file(s), matching files to ports
--->  Found 3 broken port(s), determining rebuild order
--->  Rebuilding in order
     apache2 @2.2.22 +preforkmpm
     git-core @1.7.7.2 +doc+pcre+python27
     php5 @5.3.10 +apache2
--->  Computing dependencies for apache2
--->  Fetching archive for apache2
--->  Attempting to fetch apache2-2.2.24_0+preforkmpm.darwin_12.x86_64.tbz2 from http://packages.macports.org/apache2
--->  Attempting to fetch apache2-2.2.24_0+preforkmpm.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/apache2
--->  Installing apache2 @2.2.24_0+preforkmpm
--->  Cleaning apache2
--->  Computing dependencies for apache2
--->  Deactivating apache2 @2.2.22_1+preforkmpm
--->  Cleaning apache2
--->  Activating apache2 @2.2.24_0+preforkmpm
--->  Cleaning apache2
--->  Computing dependencies for git-core
--->  Dependencies to be installed: p5.12-term-readkey
--->  Fetching archive for p5.12-term-readkey
--->  Attempting to fetch p5.12-term-readkey-2.300.0_3.darwin_12.x86_64.tbz2 from http://packages.macports.org/p5.12-term-readkey
--->  Attempting to fetch p5.12-term-readkey-2.300.0_3.darwin_12.x86_64.tbz2.rmd160 from http://packages.macports.org/p5.12-term-readkey
--->  Installing p5.12-term-readkey @2.300.0_3
--->  Activating p5.12-term-readkey @2.300.0_3
--->  Cleaning p5.12-term-readkey
--->  Fetching archive for git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://packages.macports.org/git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/git-core
--->  Attempting to fetch git-core-1.8.2.1_0+credential_osxkeychain+doc+pcre+python27.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/git-core
--->  Fetching distfiles for git-core
--->  Attempting to fetch git-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Attempting to fetch git-manpages-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Attempting to fetch git-htmldocs-1.8.2.1.tar.gz from http://git-core.googlecode.com/files/
--->  Verifying checksum(s) for git-core
--->  Extracting git-core
--->  Applying patches to git-core
--->  Configuring git-core
--->  Building git-core
--->  Staging git-core into destroot
--->  Installing git-core @1.8.2.1_0+credential_osxkeychain+doc+pcre+python27
--->  Cleaning git-core
--->  Computing dependencies for git-core
--->  Deactivating git-core @1.7.7.2_0+doc+pcre+python27
--->  Cleaning git-core
--->  Activating git-core @1.8.2.1_0+credential_osxkeychain+doc+pcre+python27
--->  Cleaning git-core
--->  Computing dependencies for php5
--->  Fetching archive for php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://packages.macports.org/php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://jog.id.packages.macports.org/macports/packages/php5
--->  Attempting to fetch php5-5.3.23_0+apache2.darwin_12.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/php5
--->  Fetching distfiles for php5
--->  Attempting to fetch php-5.3.23.tar.bz2 from http://jp.php.net/get/php-5.3.23.tar.bz2/from/this/mirror?dummy=
--->  Verifying checksum(s) for php5
--->  Extracting php5
--->  Applying patches to php5
--->  Configuring php5
Error: org.macports.configure for port php5 returned: configure failure: command execution failed
Please see the log file for port php5 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_lang_php5/php5/main.log
Error: Unable to upgrade port: 1
Error rebuilding php5
    while executing
"error "Error rebuilding $portname""
    (procedure "revupgrade_scanandrebuild" line 382)
    invoked from within
"revupgrade_scanandrebuild broken_port_counts $opts"
    (procedure "macports::revupgrade" line 5)
    invoked from within
"macports::revupgrade $opts"
    (procedure "action_revupgrade" line 2)
    invoked from within
"action_revupgrade $action $portlist $opts"
    (procedure "action_target" line 94)
    invoked from within
"$action_proc $action $portlist [array get global_options]"
    (procedure "process_cmd" line 95)
    invoked from within
"process_cmd $remaining_args"
    invoked from within
"if { [llength $remaining_args] > 0 } {

    # If there are remaining arguments, process those as a command
    set exit_status [process_cmd $remaining..."
    (file "/opt/local/bin/port" line 4785)
$ sudo port load mongodb

で起動時にデーモンが立ち上がるようになるみたい。

### mongodbデーモン起動

mongod でデーモン起動。

$ mongod
mongod --help for help and startup options
Sun Jun  2 09:11:40.248 [initandlisten] MongoDB starting : pid=28245 port=27017 dbpath=/data/db/ 64-bit host=clicktx-MBP.local
Sun Jun  2 09:11:40.248 [initandlisten] 
Sun Jun  2 09:11:40.248 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sun Jun  2 09:11:40.249 [initandlisten] db version v2.4.1
Sun Jun  2 09:11:40.249 [initandlisten] git version: nogitversion
Sun Jun  2 09:11:40.249 [initandlisten] build info: Darwin clicktx-MBP.local 12.3.0 Darwin Kernel Version 12.3.0: Sun Jan  6 22:37:10 PST 2013; root:xnu-2050.22.13~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Sun Jun  2 09:11:40.249 [initandlisten] allocator: tcmalloc
Sun Jun  2 09:11:40.249 [initandlisten] options: {}
Sun Jun  2 09:11:40.249 [initandlisten] exception in initAndListen: 10296 
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sun Jun  2 09:11:40.249 dbexit: 
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to close listening sockets...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to flush diaglog...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: going to close sockets...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: waiting for fs preallocator...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: lock for final commit...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: final commit...
Sun Jun  2 09:11:40.249 [initandlisten] shutdown: closing all files...
Sun Jun  2 09:11:40.249 [initandlisten] closeAllFiles() finished
Sun Jun  2 09:11:40.249 dbexit: really exiting now

データベースのディレクトリがないみたい。

### mongodbシェルを使う

$ mongo
MongoDB shell version: 2.4.1
connecting to: test
> 

tabでコマンドの補完やカーソルキーで履歴の表示など出来る。

### チュートリアルを試してみる

[MongoDBの薄い本(The Little MongoDB Book) - cuspy diary](http://www.cuspy.org/diary/2012-04-17)

カテゴリー
メモ

CentOS6.4 iptablesの設定

Linodeのマニュアルにはiptablesの設定の仕方とか書いてあって親切。

Linode - Creating a Firewall

ルールの作成
vi /etc/iptables.firewall.rules

*filter

#  Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT

#  Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#  Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT

#  Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

#  Allow SSH connections
#
#  The -dport number should be the same port number you set in sshd_config
#
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

#  Allow ping
-A INPUT -p icmp -j ACCEPT

#  Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

#  Drop all other inbound - default deny unless explicitly allowed policy
-A INPUT -j DROP
-A FORWARD -j DROP

COMMIT
ルールの適用
sudo iptables-restore < /etc/iptables.firewall.rules
ルールの確認
sudo iptables -nL
ルールの保存

CentOS6.2以上の場合は

/sbin/service iptables save
カテゴリー
CentOS6.x phpmyadmin

[CentOS6] phpMyAdminの「mcrypt 拡張をロードできません。PHP の設定を確認してください」

yumでインストールしたphpMyAdmin。途中は端折るけど、「mcrypt 拡張をロードできません。PHP の設定を確認してください」のエラーが消えない。

$ php -v
# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/module.so' - /usr/lib64/php/modules/module.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.3.3 (cli) (built: Feb 22 2013 02:51:11) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

色々ググッた結果このエントリーを発見

「mcrypt 拡張をロードできません。PHP の設定を確認してください」

# vi /etc/php.d/mcrypt.ini 
; Enable mcrypt extension module
extension=mcrypt.so

こんなトラップが仕掛けられているとは恐れ入る。

カテゴリー
CentOS6.x perlモジュール インストールメモ

[Perl][CentOS6] Net::SSLeayがインストール出来ない時

openssl-develをインストールしてからインストールする。

sudo yum install openssl-devel
cpanm Net-SSLeay
カテゴリー
CentOS5.x CentOS6.x インストールメモ

CentOSにyumでmecabをインストールする

どうやらcentosではmecab単体のパッケージが提供されていないので、groongaをインストールする。

2.5. CentOS — groonga v3.0.3ドキュメント

groongaのリポジトリを追加
% sudo rpm -ivh http://packages.groonga.org/centos/groonga-release-1.1.0-1.noarch.rpm
groongaのトークナイザーにmecabを使う
% sudo yum install -y groonga-tokenizer-mecab
================================================================================
 Package                   Arch     Version                     Repository
                                                                           Size
================================================================================
Installing:
 groonga-tokenizer-mecab   x86_64   3.0.3-0.el6                 groonga    18 k
Installing for dependencies:
 mecab                     x86_64   0.996-1.el6                 groonga   2.3 M
 mecab-ipadic              x86_64   2.7.0.20070801-6.el6.1      groonga    13 M

Transaction Summary
================================================================================
Install       3 Package(s)

mecab本体と辞書がインストールされます。

もしかするとgroonagリポジトリ追加して、yum install mecab mecab-ipadic で良かったかも。groonga必要だからいいけど。