elasticsearchをインストールする
検索エンジンではSolrが有名ですが、新たにelasticsearchというものがあると聞いた。
大きな特徴としては、Schema freeといって、あらかじめSchema定義をしなくても投入されるデータに対して、型を推測してデータを入れるらしいけど、どのような場面でこのSchema freeを活かすかは、今のところ自分にはわからない。。
どのようなものか知るため、Mac環境にインストールしてみる。
ダウンロード
elasticsearch公式サイトのダウンロードページからダウンロードする。
今回はTAR.GZを選択。
インストール
ダウンロードできたことを確認したら、以下の手順で解凍した後に、binディレクトリにあるスクリプトを実行するだけ。
確認
ブラウザでhttp://localhost:9200/に接続して、以下のjsonが帰ってきたら成功している。("name"は起動ごとに違う)
{ "ok" : true, "status" : 200, "name" : "The Grip", "version" : { "number" : "0.90.7", "build_hash" : "36897d07dadcb70886db7f149e645ed3d44eb5f2", "build_timestamp" : "2013-11-13T12:06:54Z", "build_snapshot" : false, "lucene_version" : "4.5.1" }, "tagline" : "You Know, for Search" }
pluginインストール
pluginのインストールも簡単だった。
一番有名であろう、elasticsearch-headをインストールする。
以下のコマンドを実行すれば、インストールできる。
elasticsearch-head pluginの確認
http://localhost:9200/_plugin/head/に接続して、GUI画面が出ていれば成功している。
感想
本体も簡単にインストールできたことに加え、pluginのインストールが予想以上に簡単だったことに驚いた。
参考
git repository を bitbucketからgithubへ移行する
移行方法
git repositoryをmirrorオプションつけてbitbucketからcloneした後、 mirrorオプションつけてgithubにpushしたら、過去のbranch, commit logともに移行できた!
以下が使用したコマンド
課題
当たり前だけど、branch, commit logは移行できたが、issueなどのbitbucket側のサービスに関しては移行できなかった。
issueが引き継がれないこと自体は仕方がないのだけれど、commit logに記述したissueとの連携コメントが意味のないものになるのが問題だ。
これに関しては、commit logの修正を手作業でするしかないようだ。
参考
vimのNeoBundle導入
Vimのプラグイン管理をするため、NeoBundleを導入したので、メモ。
NeoBundle用のディレクトリを作成
$ mkdir -p ~/.vim/bundle
NeoBundleをgithubからclone
$ git clone http://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
.vimrc編集
" viとの互換性OFF set nocompatible " ファイル形式の検出を無効にする filetype off if has('vim_starting') set runtimepath+=~/.vim/bundle/neobundle.vim call neobundle#rc(expand('~/.vim/bundle')) endif " github にあるプラグイン NeoBundle 'Shougo/neocomplcache' NeoBundle 'Shougo/neosnippet' NeoBundle 'Shougo/unite.vim' NeoBundle 'vim-ruby/vim-ruby' NeoBundle 'scrooloose/nerdtree' NeoBundle 'tpope/vim-rails' NeoBundle 'tpope/vim-surround' " vim-scripts プラグイン NeoBundle 'dbext.vim' NeoBundle 'pathogen.vim' " github にないプラグイン " ファイル形式検出、プラグイン、インデントを ON filetype plugin indent on
vimを起動し、以下を実行
:NeoBundleInstall
これで、~/.vimrc上でNeoBundleに設定したプラグインをインストールされる。
Solrインストール
アプリケーションに検索機能をつけるため、Solrを開発環境にインストールする。
ちなみに、開発環境はVagrant上で構築する。
vagrant@vagrant-debian-squeeze:~$ java -bash: java: command not found
javaないと言われるので、javaをaptitudeでインストールする。
vagrant@vagrant-debian-squeeze:~$ sudo aptitude install java-sdk "java-sdk" is a virtual package provided by: openjdk-6-jdk default-jdk gcj-4.4-jdk gcj-jdk You must choose one to install. No packages will be installed, upgraded, or removed. 0 packages upgraded, 0 newly installed, 0 to remove and 27 not upgraded. Need to get 0 B of archives. After unpacking 0 B will be used.
javaといっても、いろいろあると出てくるので、今回はdefault-jdkをインストールする。
vagrant@vagrant-debian-squeeze:~$ sudo aptitude install default-jdk The following NEW packages will be installed: # (省略) Setting up default-jdk (1:1.6-40) ... Processing triggers for menu ... vagrant@vagrant-debian-squeeze:~$ java -version java version "1.6.0_18" OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
javaが入れられたことを確認できた。
2. Solrをダウンロード & インストール
Solrをインストールするために、
http://www.apache.org/dyn/closer.cgi/lucene/solr/4.2.0
の適当なミラーサイトからダウンロードする。
今回は、バージョン4.2.0。
そのあと、unzipで解凍する。
vagrant@vagrant-debian-squeeze:~$ wget http://ftp.tsukuba.wide.ad.jp/software/apache/lucene/solr/4.2.0/solr-4.2.0.zip --2013-04-04 16:30:54-- http://ftp.tsukuba.wide.ad.jp/software/apache/lucene/solr/4.2.0/solr-4.2.0.zip Resolving ftp.tsukuba.wide.ad.jp... 203.178.132.80 Connecting to ftp.tsukuba.wide.ad.jp|203.178.132.80|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 121058888 (115M) [application/zip] Saving to: “solr-4.2.0.zip” 100%[==================================================================================================================================================================>] 121,058,888 2.43M/s in 79s 2013-04-04 16:32:18 (1.46 MB/s) - “solr-4.2.0.zip” saved [121058888/121058888] vagrant@vagrant-debian-squeeze:~$ unzip solr-4.2.0.zip Archive: solr-4.2.0.zip creating: solr-4.2.0/ creating: solr-4.2.0/contrib/ # (省略)
4. Solr 管理画面起動
Solrの管理画面をstart.jarで起動する。
vagrant@vagrant-debian-squeeze:~$ cd solr-4.2.0/example/ vagrant@vagrant-debian-squeeze:~/solr-4.2.0/example$ java -jar start.jar
http://xxxxxxxx:xxxx/solr/adminを叩いて確認する。
(xxxxxxxx:xxxxはホスト名:ポート番号。)
5. データ更新
標準で付いてくるサンプルxmlをPOSTして、データ更新する。
vagrant@vagrant-debian-squeeze:~/solr-4.2.0/example$ cd exampledocs/ vagrant@vagrant-debian-squeeze:~/solr-4.2.0/example/exampledocs$ java -jar post.jar ipod_other.xml
データが入っていることを確認する。
今回は、2ドキュメント入った。
6. データ検索
ちゃんと検索できるか確認する。
ipod_other.xmlのデータを入れたから、ipodで検索する。
http://xxxxxxxx:xxxx/solr/collection1/select?q=ipod&wt=xml&indent=true
で検索する(xxxxxxxx:xxxxはホスト名:ポート番号。)
MacでVagrant導入
今までは、自分のローカル環境で開発環境を構築していたが、
Vagrantを使えば簡単なコマンドで開発環境がVM上に構築できるということを知ったので、今回はVagrantを使用して開発環境を構築しようと思う。
自分のメモ用に、Vagrant導入までの流れを記録する。
1. VirtualBoxインストール
https://www.virtualbox.org/wiki/Downloads
からMac用のものをダウンロードする。
ダウンロードしたものをダブルクリックで、あとは通常のインストールをする。
2. Vagrantダウンロード
http://downloads.vagrantup.com/
から最新版をダウンロードする。 現在の最新バージョンv1.1.5。
vagrant.dmgがダウンロードされるので、ダブルクリックする。
vagrant.pkgをダブルクリックして、インストール画面に移行する。
そのまま、他のソフト同様インストーラーの選択をすすめていく。
インストール完了。
ターミナルでvagrantコマンドが使えることを確認した。
nara-no-MacBook-Air:vagrant NaraTakahito$ vagrant --version Vagrant version 1.1.5 nara-no-MacBook-Air:vagrant NaraTakahito$
3. box選択
http://www.vagrantbox.es/
からvagrantで構築したい環境を選択する。
今回は、以下を選択。
Name: Debian 6 Squeeze x64 configured according to documentation
URL: http://www.emken.biz/vagrant-boxes/debsqueeze64.box
以下のコマンドを実行する。
nara-no-MacBook-Air:vagrant NaraTakahito$ sudo vagrant box add debsqueeze64 http://www.emken.biz/vagrant-boxes/debsqueeze64.box Password: [vagrant] Downloading with Vagrant::Downloaders::HTTP... [vagrant] Downloading box: http://www.emken.biz/vagrant-boxes/debsqueeze64.box [vagrant] Downloading box: http://www.emken.co/vagrant-boxes/debsqueeze64.box [vagrant] Extracting box... [vagrant] Verifying box... [vagrant] Cleaning up downloaded box... nara-no-MacBook-Air:vagrant NaraTakahito$
4. リスト表示
登録されたかを確認するため、リスト表示をする。
nara-no-MacBook-Air:vagrant NaraTakahito$ vagrant box list debsqueeze64
5. vagrant用のディレクトリを作っておく
box毎の設定ファイルを置くためのディレクトリを作成する。
nara-no-MacBook-Air:work NaraTakahito$ ls -ld vagrant drwxr-xr-x 2 NaraTakahito staff 68 4 5 01:21 vagrant
6. vagrantの初期化
まずは、初期化をする。
nara-no-MacBook-Air:vagrant NaraTakahito$ vagrant init A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. nara-no-MacBook-Air:vagrant NaraTakahito$ ls Vagrantfile
7. Vagrantfileを編集
初期化をすると、Vagrantfileがカレントディレクトリに作成されているので、
以下のとおりに編集する。
- config.vm.box = "base" + config.vm.box = "debsqueeze64"
※ もしくは初期化の際に、以下で実行する。
vagrant init debsqueeze64
8. 起動
いよいよ起動する。
nara-no-MacBook-Air:vagrant NaraTakahito$ sudo vagrant up [default] Importing base box 'debsqueeze64'... [default] Matching MAC address for NAT networking... [default] Clearing any previously set forwarded ports... [default] Forwarding ports... [default] -- 22 => 2222 (adapter 1) [default] Creating shared folders metadata... [default] Clearing any previously set network interfaces... [default] Booting VM... [default] Waiting for VM to boot. This can take a few minutes. [default] VM booted and ready for use! [default] The guest additions on this VM do not match the install version of VirtualBox! This may cause things such as forwarded ports, shared folders, and more to not work properly. If any of those things fail on this machine, please update the guest additions and repackage the box. Guest Additions Version: 4.1.24 VirtualBox Version: 4.2.10 [default] Mounting shared folders... [default] -- v-root: /vagrant nara-no-MacBook-Air:vagrant NaraTakahito$
nara-no-MacBook-Air:vagrant NaraTakahito$ sudo vagrant ssh Linux vagrant-debian-squeeze 2.6.32-5-amd64 #1 SMP Sun Sep 23 10:07:46 UTC 2012 x86_64 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. No mail. Last login: Sat Feb 16 09:20:45 2013 from 10.0.2.2 vagrant@vagrant-debian-squeeze:~$
はじめまして
はじめまして、takahitoです。
主に、技術に関してブログを書いていきます。