Recents

Showing posts with label Administrasi Server. Show all posts
Showing posts with label Administrasi Server. Show all posts

Tuesday, July 7, 2015

ownCloud 8.0.4 (NGiNX+MariaDB+SSL) di CentOS 7

Assalamu'alaikum.wr.wb.

Halo all, ketemu lagi dengan blog saya yang insya allah postingan saya bermanfaat semua untuk kalian semua yang membaca hahaha. Yuk masuk ke materi disini saya akan posting materi Cloud Storage menggunakan ownCloud 8.0.4. OwnCloud sama seperti google drive, dropbox, dan lain-lain namun dia bersifat open-source. Penasaran? Langsung saja ke materi.



A. Penjelasan Singkat

Saat ini layanan Cloud Storage sudah banyak bertebaran di internet, dari yang gratisan hingga berbayar. Contoh yang populer saat ini adalah Dropbox yang menyediakan space sebesar 2GB secara cuma-cuma yang bisa diupgrade hingga maksimal 18GB, kemudian ada lagi Google Drive, SugarSync, SpiderOak dan Microsoft SkyDrive. Semuanya memiliki kelebihan dan kekurangannya masing-masing.

Nah di tutorial kali ini saya akan mencoba membuat layanan Cloud Storage sendiri yang dapat digunakan untuk pribadi, komunitas, maupun lembaga atau perusahaan. Disini saya akan menggunakan sebuah CMS (Content Management System) yang memang khusus dibuat untuk layanan Cloud Storage mirip Dropbox atau Google Drive, CMS tersebut adalah ownCloud yang dapat diunduh secara cuma-cuma dan merupakan salah satu perangkat lunak sumber terbuka (Open Source).

OwnCloud termasuk dalam kategori Infrastructure as a Service (IaaS) Layanan awan. Dengan ownCloud kita dapat menyimpan file, folder, kontak, audio, galeri foto, kalender dan dokumen lainnya. Kita juga dapat mengakses file dan melakukan sinkronisasi file yang terdapat pada server ownCloud dengan perangkat mobile, desktop, atau peramba web.


B. Bahan-bahan:

- PC/Notebook
- Server yang sudah terinstall CentOS 7
- Koneksi Internet
- Smartphone Android (Kalau gapunya juga gpp hehe)


C. Langkah Kerja

1. Atur network pada server yang digunakan, disini saya menggunakan subnet /24. Kemudian restart konfigurasi interface network.
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@localhost ~]# chkconfig network on



2. Matikan SELinux menjadi disable agar tidak di proteksi policy, biar bisa masuk ke sistem.
[root@localhost ~]# vi /etc/sysconfig/selinux



3. Hentikan sekaligus martikan beberapa layanan yang sedang aktif seperti, firewall, iptables.
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld 
[root@localhost ~]# systemctl stop iptables
[root@localhost ~]# systemctl stop ip6tables
[root@localhost ~]# systemctl disable firewalld 
[root@localhost ~]# systemctl disable ip6tables
[root@localhost ~]# systemctl disable iptables


4. Kemudian update sistem agar lebih baru.
[root@localhost ~]# yum update -y


5. Untuk menginstall LEMP (Linux, NGiNX, MariaDB, PHP-FPM) Install EPEL Repository dahulu.
[root@localhost ~]# yum install epel-release -y


6. Install package berikut ini.
[root@localhost ~]# yum -y install nginx mariadb mariadb-server php-fpm php-cli php-gd php-mcrypt php-mysql php-pear php-xml bzip2 vim


7. Matikan dan disable httpd.
[root@localhost ~]# systemctl stop httpd 
[root@localhost ~]# systemctl disable httpd 


8. Karena disini saya menggunakan MariaDB, jalankan kemudian aktifkan MariaDB.
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# systemctl enable mariadb


9. Konfigurasi MariaDB untuk membuat password root.
[root@localhost ~]# mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): #Tekan Enter
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: #Masukkan Password Root
Re-enter new password: #Masukkan Password Root Kembali
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@localhost ~]#


10. Edit file PHP-FPM. Ubah user dan group menjadi nginx.
[root@localhost ~]# vi /etc/php-fpm.d/www.conf

; Start a new pool named 'www'.
[www]

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx -- Ubah jadi nginx yang sebelumnya apache
; RPM: Keep a group allowed to write in log dir.
group = nginx -- Ubah jadi nginx yang sebelumnya apache


11. Edit file nginx.conf. Hapus listen  pada line 3.
[root@localhost ~]# vi /etc/nginx/nginx.conf

    server {
        listen       80 default_server;
        listen       [::]:80 default_server; -- (Hapus bagian ini)
        server_name  _;
        root         /usr/share/nginx/html;



12. Buat direktori untuk session-path dan ubah permission.
[root@localhost ~]# mkdir -p /var/lib/php/session
[root@localhost ~]# chown nginx:nginx -R /var/lib/php/session/


13. Jalankan kemudian aktifkan NGiNX dan PHP-FPM.
[root@localhost ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost ~]# systemctl start php-fpm
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl enable php-fpm
[root@localhost ~]# systemctl enable nginx


14. Testing NGiNX di browser menggunakan IP Address Server.



15. Buat database untuk ownCloud di MariaDB.
[root@localhost ~]# mysql -u root -p
Enter password: -- (Masukkan Password Root)
Welcome to the MariaDB monitor.  Commands end with ; or \g.
]Your MariaDB connection id is 10
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database owncloud_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user ownclouduser@localhost identified by 'ownclouduser';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all privileges on owncloud_db.* to ownclouduser@localhost identified by 'ownclouduser';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
[root@localhost ~]#


16. Buat dahulu direktori untuk SSL, masuk ke direktori yang sudah dibuat. Buat SSL Cerficate dengan mengisi datanya.
[root@localhost ~] mkdir -p /etc/nginx/ssl
[root@localhost ~] cd /etc/nginx/ssl/
[root@localhost ssl]# openssl req -new -x509 -days 365 -nodes -out /etc/nginx/ssl/owncloud.crt -keyout /etc/nginx/ssl/owncloud.key
Generating a 2048 bit RSA private key
.............................................................+++
.......................................+++
writing new private key to '/etc/nginx/ssl/owncloud.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:ID
State or Province Name (full name) []:Jawa Barat
Locality Name (eg, city) [Default City]:Bekasi
Organization Name (eg, company) [Default Company Ltd]:TKJ
Organizational Unit Name (eg, section) []:Excellent
Common Name (eg, your name or your server's hostname) []:iman
Email Address []:root@iman
[root@localhost ssl]#


17. Ubah permission owner agar bisa menjadi read dan write.
[root@localhost ssl]# chmod 600 owncloud.crt 
[root@localhost ssl]# chmod 600 owncloud.key


18. Install wget dahulu agar bisa mendownload file ownCloud. Pindah ke direktori /opt. Download file ownCloud di direktori tersebut.
[root@localhost ~]# yum install wget -y
[root@localhost ~]# cd /opt/
[root@localhost opt]# wget -c https://download.owncloud.org/community/owncloud-8.0.4.tar.bz2


19. Ekstrak kemudian pindahkan ke direktori /usr/share/nginx/html/.
[root@localhost opt]# tar xfv owncloud-8.0.4.tar.bz2
[root@localhost opt]# mv owncloud/ /usr/share/nginx/html/


20. Pindah ke direktori html, ubah permission owner di direktori ownCloud ke nginx.
[root@localhost opt]# cd /usr/share/nginx/html/
[root@localhost html]# chown nginx:nginx -R owncloud/


21. Buat direktori data untuk direktori ownCloud dan ubah permission nginx.
[root@localhost html]# mkdir -p owncloud/data/
[root@localhost html]# chown nginx:nginx -R owncloud/data/


22. Konfigurasi virtualhost untuk ownCloud. Pindah ke direktori /etc/nginx/conf.d/.
[root@localhost html]# cd /etc/nginx/conf.d/
[root@localhost conf.d]# vi owncloud.conf


23. Copy paste konfigurasi di bawah ini.
upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/var/run/php5-fpm.sock;
}

