Skip to content

Instantly share code, notes, and snippets.

@AKB428
Last active March 10, 2016 16:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AKB428/c30bc6a979e05fa3a022 to your computer and use it in GitHub Desktop.
Save AKB428/c30bc6a979e05fa3a022 to your computer and use it in GitHub Desktop.
Mikasaインストールマニュアル

以下はLinuxインスタンスを生成したばかりのVPSまたはクラウドOSにMikasaをインストールする場合について記述している。

OSはCentOS7を対象にして説明している。

Java、Rubyのインストール手順はインストール済みの場合はSKIPして問題ないがJava7+、Ruby2.0+がインストールされていること。

用意するもの

  • Twitterの開発者アカウント
  • Amazonの開発者アカウント(つぶやきデータから商品をレコメンドする場合)

事前環境整備

(基本) tmux git インストール

yum -y install tmux git

Nginx構築 Firewall開放

yum -y install nginx

vi /etc/nginx/nginx.conf
worker_processes  auto;

service nginx start
curl localhost
firewall-cmd --permanent --add-service=http
firewall-cmd --reload

rbenvで最新のRuby環境構築

rubyが構築できるよう開発環境を整備

yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel

コマンドの元ネタ) https://github.com/sstephenson/ruby-build/wiki#suggested-build-environment

後はここを参考に最新のRubyをインストール http://dev.classmethod.jp/server-side/language/build-ruby-environment-by-rbenv/

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
rbenv install 2.2.2
rbenv global 2.2.2
ruby -v

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

Oracle JDKインストール

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Linuxサーバーから直に落とせないのでローカルPCでダウンロードしscpする

scp ~/Downloads/jdk-8u45-linux-x64.rpm root@n-conoha3:~
ssh root@n-conoha3
rpm -ivh jdk-8u45-linux-x64.rpm
$java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

githubにSSH鍵登録(gitのsshパスからダウンロードせずhttp経由でダウンロードするなら不要)

cd ~
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:

cat .ssh/id_rsa.pub
中身をコピー

システムコンポーネント

ZooKeeper(Kafka起動に必要)

cd ~
mkdir download
cd download
curl -O http://ftp.jaist.ac.jp/pub/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
tar -xzvf zookeeper-3.4.6.tar.gz
cd zookeeper-3.4.6/
bin/zkServer.sh start conf/zoo_sample.cfg

出力ログ

JMX enabled by default
Using config: conf/zoo_sample.cfg
Starting zookeeper ... STARTED

Scala(Kafka起動に必要)

cd ~/download
curl -O http://downloads.typesafe.com/scala/2.10.5/scala-2.10.5.rpm
rpm -ivh scala-2.10.5.rpm

インストール確認

scala -version
Scala code runner version 2.10.5 -- Copyright 2002-2013, LAMP/EPFL

Kafka

curl -O http://ftp.yz.yamagata-u.ac.jp/pub/network/apache/kafka/0.8.2.1/kafka_2.10-0.8.2.1.tgz
tar -xzvf kafka_2.10-0.8.2.1.tgz
tmux new -s kafka
cd kafka_2.10-0.8.2.1/
bin/kafka-server-start.sh config/server.properties

Ctrl+B dでtmuxセッションを抜ける

SBT

curl https://bintray.com/sbt/rpm/rpm | sudo tee /etc/yum.repos.d/bintray-sbt-rpm.repo
sudo yum -y install sbt

インストール確認

sbt --version
sbt launcher version 0.13.8

misaka_ol インストール&起動

cd ~/download
git clone git@github.com:AKB428/mikasa_ol.git

Kafka トピック作成

cd kafka_2.10-0.8.2.1/
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic ikazuchi0
>>Created topic "ikazuchi0".
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic ikazuchi0.view
>>Created topic "ikazuchi0.view".
cd ~/download/mikasa_ol
cp config/application.properties.sample config/application.properties

設定ファイルを記述した後

tmux new -s mikasa_ol
sbt
(sbt shell)> run
プログラム選択

ctrl+b dでtmuxセッションを抜ける

kafka受信確認(動作確認が必要な場合のみ)

tmux new -s kafka-ikazuchi0
cd ~/download/kafka_2.10-0.8.2.1/
./bin/kafka-console-consumer.sh --topic ikazuchi0 --zookeeper localhost:2181
ctrl+b d
tmux new -s kafka-ikazuchi0.view
cd ~/download/kafka_2.10-0.8.2.1/
/bin/kafka-console-consumer.sh --topic ikazuchi0.view --zookeeper localhost:2181
ctrl+b d

misaka_rs インストール&起動

bundler

gem install bundler
cd ~/download/
git clone git@github.com:AKB428/mikasa_rs.git
cd mikasa_rs
bundle install

nokogiriのインストールに失敗する時

yum -y install libxslt-devel
gem install nokogiri -- --use-system-libraries
bundle install

便利系(必須ではない)

リソースモニタ

yum -y install htop

SSHポートフォワード 開放

vi /etc/ssh/sshd_config
AllowTcpForwarding yes
service sshd restart

ローカルでリモートのSparkUIにアクセス

ssh -L 14040:X.X.X.X:4040 user@X.X.X.X

http://localhost:14040/ にアクセス

wiki Index ユーザー辞書

curl -O https://objectstore-r1nd1001.cnode.jp/v1/93a6500c0a1e4c68b976e5e46527145c/wtest/user_dic.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment