ネットワークカードの有効化

あれ、centos7だとifcfg-eth0がない!?
ifcfg-enp0s3を見てみる。
お、ONBOOT=no の項目がありますね。

ONBOOT=yes
service network restart

RHEL7/CentOS7では、net-toolsを「deprecated」

ssh接続してみましょう。
portは2222でしたね。
ちなみに、2222は
ESET remote administrator[
ほう!

login as: root
root@127.0.0.1’s password:
Last login: Sat Oct 27 10:06:53 2018
[root@localhost ~]#

osの確認

[root@localhost ~]# cat /etc/issue
\S
Kernel \r on an \m

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ~]# cat /proc/version
Linux version 3.10.0-862.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc versi on 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Fri Apr 20 16:44:24 UTC 2018

ぎゃあああああああああああああああああああああああああああああああああ

ISOから仮想マシン新規作成

名前、タイプ、バージョンを指定
メモリ 512m

仮想ハードディスクのファイルタイプ
VirtualBox Disk Image

物理ハードディスクにあるストレージ
可変サイズ

仮想マシンが作成されました。

コントローラーIDEを編集する

コントローラーIDEでcentos7のiosを選択

オーディオの有効化のチェックを外す

ネットワーク アダプター1の「割り当て」に「NAT」が設定されている
「高度」を展開し、「ポートフォワーディング」をクリック

メルカリ機械学習

tech系のイベント@六本木ヒルズ18F メルカリ

ビールとご飯を無料配布
ビールは久しぶりに飲んだわ

で、学んだこと
1. apple, amazon, googleをwatchしている
2. 学会の論文を読んで、それをモデリングに落として試している
3. mercariはawsを使っている
4. 機械学習ができて当然は本当だった
5. MLチーム構成は半分日本人、次にインド人
6. 全部出来るやつが強い(当たり前か。。)

どうすっかなー

VBoxManage

VBoxManageって何?

VBoxManage is the command-line interface to VirtualBox. With it, you can completely control VirtualBox from the command line of your host operating system.

Chapter 8. VBoxManage - Oracle VM VirtualBox® User Manual

VBoxManage supports all the features that the graphical user interface gives you access to, but it supports a lot more than that. It exposes really all the features of the virtualization engine, even those that cannot (yet) be accessed from the GUI.

Chapter 8. VBoxManage - Oracle VM VirtualBox® User Manual

>VBoxManage list vms
‘VBoxManage’ は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

認識されてないぞ。。

ここで躓くとキツイな。

906mってどれだけ時間かかってんだか。

isoファイルとは

ISOというのは、国際標準機構(ISO)が定義しているということ
ISOイメージファイルは、世界中で利用されるものなので、国際標準で形式が定義されている

centosは以下のURLからDLできる
https://wiki.centos.org/Download

NOTE: CentOS is available free of charge.
フリーと書いてます。ドメインがcentos.orgなのでcentosのようにですね。

isoのmirrorページがあるので、クリックしてみます。
http://isoredirect.centos.org/centos/7/isos/x86_64/

The following mirrors in your region should have the ISO images available:
http://ftp.iij.ad.jp/pub/linux/centos/7.5.1804/isos/x86_64/
http://mirror.fairway.ne.jp/centos/7.5.1804/isos/x86_64/
http://ftp-srv2.kddilabs.jp/Linux/packages/CentOS/7.5.1804/isos/x86_64/
http://ftp.yz.yamagata-u.ac.jp/pub/linux/centos/7.5.1804/isos/x86_64/
http://mirrors.cat.net/centos/7.5.1804/isos/x86_64/
http://ftp.jaist.ac.jp/pub/Linux/CentOS/7.5.1804/isos/x86_64/
http://ftp.tsukuba.wide.ad.jp/Linux/centos/7.5.1804/isos/x86_64/
http://ftp.riken.jp/Linux/centos/7.5.1804/isos/x86_64/
http://ftp.nara.wide.ad.jp/pub/Linux/centos/7.5.1804/isos/x86_64/

なにこれ。

sshdのポートを22番以外で開ける

ネットワークの入り口:ゲートウェイから全てのパケットが入ってくるので、サーバ毎にFirewallを設定する必要がある
Linuxであればiptables

22番以外を開ける理由は、22番ポートへの侵入を目的とするアタックを回避する

VPN経由で内部からしかリモートログインできない、特定のIPアドレスからのみリモートログイン出来る、という場合はFirewallが守る

代表的なプロトコル
ssh: tcp 22
http: tcp 80
https: tcp 443

ftpを使うなら tcp20, telnet 23, smtp 25, dns 53, dhcp 67, dp 68, pop3 110, ntp 123

なるほどね。

ローカル環境構築

なんだよこれ、ローカル構築とかいって、すげー重要やんけwww びっくりした。
いやー参ったね。。

vagrant boxとは?
– boxとは仮想マシンを作成する際に必要なOSのディスクイメージ、仮想マシンのテンプレート

あれ、boxって、vagrant fileと違うの?
まーいいか。
あ、boxをaddして、vagrant initして、vagrant upだ。initとupはわかるから、要はvagrant upね。

vagrantのboxをインストールする方法

vagrant box and [box-name] [box-url]

公式のページです。
https://www.vagrantup.com/docs/boxes.html

vagrant list of base boxes
http://www.vagrantbox.es/

centosは? boxesを見ると、centos 7.2ってのがあって、これが一番最新のように見えるが。。
CentOS 7.2 x64 (Minimal, Puppet 4.2.3, Guest Additions 4.3.30)

centosのサイトを覗いてみる。ナニコレ、バージョンが幾つかよく分からない。
https://www.centos.org/download/

あれ、centos 7.4が最新のよう。centos6だと、6.10のようにです。つまりvagrant boxesはやや遅れ気味。
https://openstandia.jp/oss_info/centos/

これを入れたい。やってみよう。
https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box

$ vagrant add centos72 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box

あ、なんか行けそうですね。vagrant box add は時間がかかりそうですが。
あれ?
>vagrant box list
bento/centos-6.7 (virtualbox, 2.2.7)
bento/centos-6.8 (virtualbox, 2.3.0)
centos72 (virtualbox, 0)
trusty64 (virtualbox, 0)
ubuntu/trusty64 (virtualbox, 20161207.0.0)

これで vagrant init centos72

vagrant init centos72

おおおおお、vagrant file理解した。
次はboxを作りたいですな。

IAMロールを作成する

IAMロールを作成する
ポリシーには以下二つの権限をつける。
-AWSLambdaBasicExecutionRole
-AmazonS3FullAccess

'use strict';

const aws = require('aws-sdk');
const s3 = new aws.S3();

exports.handler = function(event, context){
	console.log('Received event:', JSON.stringify(event, null, 2));

	const uploadBucket = event.Records[0].s3.bucket.name;
	const key = event.Records[0].s3.object.key;

	const params = {
		Bucket: uploadBucket,
		Key: key
	};
	s3.getObject(params, function(err, data){
		if(err){
			console.log(err, err.stack);
			context.done(err, err.stack);
		} else {
			console.log('data: ', data);

			const copyBucket = 'sample-copy-bucket';
			const params = {
				Bucket: copyBucket,
				Key: key,
				Body: data.Body
			};
			s3.putObject(params, function(err, data){
				if(err){
					console.log(err, err.stack);
					context.done(err, err.stack);
				} else {
					console.log('data: ', data);
					context.suceed('complete!');
				}
			});
		}
	});
};