server {
        listen 80;
        server_name 192.168.100.161; # YourIP or domain
        return 301 https://192.168.100.161;  # redirect all to use ssl

}


server {
        listen 443 ssl;
        server_name 192.168.100.161; # YourIP or domain

        #SSL Certificate you created
        ssl on;
        ssl_certificate /etc/nginx/ssl/owncloud.crt;
        ssl_certificate_key /etc/nginx/ssl/owncloud.key;

        # owncloud path
        root /usr/share/nginx/html/owncloud/;

        client_max_body_size 10G; # set max upload size
        fastcgi_buffers 64 4K;

        rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
        rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
        rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

        index index.php;
        error_page 403 /core/templates/403.php;
        error_page 404 /core/templates/404.php;

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location ~ ^/(data|config|\.ht|db_structure\.xml|README) {

                deny all;
        }

        location / {
                # The following 2 rules are only needed with webfinger
                rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
                rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

                rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
                rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

                rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

                try_files $uri $uri/ index.php;
        }

        location ~ ^(.+?\.php)(/.*)?$ {
                try_files $1 = 404;

                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$1;
                fastcgi_param PATH_INFO $2;
                fastcgi_param HTTPS on;
                fastcgi_pass php-handler;
        }

        # Optional: set long EXPIRES header on static assets
        location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                expires 30d;
                # Optional: Don't log access to assets
                access_log off;
        }

}


24. Restart NGiNX, PHP-FPM, MariaDB dan aktifkan apabila mesin dinyalan sudah otomatis up.
[root@localhost conf.d]# systemctl restart nginx mariadb php-fpm
[root@localhost conf.d]# systemctl enable nginx mariadb php-fpm


25. Masuk ke browser, ketik di URL http://192.168.100.161 (Your-IP-Address) maka otomatis ngedirect ke https. Apabila muncul seperti seperti gambara di bawah ini di https, jangan khawatir, pilih I Understand the Risks kemudian pilih Add Exception.




26. Pilih Get Certificate dan Confirm Security Exception.



27. Makan muncul tampilan halaman ownCloud. Terlihat website ownCloud tersecure karena sudah di konfigurasi SSL Certificate.



28. Penjelasan detail seperti gambar di bawah ini.



29. Login dengan admin dengan memasukkan password root. Untuk database, pilih MySQL/MariaDB, masukkan data database sesuai yang sudah dibuat sebelumnya dan Data Folder pindahkan ke direktori data.



30.  Tampilan ownCloud setelah login.



- Membuat User

1. Untuk membuat user, klik sebelah kanan pilih admin, maka pilih bagian user. Masukkan nama beserta password.



2. Terlihat user telah terbuat dengan nama imanagus.



3. Kemudian log out, login dengan user yang telah dibuat.



- Testing Upload File

1. Secara default upload file di limitasi hanya bisa mengupload sebesar 513MB. Disini saya menggunakan admin untuk mengupload file.



2. Nah solusinya saya temukan, karena saya menggunakan PHP-FPM, ubah limitasi file menjadi 513MB menjadi 4GB.
[root@localhost ~]# vi /usr/share/nginx/html/owncloud/.user.ini 



3. Restart kembali NGiNX, PHP-FPM, MariaDB.
[root@localhost conf.d]# systemctl restart nginx mariadb php-fpm


4. Refresh di browser, terlihat max upload menjadi 4GB.



5. Disini saya akan coba upload file .ISO.



6. Tunggu proses hingga selesai, setelah selesai maka akan ada di tampilan folder.



- Testing Menggunakan Smartphone Android


1. Install ownCloud dahulu dari Google Play Store, kemudian masukkan IP Address Server pada URL, dan user yang sudah dibuat kemudian Connect.



2. Tampilan ownCloud di Android setelah login.



3. Buat file .txt buat testing, disini saya mulai dari browser.



4. Terlihat file gan.txt telah terbuat.



5. Cek apakah di android ada, terlihat ada file yang sudah dibuat melalui browser.



6. Nah disini saya balik, saya akan buat direktori dari Android. Pilih Create directory.



7. Masukkan nama, misal gan2.



8. Terlihat direktori sudah terbuat.



9. Cek di browser, terlihat direktori yang sudah dibuat di Android ada di browser.



Semoga Bermanfaat

Terima kasih


Wassalamu'alaikum.wr.wb.

Saturday, June 27, 2015

Ceph Cluster di CentOS 7

Assalamu'alaikum.wr.wb.

Hi all, ketemu lagi dengan saya Iman Agus Trianto. Disini saya akan posting materi Storage Server menggunakan OS CentOS 7. Setelah kemaren saya memposting materi Storage Server, yaitu GlusterFS, nah pada kali ini saya akan berganti dengan Ceph Cluster. Apa itu Ceph Cluster? Penasaran? Yuk langsung masuk materi.



A. Topologi



Tabel Addressing




B. Tujuan

  • Untuk mengetahui konsep Ceph Cluster
  • Untuk mengetahui cara bekerjanya Ceph Cluster
  • Untuk mengetahui cara konfigurasi Ceph Cluster di CentOS 7

C. Bahan

1. VirtualBox
2. GNS3
3. ISO CentOS-7-x86_64-DVD-1503-01
4. Koneksi Internet


D. Konsep Dasar

Ceph Storage Cluster adalah sebuah software yang berbasis opensource yang berfungsi sebagai storage server atau server penyimpanan seperti google drive. Ceph Storage Cluster terdiri dari dua jenis daemon yaitu Ceph OSD Daemon (OSD) berfungsi untuk menyimpan data sebagai objek pada server penyimpanan dan Ceph Monitor (MON) berfungsi untuk menjaga atau memonitoring data master pada server cluster. Dalam membuat ceph storage, minimal harus mempunyai satu Ceph Monitor (MON) untuk memonitoring dan dua Ceph OSD Daemon (OSD) untuk menyimpan data replikasi.

Dalam kasus ini, saya akan membuat satu Ceph Monitor (MON), satu Metadata Server (MDS), dan tiga Ceph OSD Daemon (OSD). Berikut masing-masing dari fungsi yang ada di ceph

1. MON berfungsi untuk memonitoring data pada cluster.

2. OSD berfungsi untuk menyimpan data sebagai objek pada server.

3. MDS berfungsi sebagai file system ceph.

Admin-Node berfungsi untuk menginstalasi ceph ke node1, node2, node3, dan client. Karena, jika kalian installasi satu persatu keyringnya akan berbeda dan ceph sendiri tidak akan saling sinkronisasi. Untuk OSD, menggunakan node1, node2 dan node3 dengan menggunakan hard disk tambahan ke masing-masing node. 

MON dan MDS hanya perlu diinstal pada node1. Untuk clientnya sendiri harus di upgrade kernelnya, karena ceph tidak support menggunakan kernel 2.x. Namun, karena disini saya menggunakan CentOS 7 kernel yang digunakan di CentOS 7 adalah 3.x. Jadi, sudah support ceph, namun apabila ingin update kernelnya kembali juga bisa.


E. Konfigurasi

A. Tahap Persiapan

1. Buat virtual hard disk di VirtualBox pada masing-masing node (node1, node2, node 3). Saya membuat dahulu pada node1. Klik Storage.



2. Pilih Controller: SATA, dan klik Add Hard Disk sebelah kanan gambar CD.


3. Pilih Create new disk.



4. Berikan nama hard disk dan size harddisk yang digunakan untuk harddisk baru, lalu Create. Masing-masing node saya berikan size 10 GB.



5. Terlihat virtual hard disk sudah terbuat untuk node1.



6. Lakukan cara yang sama untuk pembuatan hard disk untuk node2 dan node3.

Node 2.
Node 3.


