Praktikum ini membuat sebuah single-node Spark cluster menggunakan Docker dengan integrasi MySQL untuk penyimpanan data Hive Metastore dan ZooKeeper untuk koordinasi HBase serta engine pemrosesan data dengan Spark. Anda dapat melakukan percobaan atau pembelajaran Big Data lokal di Windows.
- Hadoop: 3.4.1
- Hive: 4.0.1
- Tez: 0.10.4
- HBase: 2.5.11
- ZooKeeper: 3.8.4
- MySQL: 8.0 (untuk Hive Metastore)
- SPARK: 3.5.5
Sebelum memulai, pastikan Anda telah menginstal dan menyiapkan hal-hal berikut:
-
Install Docker Desktop
Unduh dan instal dari https://www.docker.com/products/docker-desktop. -
Login atau Daftar Akun Docker
Buka Docker Desktop dan login menggunakan akun Docker Anda. Jika belum punya, silakan daftar terlebih dahulu. -
Install WSL dan Ubuntu 22.04 di Windows
Buka PowerShell (Run as Administrator) dan jalankan:wsl --install -d Ubuntu-24.04
-
Buka Terminal Ubuntu (WSL)
Posisikan terminal di direktoriC:\
:cd /mnt/c
Atau alternatif lain, gunakan terminal di Windows:
cd C:\
Setelah prasyarat selesai, ikuti langkah-langkah berikut:
-
Clone Repo
git clone https://github.com/sains-data/bigdata-spark.git
-
Download Dependencies - jika belum memiliki file yang diperlukan:
-
Buka folder di VS Code
Buka folderbigdata-spark
di VS Code, lalu ubah semua baris dengan formatCRLF
keLF
.- Di VS Code: Klik
CRLF
di kanan bawah, lalu pilihLF
.
- Di VS Code: Klik
-
Arahkan Terminal ke Folder Repo
cd /mnt/c/bigdata-spark
Atau pada terminal Windows:
cd C:\bigdata-spark
-
Salin file
hadoop-3.4.1.tar.gz
ke folder ini
File ini tidak diunduh otomatis oleh Dockerfile.- Unduh dari: https://downloads.apache.org/hadoop/common/hadoop-3.4.1/hadoop-3.4.1.tar.gz
- Pindahkan ke folder
bigdata-hive-mysql
💡 Catatan: Jika ingin Docker otomatis mengunduh file, bisa tambahkan perintah
curl
ke dalamDockerfile
seperti:RUN curl -O https://downloads.apache.org/hadoop/common/hadoop-3.4.1/hadoop-3.4.1.tar.gz
-
Salin file
hive-4.0.1-bin.tar.gz
dantez-0.10.4-bin.tar.gz
ke folder ini
File-file ini tidak diunduh otomatis oleh Dockerfile.
-
Unduh dari:
-
Pindahkan file-file tersebut ke folder
bigdata-hive-mysql
.
💡 Catatan: Jika ingin Docker otomatis mengunduh file, bisa tambahkan perintah
wget
ke dalamDockerfile
seperti:
RUN wget https://downloads.apache.org/hive/hive-4.0.1/apache-hive-4.0.1-bin.tar.gz
RUN wget https://downloads.apache.org/tez/tez-0.10.4/apache-tez-0.10.4-bin.tar.gz
Salin file hbase-2.5.11-bin.tar.gz dan file zookeeper-3.8.4-bin.tar.gz ke folder ini
- Bangun Docker Image
bash build.sh
- Jalankan Container
bash start.sh
- Cek Apakah Container Jalan
docker ps -a
- Login ke Container
bash login.sh
setelah masuk ke kontainer tunggu beberapa menit untuk semua fungsi berjalan, untuk melihat history log nya bisa lihat di:
cat /tmp/bootstrap.log
lihat semua status apakah sudah dijalankan atau belum.
Berikut ini jika ingin memeriksa hive dan hbase, jika tidak bisa dilewatkan saja:
- Cek Aktivitas Hive dan Port yang Tersedia
Cek port apakah sudah aktif untuk
hivemetastore
di port 10000 danhiveserver2
di port 10001 dengan perintah:
netstat -nlpt
Atau cek satu-satu dengan perintah:
netstat -nlpt | grep 10000
netstat -nlpt | grep 10001
Jika belum muncul, tunggu beberapa menit dan cek kembali. Jika sudah muncul, lanjutkan ke langkah berikutnya.
- Koneksi ke Hive dengan Beeline - jika ingin memeriksa Hive Metastore Setelah port 10001 aktif, lanjutkan dengan membuka koneksi Hive menggunakan Beeline:
beeline -u jdbc:hive2://localhost:10001/ -n hive -p hive
Di sini:
-n
adalah username Hive (misalnyahive
).-p
adalah password Hive (misalnyahive
).
Jika berhasil terkoneksi, Anda siap untuk menggunakan Hive.
- Akses GUI Hiveserver
Cek juga antarmuka web GUI Hiveserver di:
http://localhost:10002.
Detail Akses GUI Hive:
Komponen Hive | Port | URL Akses |
---|---|---|
Hive Web UI | 10002 | http://localhost:10002 |
-
Keluar dari Koneksi Hive Setelah selesai, tekan
Ctrl + C
untuk keluar dari koneksi Beeline. -
Akses HBase Shell:
hbase shell
Untuk mengakses HBase Web UI, Anda bisa membuka browser dan akses alamat berikut:
http://localhost:16010
Detail Akses GUI HBase:
Komponen HBase | Port | URL Akses |
---|---|---|
HBase Master UI | 16010 | http://localhost:16010 |
HBase REST API | 16030 | http://localhost:16030 |
- Keluar dari hbase Setelah keluar dari hbase shell, ketik:
exit
selanjutnya kita akan masuk ke root bash
- Masuk ke Spark Shell ketik perintah berikut
spark-shell
tunggu sampai muncul logo spark 3.5.5
Detail Akses GUI SPARK:
Komponen SPARK | Port | URL Akses |
---|---|---|
SPARK UI | 4040 | http://localhost:4040 |
untuk keluar dari spark-shell maka ketik CTRL + C
di keyboard, lalu kita akan masuk ke root bash
kegiatan dilanjutkan ke latihan.
Berikut ini cara untuk keluar dari root bash dan menghentikan container
- Keluar dari Root bash ketik:
exit
- Hentikan Container Hentikan container dengan menjalankan:
bash stop.sh
Tunggu hingga container benar-benar berhenti.
Port | Service | URL (jika ada) |
---|---|---|
9000 | HDFS NameNode | - |
9866 | HDFS DataNode | - |
9870 | HDFS Web UI | http://localhost:9870 |
8088 | YARN ResourceManager | http://localhost:8088 |
8030 | YARN Scheduler | - |
19888 | MapReduce JobHistory | http://localhost:19888 |
Port | Service | URL |
---|---|---|
10000 | Hive Metastore | - |
10001 | HiveServer2 | jdbc:hive2://localhost:10001 |
10002 | Hive Web UI | http://localhost:10002 |
Port | Service | URL |
---|---|---|
16000 | HBase Master | - |
16010 | HBase Master Web UI | http://localhost:16010 |
16020 | HBase RegionServer | - |
16030 | HBase REST Server | http://localhost:16030 |
Port | Purpose |
---|---|
2181 | Client connections |
2888 | Peer communication |
3888 | Leader election |
Port | Service | URL |
---|---|---|
4040 | SPARK UI | http://localhost:4040 |
Port | Service |
---|---|
3306 | MySQL |
Untuk pertanyaan atau kontribusi, silakan buka Issue di repo ini atau hubungi Asisten Praktikum Analisis Big Data.