VirtualBox上でMapRを試すにはMapRが提供するsandboxを利用するのが手っ取り早いですが、ここでは自前でインストールする方法を紹介します。
今回はVagrant等は使わずに全て手動で行います。
1. OSイメージのダウンロード
今回は2017/03で最新版であるMapR 5.2のインストールを行います。
OS/MapRマトリックス よりサポートされているOS(今回はCentOS 7.2)をダウンロードします。
2. イメージの作成
VirtualBoxで新しいイメージを作成します。
- Red Hat (64-bit) 選択
- メモリは最小限の8GBとしますが、いろいろ遊びたい場合は増やしておきましょう
- Diskの追加。このDiskはOS用のDiskでMapRが提供する分散ファイルシステム(MapR-FS)用ではないです
- Storageは"Fixed Size"で
- Diskサイズは適当に設定
- 次にMapR-FS用のディスクを追加します。"Controller SATA"のところでHard Diskの追加アイコンをクリック
- インストール用にBootイメージを追加します。"Controller IDE"から”Adds optical drive"を選択
- 先程ダウンロードしたisoファイルを選択
- Network画面よりNetwork Adapterで"Bridged Adapter"を選択
これにてイメージ作成は完了となります。
3. OSのインストール
OSインストール時に気をつけることは以下の5点になります
- 言語は英語にしておきましょう。マルチバイト言語ではインストールが失敗する事があります
- rootのパスワードを設定しましょう
- OSのインストール時には先程追加した2つのDiskのうち、ひとつをOS用に選択してください。もう一つは放置で
- ホスト名の設定&EthernetはONにしておきましょう
4. MapRインストール準備
MapRのインストール前に以下の項目をチェックしておいてください
- firewalld(CentOS 6の場合はiptables) の停止
[root@samplehost ~]# systemctl stop firewalld
Failed to stop firewalld.service: Unit firewalld.service not loaded.
[root@samplehost ~]# ps aux | grep firewall
root 9792 0.0 0.0 112616 736 pts/0 R+ 00:35 0:00 grep --color=auto firewall
- hostname 設定
hostname -f コマンドでホスト名が返ってくる用、以下のように設定してください
[root@samplehost tmp]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:56:fc:e3 brd ff:ff:ff:ff:ff:ff
inet 10.9.1.110/24 brd 10.9.1.255 scope global dynamic enp0s3
valid_lft 12907sec preferred_lft 12907sec
inet6 fe80::a00:27ff:fe56:fce3/64 scope link
valid_lft forever preferred_lft forever
[root@samplehost tmp]# vi /etc/hosts
[root@samplehost tmp]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.9.1.110 samplehost
[root@samplehost tmp]# hostname -f
samplehost
また、MapR-FS用にディスクが追加されていることも確認しておきましょう。
下記の使われていない/dev/sdbがMapR-FS用ディスクとなります。
[root@samplehost tmp]# fdisk -l | grep dev
Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 sectors
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 16777215 7875584 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 sectors
Disk /dev/mapper/centos-root: 7159 MB, 7159676928 bytes, 13983744 sectors
Disk /dev/mapper/centos-swap: 859 MB, 859832320 bytes, 1679360 sectors
5. MapRのインストーラの起動
MapRインストーラの起動を行います。以下の手順にそって実行してください。
- MapR インストーラのダウンロード
こちらのページのようにInstallerをダウンロードします
# yum install -y wget
# wget http://package.mapr.com/releases/installer/mapr-setup.sh -P /tmp
- インストーラ起動
インストーラを起動するとプロンプトの中で質問が来ますが、基本Enterで答えてください。
maprユーザのパスワードを聞かれますので、設定してください。
# sudo bash /tmp/mapr-setup.sh
MapR Distribution Initialization and Update
Copyright 2017 MapR Technologies, Inc., All Rights Reserved
http://www.mapr.com
Install required packages? [Y]:
Installing package dependencies (curl device-mapper iputils libsysfs lvm2 nc nfs-utils nss ntp openssh-clients openssh-server openssl python-devel python-pycurl
sdparm sshpass sudo syslinux sysstat wget which)
---
Enter [host:]port that cluster nodes connect to this host on [samplehost:9443]:
Testing for cluster admin account...
Enter MapR cluster admin user name [mapr]:
User 'mapr' does not exist. Creating new cluster admin account...
Enter 'mapr' uid [5000]:
Enter 'mapr' group name [mapr]:
Enter 'mapr' gid [5000]:
Enter 'mapr' password:
Confirm 'mapr' password:
...Success
Installing packages...
---
To continue installing MapR software, open the following URL in a web browser
If the address 'samplehost' is internal and not accessible
from your browser, use the external address mapped to it instead
https://samplehost:9443
6. MapRのインストール
MapRインストーラの起動時に出てきたアドレスにホストOSのブラウザからアクセスします。
VirtualBoxのホストでhosts設定していない場合は、ipアドレスに直接アクセスしてください。
今回のケースでは以下のいずれかのアドレスとなります。
以下インストーラ実行時の注意点となります
- Sign inには”mapr"ユーザで先程設定したパスワードを使ってログインしましょう
- MapR Version は "5.2.0"
- Edtionは"Converged Eterprise Edition"
- License Optionは"Add License After Installation Complete"
- Select Servicesでは任意のテンプレを選択可能ですが、今回は1ホストでリソースも厳しいので、"Custom Services"を選択し、"Show advanced service options"から"YARN + MapReduce (5.2.0)"のみ選択します
- "Configure Nodes"
- "Configure Disks"のDisks設定の際に追加したディスク("/dev/sdb")を設定
- "Configure Remote Authentication"を設定。ここではSSH Usernameに"root"か"mapr"を選択し、パスワードかKeyアクセスか好きなほうを選択してください
- "Verify Nodes"画面ではディスクサイズなどでWarningが出ることがありますが、とりあえず問題ありませんのですすめましょう
- Veririficationが終わったらインストール実行となります
インストールが終わると管理画面(MCS)にアクセス可能となります。
今回のケースでは以下のいずれかのアドレスとなります。
7. ライセンス適用
インストールが終わったらライセンスを適用します。適用前にクラスタのIDをMCSから確認しましょう。
MCSの右上にある"Manage License" -> 右上の"Cluster ID"になります。
- 期限付きのライセンスをmapr.comから設定します
この後、コンソールに入ってwardenの再起動を行います
# service mapr-warden restart
8. Have FUN!
MapRではNFS Server経由でファイルへのアクセスが可能です。
デフォルトでは "/mapr/[クラスタ名]"以下にMapR-FSがマウントされます
[root@samplehost tmp]# hadoop fs -ls /
Found 5 items
drwxr-xr-x - mapr mapr 0 2017-03-27 05:26 /apps
drwxr-xr-x - mapr mapr 0 2017-03-27 05:23 /hbase
drwxr-xr-x - mapr mapr 0 2017-03-27 05:35 /opt
drwxrwxrwx - mapr mapr 0 2017-03-27 05:23 /tmp
drwxr-xr-x - mapr mapr 1 2017-03-27 05:27 /var
[root@samplehost tmp]# ls /mapr/samplecluster/ -l
total 1
drwxr-xr-x. 2 mapr mapr 0 Mar 27 05:26 apps
drwxr-xr-x. 2 mapr mapr 0 Mar 27 05:23 hbase
drwxr-xr-x. 2 mapr mapr 0 Mar 27 05:35 opt
drwxrwxrwx. 2 mapr mapr 0 Mar 27 05:23 tmp
drwxr-xr-x. 3 mapr mapr 1 Mar 27 05:27 var
現状はMapReduce2しかインストールしていないので、サンプルのMR2を実行してみます
[root@samplehost tmp]# su - mapr
Last login: Mon Mar 27 05:21:40 EDT 2017
[mapr@samplehost ~]$ yarn jar /opt/mapr/hadoop/hadoop-2.7.0/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.0-mapr-1607.jar teragen 5000 /tmp/teragen-test
17/03/28 00:23:58 INFO client.MapRZKBasedRMFailoverProxyProvider: Updated RM address to samplehost/10.9.1.110:8032
17/03/28 00:23:59 INFO terasort.TeraSort: Generating 5000 using 2
17/03/28 00:23:59 INFO mapreduce.JobSubmitter: number of splits:2
17/03/28 00:23:59 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1490608083785_0001
17/03/28 00:24:00 INFO security.ExternalTokenManagerFactory: Initialized external token manager class - com.mapr.hadoop.yarn.security.MapRTicketManager
17/03/28 00:24:00 INFO impl.YarnClientImpl: Submitted application application_1490608083785_0001
17/03/28 00:24:00 INFO mapreduce.Job: The url to track the job: http://samplehost:8088/proxy/application_1490608083785_0001/
17/03/28 00:24:00 INFO mapreduce.Job: Running job: job_1490608083785_0001
17/03/28 00:24:11 INFO mapreduce.Job: Job job_1490608083785_0001 running in uber mode : false
17/03/28 00:24:11 INFO mapreduce.Job: map 0% reduce 0%
17/03/28 00:24:18 INFO mapreduce.Job: map 50% reduce 0%
17/03/28 00:24:22 INFO mapreduce.Job: map 100% reduce 0%
17/03/28 00:24:23 INFO mapreduce.Job: Job job_1490608083785_0001 completed successfully
17/03/28 00:24:23 INFO mapreduce.Job: Counters: 32
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=192622
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
MAPRFS: Number of bytes read=164
MAPRFS: Number of bytes written=500000
MAPRFS: Number of read operations=14
MAPRFS: Number of large read operations=0
MAPRFS: Number of write operations=10058
Job Counters
Launched map tasks=2
Other local map tasks=2
Total time spent by all maps in occupied slots (ms)=7012
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=7012
Total vcore-seconds taken by all map tasks=7012
Total megabyte-seconds taken by all map tasks=7180288
DISK_MILLIS_MAPS=3506
Map-Reduce Framework
Map input records=5000
Map output records=5000
Input split bytes=164
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=26
CPU time spent (ms)=370
Physical memory (bytes) snapshot=281276416
Virtual memory (bytes) snapshot=5809065984
Total committed heap usage (bytes)=251396096
org.apache.hadoop.examples.terasort.TeraGen$Counters
CHECKSUM=10800304792171
File Input Format Counters
Bytes Read=0
File Output Format Counters
Bytes Written=500000
[mapr@samplehost ~]$ ls -lh /mapr/samplecluster/tmp/teragen-test/
total 489K
-rwxr-xr-x. 1 mapr mapr 245K Mar 28 00:24 part-m-00000
-rwxr-xr-x. 1 mapr mapr 245K Mar 28 00:24 part-m-00001
-rwxr-xr-x. 1 mapr mapr 0 Mar 28 00:24 _SUCCESS
他のディストリビューションやApache Hadoopが提供するHDFSとは異なり、ファイルの修正が可能となります.
[root@samplehost tmp]# cat /tmp/testfile
abcde
[root@samplehost tmp]# hadoop fs -put ./testfile /tmp/
[root@samplehost tmp]# hadoop fs -ls /tmp
Found 1 items
-rwxr-xr-x 3 root root 6 2017-03-28 00:10 /tmp/testfile
[root@samplehost tmp]# cat /mapr/samplecluster/tmp/testfile
abcde
[root@samplehost tmp]# vi /mapr/samplecluster/tmp/testfile <<-- 修正
[root@samplehost tmp]# hadoop fs -cat /mapr/samplecluster/tmp/testfile
abcde
fghij
以上です!