7. Atur network pada masing-masing node (admin-node, node1, node2, node3) dan client, disini saya menggunakan subnet /24. Setelah di konfigurasi, restart network dan chkconfig agar network otomatis menyala pada saat saat mesin dinyalakan
[root@admin-node ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
[root@admin-node ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@admin-node ~]# chkconfig network on

[root@node1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
[root@node1 ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@node1 ~]# chkconfig network on

[root@node2 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
[root@node2 ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@node2 ~]# chkconfig network on

[root@node3 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
[root@node3 ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@node3 ~]# chkconfig network on

[root@client ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 
[root@client ~]# service network restart
Restarting network (via systemctl):                        [  OK  ]
[root@client ~]# chkconfig network on

Admin-Node.
Node 1.
Node 2. 
Node 3.
Client.


8. Matikan SELinux di masing-masing node (admin-node, node1, node2, node) dan client. Agar tidak di proteksi policy, biar bisa masuk ke sistem.
[root@admin-node ~]# vi /etc/sysconfig/selinux
[root@node1 ~]# vi /etc/sysconfig/selinux
[root@node2 ~]# vi /etc/sysconfig/selinux
[root@node3 ~]# vi /etc/sysconfig/selinux
[root@client ~]# vi /etc/sysconfig/selinux

Admin-Node.
Node 1.
Node 2. 
Node 3.
Client.


9. Hentikan sekaligus martikan beberapa layanan yang sedang aktif seperti, firewall, iptables di masing-masing server maupun client.
[root@admin-node ~]# setenforce 0
[root@admin-node ~]# systemctl stop firewalld 
[root@admin-node ~]# systemctl stop iptables
[root@admin-node ~]# systemctl stop ip6tables
[root@admin-node ~]# systemctl disable firewalld 
[root@admin-node ~]# systemctl disable ip6tables
[root@admin-node ~]# systemctl disable iptables

[root@node1 ~]# setenforce 0
[root@node1 ~]# systemctl stop firewalld 
[root@node1 ~]# systemctl stop iptables
[root@node1 ~]# systemctl stop ip6tables
[root@node1 ~]# systemctl disable firewalld 
[root@node1 ~]# systemctl disable ip6tables
[root@node1 ~]# systemctl disable iptables

[root@node2 ~]# setenforce 0
[root@node2 ~]# systemctl stop firewalld 
[root@node2 ~]# systemctl stop iptables
[root@node2 ~]# systemctl stop ip6tables
[root@node2 ~]# systemctl disable firewalld 
[root@node2 ~]# systemctl disable ip6tables
[root@node2 ~]# systemctl disable iptables

[root@node3 ~]# setenforce 0
[root@node3 ~]# systemctl stop firewalld 
[root@node3 ~]# systemctl stop iptables
[root@node3 ~]# systemctl stop ip6tables
[root@node3 ~]# systemctl disable firewalld 
[root@node3 ~]# systemctl disable ip6tables
[root@node3 ~]# systemctl disable iptables

[root@client ~]# setenforce 0
[root@client ~]# systemctl stop firewalld 
[root@client ~]# systemctl stop iptables
[root@client ~]# systemctl stop ip6tables
[root@client ~]# systemctl disable firewalld 
[root@client ~]# systemctl disable ip6tables
[root@client ~]# systemctl disable iptables


B. Konfigurasi Openssh-Clients  (Admin-Node)

1. Openssh-clients ini bertujuan agar ssh ke node lain, tidak diperlukan lagi password untuk login. Biasanya disebut ssh tanpa password, kalian bisa melihat video tutorial yang saya buat disini. Install openssh-clients di admin-node, karena secara default CentOS belum mempunyai fitur ssh-copy-id.
[root@admin-node ~]# yum install openssh-clients -y



2. Edit file hosts, tambahkan IP Address dari node 1 sampai client kemudian berikan nama pada IP tersebut. Fungsinya agar kalian tidak perlu lagi menggunakan IP Address tersebut, jadi menggunakan nama saja yang sudah diinisialisasikan.
[root@admin-node ~]# vi /etc/hosts



3. Masukkan perintah ssh-keygen untuk membuat rsa public key.
[root@admin-node ~]# ssh-keygen 



4. Masukkan perintah ssh-copy-id untuk menyimpan password dari server yang diremote.
[root@admin-node ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node1
[root@admin-node ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node2
[root@admin-node ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@node3
[root@admin-node ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@client 






B. Mendownload dan Menginstall EPEL Repository CentOS 7 beserta Ceph  (Admin-Node)

1. Download EPEL Repository untuk CentOS 7, masuk dahulu ke direktory /opt.
[root@admin-node opt]# wget -c http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm 



2. Keluar dari direktory opt, install beberapa packages untuk CentOS 7, hal ini diperlukan karena apabila install ceph di tidak mengalami error. Karena saya sendiri yang mengalaminya, solusinya install package dibawah ini.
[root@admin-node ~]# yum install -y net-tools snappy leveldb gdisk python-argparse gperftools-libs



3. Download Repository Ceph untuk CentOS 7.
[root@admin-node ~]# yum install -y net-tools snappy leveldb gdisk python-argparse gperftools-libs



4. Install Epel Repository dan Repo Ceph.
[root@admin-node opt]# rpm -ivh epel-release-7-5.noarch.rpm
[root@admin-node opt]# rpm -ivh ceph-release-1-0.el7.centos.noarch.rpm 



5. Sebelum instalasi ceph,  tambahkan priority=1 pada repositori ceph dan instal packages plugin-priorieties.
[root@admin-node opt]# sed -i -e "s/enabled=1/enabled=1\npriority=1/g" /etc/yum.repos.d/ceph.repo
[root@admin-node opt]# yum install yum-plugin-priorities -y



6. Install ceph pada Admin-Node.
[root@admin-node opt]# yum install ceph ceph-deploy -y



C. Membuat Ceph MON, Install Ceph Node 1-Node3, dan Membuat Admin-Keyring

1. Buat direktory untuk penyimpanan konfigurasi ceph. Ketika kalian melakukan perintah ceph-deploy, file konfigurasi ceph-deploy akan menyimpan file konfigurasi ke dalam direktory yang sedang dibuka. Misalnya kalian berada di /etc/ceph-cluster, otomatis jika kalian masuk ke /etc/ceph-cluster maka ceph-deploy akan menyimpan file konfigurasi pada /etc/ceph-deploy.
[root@admin-node ~]# mkdir /etc/ceph-cluster
[root@admin-node ~]# cd /etc/ceph-cluster/
[root@admin-node ceph-cluster]#



2. Membuat MON ke node 1.
ceph-deploy new (initial-monitor-node(s))
[root@admin-node ceph-cluster]# ceph-deploy new node1



3. Menginstal ceph ke node1 sampai node3. Untuk instalasi ceph, kita cukup membuka port ssh pada masing-masing node akan memudahkan kita untuk menginstal ceph. Tunggu proses hingga selesai.
[root@admin-node ceph-cluster]# ceph-deploy install admin-node node1 node2 node3




4. Membuat admin-keyring. Tunggu proses hingga selesai.
[root@admin-node ceph-cluster]# ceph-deploy mon create-initial




D. Memformat Hard Disk untuk Ceph OSD  (Node 1-Node3)

1. Buat partisi hard disk harus ke dalam type xfs dan labelnya harus gpt. Dalam memformat partisi saya menggunakan menggunakan parted, karena lebih mudah.
[root@node1 ~]# parted -s /dev/sdb mklabel gpt
[root@node1 ~]# parted -s /dev/sdb mkpart primary xfs 0% 100%
[root@node1 ~]# mkfs.xfs /dev/sdb1 -f



2. Buat direktori untuk mountingan partisi yang sudah diformat dan mounting partisi tersebut.
[root@node1 ~]# mkdir /ceph-OSD
[root@node1 ~]# mount -t xfs /dev/sdb1 /ceph-OSD/



3. Edit file fstab dan tambahkan script mounting otomatis partisi hard disk yang sudah dimounting. Berfungsi ketika kita restart server tersebut, langsung memounting otomatis partisi tersebut.
[root@node1 ~]# vi /etc/fstab
/dev/sdb1       /ceph-OSD       xfs    defaults  0       0



4. Cek hasil mountingan dengan perintah df -h.
[root@node1 ~]# df -h



5. Lakukan cara yang sama seperti node 1 untuk node 2 dan node 3 dalam hal memformat hard disk sekaligus memounting hard disk yang sudah di format. Kemudian cek hasil mountingan dengan perintah df -h pada node 2 dan node 3.
[root@node2 ~]# df -h
[root@node3 ~]# df -h

Node 2.
Node 3.


E. Membuat Ceph Object Storage atau OSD  (Admin-Node)

1. Buat OSD yang digunakan pada Ceph.
ceph-deploy osd prepare (ceph-node):/directory
[root@admin-node ceph-cluster]# ceph-deploy osd prepare node1:/ceph-OSD node2:/ceph-OSD node3:/ceph-OSD



2. Aktifkan node yang sudah dibuat.
ceph-deploy osd activate (ceph-node):/directory
[root@admin-node ceph-cluster]# ceph-deploy osd activate node1:/ceph-OSD node2:/ceph-OSD node3:/ceph-OSD



F. Mengcopy File Konfigurasi dan Key Ceph ke Node1 sampai Node 3 → (Admin-Node)

1. Mengcopy file konfigurasi Ceph dari admin-node ke node 1 sampai node 3.
ceph-deploy admin (admin-node) (ceph-node)
[root@admin-node ceph-cluster]# ceph-deploy admin admin-node node1 node2 node3



2. Memberikan hak akses read pada file ceph.client.admin.keyring.
[root@admin-node ceph-cluster]# chmod +r /etc/ceph-cluster/ceph.client.admin.keyring



G. Membuat Metadata Server ke Node 1 dan Cek Status Ceph → (Admin-Node)


1. Buat metadata server ke node 1. 
[root@admin-node ceph-cluster]# ceph-deploy mds create node1



2. Mengecek kesehatan Ceph yang berfungsi sebagai active+clean.
[root@admin-node ceph-cluster]# ceph-deploy mds create node1



3. Mengecek quorum status sebagai monitoring cluster.
[root@admin-node ceph-cluster]# ceph quorum_status --format=json-pretty




H. Mengecek Status di Ceph Node 1 sampai Node 3

1. Mengecek status OSD.
[root@node1 ~]# ceph osd stat
[root@node2 ~]# ceph osd stat
[root@node3 ~]# ceph osd stat

Node 1.
Node 2.
Node 3.


2. Mengecek service Ceph.
[root@node1 ~]# service ceph status
[root@node2 ~]# service ceph status
[root@node3 ~]# service ceph status

Node 1.
Node 2. 
Node 3.


3. Melihat OSD aktif atau tidak.
[root@node1 ~]# ceph osd tree
[root@node2 ~]# ceph osd tree
[root@node3 ~]# ceph osd tree

Node 1. 
Node 2.
Node 3.


4. Melihat kapasitas hard disk Ceph.
[root@node1 ~]# ceph df
[root@node2 ~]# ceph df
[root@node3 ~]# ceph df

Node 1.
Node 2.
Node 3.


I. Konfigurasi Client 

1. Instalasi Xen berfungsi agar Ceph lebih stabil karena dalam kasus ini, saya menggunakan virtualisasi bukan real device. Namun, untuk CentOS 7 Xen tidak tersedia dalam packages, Xen hanya tersedia di CentOS 6.x, kalian bisa lihat artikel yang saya temukan https://www.centos.org/forums/viewtopic.php?f=48&t=48074.

2. Bagi yang menggunakan CentOS 6.x, harus upgrade kernel terlebih dahulu karena ceph tidak support kernel 2.x. Ceph support kernel 3.x, dalam hal ini CentOS 7 sudah memakai kernel 3.x. Namun disini saya mengupdate kernel di CentOS 7, supaya lebih baru. Kalau tidak mengupdate pun tidak masalah.
[root@client ~]# yum update kernel -y




3. Cek kernel yang sudah di update pada client.
[root@client ~]# uname -a



J. Menginstall Ceph dan Menyalin Keyring ke Client → (Admin-Node)

1. Menginstall Ceph ke Client.
[root@admin-node ceph-cluster]# ceph-deploy install client




2. Menyalin file keyring ke client dari admin-node.
[root@admin-node ceph-cluster]# ceph-deploy install client



K. Membuat Block Device dari Client → (Client)

1. Buat disk baru dengan menggunakan rbd. Saya kasih size semua hard disk yang sebelumnya telah dibuat sebesar 10 GB.
[root@client ~]# rbd create disk --size 10240
[root@client ~]# rbd ls
[root@client ~]# rbd ls -1



2. Membuat mapping dari disk yang sudah dibuat.
[root@client ~]# rbd map disk
[root@client ~]# rbd showmapped



3. Memformat disk yang sudah dimapping.
[root@client ~]# mkfs.ext3 /dev/rbd0



4. Memounting partisi yang sudah di format. Buat direktori terlebih dahulu.
[root@client ~]# mkdir /ceph-client
[root@client ~]# mount -t ext3 /dev/rbd0 /ceph-client/
[root@client ~]# df -h



L. Membuat Ceph File System dan Uji Coba

1. Buat pool pada Ceph OSD.
ceph osd pool create (nama pool) (nomor) 
[root@client ~]# ceph osd pool create data 10
[root@client ~]# ceph osd pool create metadata 10



2. Buat file system Ceph dari pool yang sudah dibuat.
ceph fs new {nama ceph fs} ((pool) (pool))
[root@client ~]# ceph fs new fsdata metadata data



3. Lihat key dari file ceph.client.admin.keyring, Kemudian salin key tersebut.
[root@client ~]# more /etc/ceph/ceph.client.admin.keyring
key = AQC6MYpVbj6RKBAArq6hnA27lvwU1vgaDbQ4mg==



4. Memounting driver ceph.
mount -t ceph (IP Address MON):6789:/(Direktori untuk ceph) -o name=admin,secretfile=(key ceph.client.admin.keyring)
[root@client ~]# mkdir /mnt/cephfsclient
[root@client ~]# mount -t ceph 192.168.100.171:6789:/ /mnt/cephfsclient -o name=admin,secret=AQC6MYpVbj6RKBAArq6hnA27==



5. Menginstall package ceph-fuse.
[root@client ~]# yum install ceph-fuse -y




6. Memounting file system atau Ceph-Fuse. Buat dahulu direktory untuk memounting.
[root@client ~]# mkdir /mycephfs
[root@client ~]# ceph-fuse -m 192.168.100.171:6789 /mycephfs



7. Cek hasil mountingan dengan df -h.
[root@client ~]# df -h



8. Melakukan uji coba pada Ceph-Fuse file system. Disini saya akan membuat direktory untuk uji coba. Saya membuat dengan nama agan.
[root@client ~]# cd /mycephfs/
[root@client mycephfs]# ls
[root@client mycephfs]# mkdir agan
[root@client cephfsclient]# cd /mnt/cephfsclient/
[root@client cephfsclient]# ls



9. Setelah membuat direktory, disini saya akan uji coba membuat file. Isi file tersebut.
[root@client mycephfs]# touch gan.txt
[root@client mycephfs]# echo "testing bro" >> gan.txt



10. Lihat hasil pembuatan file dan isi file.
[root@client cephfsclient]# cd /mnt/cephfsclient/
[root@client cephfsclient]# ls
[root@client cephfsclient]# more gan.txt



M. Cek Hasil Mountingan Ceph File System → (Node 1-Node 3)

1. Melihat hasil mountingan Ceph file system node 1 sampai node 3.
[root@node1 ~]# ceph df
[root@node2 ~]# ceph df
[root@node3 ~]# ceph df

Node 1.
Node 2. 
Node 3.


Semoga Bermanfaat

Terima kasih

Wassalamu'alaikum.wr.wb.