以下はLinuxインスタンスを生成したばかりのVPSまたはクラウドOSにMikasaをインストールする場合について記述している。
OSはCentOS7を対象にして説明している。
Java、Rubyのインストール手順はインストール済みの場合はSKIPして問題ないがJava7+、Ruby2.0+がインストールされていること。
- Twitterの開発者アカウント
- Amazonの開発者アカウント(つぶやきデータから商品をレコメンドする場合)
yum -y install tmux git
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
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]
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)
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
中身をコピー
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
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
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セッションを抜ける
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
cd ~/download
git clone git@github.com:AKB428/mikasa_ol.git
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セッションを抜ける
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
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
vi /etc/ssh/sshd_config
AllowTcpForwarding yes
service sshd restart
ssh -L 14040:X.X.X.X:4040 user@X.X.X.X
http://localhost:14040/ にアクセス
curl -O https://objectstore-r1nd1001.cnode.jp/v1/93a6500c0a1e4c68b976e5e46527145c/wtest/user_dic.csv