onoderay
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
 #概要 本資料はJSCプロジェクトでの機械学習システム導入手順書です。 主な導入内容は、スプリーム独自の機械学習アプリケーション ”barn-owl”のインストールおよび設定です。 barn-owlは、各種機械学習アルゴリズムのモデルを作成したり、作成したモデルを利用してスコアリングすることができるwebアプリケーションです。Webアプリケーションのため、Apachのインストール・設定、ネットワーク設定が必要となります。 #前提 JSCプロジェクトでの機械学習サーバー(MLサーバー)はEC2上にAimstarおよび保守端末から接続できる環境になっています。 保守端末とMLサーバー間はssh、httpの通信が可能。 AismtarとMLサーバー間はhttpの通信が可能。 AismtarとMLサーバー間でファイル連携をする場合は、S3を介する想定。 OSはUbuntu 20.04を想定しています。CentOSを使用する際には、機械学習サーバー構築手順書_JSC案件_20190328_kawa_ykoba修正を参照して下さい。 (参)ローカル環境でAmazonLinux2を検証したい場合には、VirtualBoxなどのツールを用いて、    仮想環境上にAmazonLinux2を構築することも可能です。  - 参考URL:「Amazon Linuxのローカル環境を作成する」 https://qiita.com/horikeso/items/cc3d628069421e11d7ab  - 関連ファイル:\\ss7\share\Aimstar\10_Aimstar導入顧客\2018_ジュピターショップチャンネル\60_導入\AWS社内開発環境\分析サーバー構築\Amazon Linux 2 ローカル仮想環境構築   JSC案件ではGPUを使用しないため、CUDAおよびCUDNNのインストールは行いません。 GPUが利用できない環境であってもbarn-owl自体は問題なく動作させることができます。 また、本番環境ではApacheの利用を推奨しますが、開発環境では、後述するDjangoの簡易サーバーを使用することもできます。 以下の手順はgithubのREADME.mdを書き直したものです。 #導入手順概要 1. 初期設定・ツールインストール 2. barn-owlのソースコードの配置 3. pythonの実行環境作成 4. Apacheのインストールと関連する設定 5. ssh関連の設定 6. barn-owlの初期設定 7. barn-owlの起動 以下の作業は、barn-owlを起動後、ブラウザ上で設定します。 8. barn-owl起動後の設定 9. 外部アプリケーションの登録(barn-owl,Aimstar) 以降個々の手順について説明します。 #導入手順詳細 ## 1. 初期設定・ツールインストール ### 1.1. セキュリティの設定 Amazon EC2ではセキュリティグループの設定によって 事前にAWSコンソール画面にログインし、起動するサーバーのポートを開放しておいてください。 デフォルトではHTTPS:8001番。(※設定によりHTTPで起動することも可能です。) (上記より、firewalldの設定によるポート開放は不要) ### 1.2. 各種ツールインストール まず、前提となる各種ツールをダウンロードします。 ```sh apt-get install build-essentials' #yum -y install sqlite-devel openssl-devel httpd-devel #Ubuntuのため略(pyenvに必要っぽい) ``` # 2. barn-owlのソースコードの配置 ```sh git clone -b develop http://192.168.0.63/barn-owl/barn-owl.git ``` 開発環境を作成する場合は、SUP社内gitlab(192.168.0.63/barn-owl/barn-owl)の"develop"リポジトリからgit cloneでソースコードを取得し、User直下に配置してください。(配置場所は都合の良い場所でよい。) もし、権限がない場合は管理者に問い合わせてください。 本番環境に配置する場合は、社内で取得したソースコードを用いて、User直下に配置してください。(配置場所は都合の良い場所でよい。) 今回は下記ファイルを解凍・利用してください。 "\\ss7\share\Aimstar\10_Aimstar導入顧客\2018_ジュピターショップチャンネル\60_導入\AWS社内開発環境\分析サーバー構築\barn-owl.zip" ## 3. Anaconda環境構築 ### 3.1. Anacondaのインストール barn-owlはpython3.Xで動作します。 以下、Amazon Linux2でのインストール方法を記載します。 Amazon Linuxのyumにあるpythonを確認し、インストールします。 以下のurlより適切なanacondのバージョンを選択後、 https://www.anaconda.com/products/individual#linux 適切なバージョンのanacondaをインストール ```sh wget https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh bash Anaconda3-2020.02-Linux-x86_64.sh ``` ちゃんと構築できているか確認 ```sh conda -V ``` ## 3.2. anacondaライブラリのインストール pythonが利用できるようになったら、barn-owlのソースコードのトップディレクトリ(README.mdと同じディレクトリ)に仮想環境を作成しましょう。(具体的な方法は後述) ```sh cd ~/barn-owl/ # 仮想環境の作成 conda env create -f barn-owl_env.yaml # 次のコマンドで仮想環境をアクティベートする conda activate barn-owl_env ``` ※依存関係があるパッケージに変更があった場合には ```sh conda env export > barn-owl_env.yaml ``` でyamlファイルを更新すること。 ### 4. Apacheのインストールと関連する設定 参考: https://qiita.com/itisyuu/items/dafa535adc8197208af1 apache2をインストールする ```sh sudo apt-get -y install apache2 apache2-dev #systemctl start apache2 ``` mod_wsgiのインストール (mod-wsgiとは、PythonのプログラムをApache HTTP Serverで動作させるためのモジュール) (mod_wsgiはpythonのライブラリにある) ```sh pip install mod_wsgi sudo mod_wsgi-express install-module ``` で現れてた文字列をコピーし (自分の場合は、'/usr/lib/apache2/modules/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so') ```sh vi /etc/apache2/apache2.conf ``` の末尾に書き込む。 #apacheとDjangoを結びつける ```sh vi /etc/apache2/sites-available/django.conf ``` でconfファイルを作成し ```sh <VirtualHost *:80> WSGIDaemonProcess proj1 python-home=/home/yuyonod/anaconda3/bin/python WSGIScriptAlias/ /home/yuyonod/work/barn-owl/test/test_project/test_project/wsgi.py <Directory /home/yuyonod/work/barn-owl/test/test_project/test_project> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> ``` のような内容を書き込みます。各自環境に合わせてください。 以下をbarn-owl.confに記載 ```sh LoadModule wsgi_module modules/mod_wsgi-py37.cpython-37m-x86_64-linux-gnu.so WSGIScriptAlias / /home/ec2-user/barn-owl/Django/ML/wsgi.py WSGIPythonHome /home/ec2-user/barn-owl/.env WSGIPythonPath /home/ec2-user/barn-owl/Django/ <Location / > Require all granted </Location> <Directory /home/ec2-user/barn-owl/Django/ML> <Files wsgi.py> Require all granted </Files> </Directory> ``` ##起動確認 ```sh $sudo a2dissite 000-default $sudo a2ensite django $systemctl restart apache2 ``` で設定ファイルを読みこみapacheを起動させる。 ※以下のエラーが出る場合 Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details. **要解決法** ------------------------------------------------------ここまで編集(20200628)------------------------------------------------------ ### 5. ssh関連の設定 鍵がなければ、作成しましょう。 ```sh ssh-keygen -t rsa ``` 鍵を作成したら、クライアント側(Aimstarサーバー)に登録してください ```sh ssh-copy-id {username}@{ip-address} ``` 次に、秘密鍵、公開鍵、サーバ証明書を作成・登録します。 ```sh openssl genrsa > barn-owl.key openssl req -new -key barn-owl.key > barn-owl.csr openssl x509 -req -signkey barn-owl.key < barn-owl.csr > barn-owl.crt mkdir /etc/httpd/conf/ssl/ mkdir /etc/httpd/conf/ssl/ mv barn-owl.key /etc/httpd/conf/ssl/ mv barn-owl.crt /etc/httpd/conf/ssl/ ``` ### 6. barn-owlの初期設定 barn-owlの初期設定のうち以下のものはCLIで実行します。 ・マイグレーション ・スーパーユーザーの作成 まず、上述の仮想環境をアクティベートして、Djangoディレクトリに移動し、以下のコマンドを実行してください。 ```sh python manage.py makemigrations regression python manage.py makemigrations classification python manage.py makemigrations clustering python manage.py makemigrations recommendation python manage.py makemigrations datafile_manager python manage.py migrate ``` 次にスーパーユーザーを作成します。 ```sh python manage.py createsuperuser ``` ユーザー名、パスワード、メールアドレスの入力を求められます。このうち、ユーザー名とパスワードはのちの手順で使用するので、控えておいてください。 メールアドレスを利用する機能は今のところ実装していないので、空欄にして構いません。 ([例] username:aimstar, password:supreme) ### 7. barn-owlの起動 以上の設定が終了したら、barn-owlを起動可能となります。 barn-owlはscriptsフォルダ内のserver-startup.sh というシェルスクリプトを使用して起動します。 barn-owl/scripts 内のserver.conf.sampleを参考に、server.confを作成してください。 少なくともipアドレスは書き換える必要があります。 ```sh cp server.conf.sample server.conf ``` server.confを書き換えたら、server-startup.shを実行してください。 ただし、server-startup.shとserver.confは改行コードがCR+LFになっている場合はエラーになるので、LFに変換して実行してください。 ```sh ./server-startup.sh # もしくは nohup ./server-startup.sh ``` https://{id-address}:{port}/api-auth/login にアクセスできることを確認し、 先ほど作成したスーパーユーザーアカウントでログインしてください。 なお、nohupモードで起動した際に、停止したい場合にはプロセスIDを特定してkillする必要があります。 ```sh # PIDを確認 ps -ef kill [PID] ``` nohupモードで起動した際の起動結果は、scripts/nohup.outに出力されています。 また、正常起動しなかった場合は、エラーログがDjango/logディレクトリあるのでそちらを参照してください。 ### 8. barn-owl起動後の設定 barn-owl起動後、ブラウザ上で「グループ」「ユーザー」を設定(作成)します。 「グループ」「ユーザー」作成後、外部から接続するためのclient_idとclient_secretが発行可能となります。 ## 8.1. グループの作成 1. groupをクリックする 1. add group をクリックする 1. 適当な名前を入力する 1. 以下のpermissionを追加する(フィルタで検索し、該当したものをすべて追加する) - classification - regression - clustering - recommendation - datafile_manager 1. save する ## 8.2. ユーザーの作成 1. users をクリックする 1. add user をクリックする 1. usernameとpasswordを入力する。このusernameとpasswordはAimstarのconfに記述するほか、接続する際に必要となる情報なので控えておくこと。 1. スーパーユーザー作成時と同様にメールアドレスを入力する欄がありますが、気にしなくて良いです ### 9. アプリケーションの登録 認証に必要な情報は「アプリケーション」という単位で発行しています。ここでの「アプリケーション」とは、barn-owl に対して、リクエストを投げる外部のソフトウェアのことであり、今回はAimstarが該当します。そのほかにも、開発者がデバッグ用にリクエストを投げる場合もアプリケーションの登録が必要です。 アプリケーションの登録をするために、前の手順で作成したユーザーでログインする必要があります。次のurlにアクセスしてください(もし、まだスーパーユーザーとしてログインしたままであれば、いったんログアウトしてください。) https://{ip-address}:{port}/api-auth/login/ ログインしたら、click here をクリックし、以下の情報を入力します。 |項目|内容| |-|-| |Name|アプリケーション名。AimstarV75| |Client id|接続用id。書き換えないこと| |Client secret|同上| |Redirect urls|空欄でよい| |Client type|Confidentialを選択する| |Authorization grant type|Resorce owner password-basedを選択する| 入力したらsave をクリックしてください。Client id とClient secret が接続するために必要な情報です。これらは控えておいてください。 AimstarからAPIを利用する場合であっても、そのほかの方法でAPIを利用する場合であっても必要な情報は以下の4つです。 * ユーザー名 * パスワード * Client id * Client secret Aimstarであれば、これらをaimstar+local.confに記述する必要があります。 ```conf machine_learning.server.url=https://{ip-address}:{port}/v2/ machine_learning.server.basic.username={username} machine_learning.server.basic.password={password} # アクセストークンを取得するためのAPI oauth2.0.machine_learning.url=https://{ip-address}:{port}/oauth2/token/ oauth2.0.machine_learning.userid={client_id} oauth2.0.machine_learning.secret={client_secret} #DatasetFile dataset_file.host_ip_address={ip-address} dataset_file.file.protocol=scp dataset_file.user.name={username} ```

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully