Jumat, 17 Februari 2012

REPLIKASI

Alat Praktikum :
    2 PC, dijadikan 1 PC slave dan 1 PC server
    Kabel LAN


Tujuan :
    Mengamankan database dengan cara PC slave meniru sistem database PC server, agar jika ada satu sistem yang 'down' maka sistem yang lainnya dapat meng-handle (backup) database tersebut.


Langkah-kerja :
    Mengkoneksikan antara PC server dengan PC slave:
        a. PC server :
            cek kabel : masuk ke root #mii-tool
            jika kabelnya konek, maka keluar :
            eth0: negotiated 100baseTx-FD flow-control, link ok
set ip : ifconfig eth0 192.168.1.1

        b. PC slave  :
            cek kabel : masuk ke root #mii-tool
            jika kabelnya konek, maka keluar :
            eth0: negotiated 100baseTx-FD flow-control, link ok

set ip : ifconfig eth0 192.168.1.2
       
        cek koneksi dari PC server ke PC slave atau sebaliknya:
        #ping ifconfig eth0 192.168.1.1   //ini ping dari PC slave ke PC server


        jika berhasil :
        root@scb:/home/rhane# ping 192.168.1.1

        PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.

        64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=0.117 ms

        64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=0.137 ms

        64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=0.178 ms

        64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=0.103 ms

        64 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=0.156 ms

        64 bytes from 192.168.1.1: icmp_req=6 ttl=64 time=0.145 ms

        ^C


    Edit MySQL (PC Slave)
        #gedit /etc/mysql/my.cnf         //konfigurasi MySQL
   

    Restart MySQL dengan menggunakan perintah : # /etc/init.d/mysql restart

        hasilnya :
        root@scb:/home/rhane# /etc/init.d/mysql restart

        Rather than invoking init scripts through /etc/init.d, use the service(8)

        utility, e.g. service mysql restart

        Since the script you are attempting to invoke has been converted to an

        Upstart job, you may also use the stop(8) and then start(8) utilities,

        e.g. stop mysql ; start mysql. The restart(8) utility is also available.

        mysql stop/waiting

        mysql start/running, process 2067


    Keluar dari root@scb : root@scb:/home/rhane# exit
        exit
        hasilnya menjadi : rhane@scb:~$


    Masuk ke MySQL :
        rhane@scb:~$ mysql -u root -p

            Enter password:

        Welcome to the MySQL monitor.  Commands end with ; or \g.

        Your MySQL connection id is 52

        Server version: 5.1.54-1ubuntu4-log (Ubuntu)

        Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

        This software comes with ABSOLUTELY NO WARRANTY. This is free software,

        and you are welcome to modify and redistribute it under the GPL v2 license

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


    menghentikan slave : mysql> stop slave ;

Query OK, 0 rows affected (0.00 sec)


    konfigurasi slave :
        mysql> change master to master_host='192.168.1.1', master_user='slave_user',  master_password='slave_password', master_log_file='mysql-bin.000055', master_log_pos=225;

    Query OK, 0 rows affected (0.52 sec)


    memulai slave :
        mysql> start slave;

Query OK, 0 rows affected (0.00 sec)

    melihat status slave :
mysql> show slave status \G;

*************************** 1. row ***************************

               Slave_IO_State: Waiting for master to send event

                  Master_Host: 192.168.1.1

                  Master_User: slave_user

                  Master_Port: 3306

                Connect_Retry: 60

              Master_Log_File: mysql-bin.000055

          Read_Master_Log_Pos: 225

               Relay_Log_File: scb-relay-bin.000002

                Relay_Log_Pos: 251

        Relay_Master_Log_File: mysql-bin.000055

             Slave_IO_Running: Yes

            Slave_SQL_Running: Yes

              Replicate_Do_DB: tugas_sister_replikasi

          Replicate_Ignore_DB:

           Replicate_Do_Table:

       Replicate_Ignore_Table:

      Replicate_Wild_Do_Table:

  Replicate_Wild_Ignore_Table:

                   Last_Errno: 0

                   Last_Error:

                 Skip_Counter: 0

          Exec_Master_Log_Pos: 225

              Relay_Log_Space: 408

              Until_Condition: None

               Until_Log_File:

                Until_Log_Pos: 0

           Master_SSL_Allowed: No

           Master_SSL_CA_File:

           Master_SSL_CA_Path:

              Master_SSL_Cert:

            Master_SSL_Cipher:

               Master_SSL_Key:

        Seconds_Behind_Master: 0

    Master_SSL_Verify_Server_Cert: No

                Last_IO_Errno: 0

                Last_IO_Error:

               Last_SQL_Errno: 0

               Last_SQL_Error:

    1 row in set (0.00 sec)



    ERROR:

    No query specified
                                       



    membuat databasenya :
        mysql> create database tugas_sister_replikasi;

        Query OK, 1 row affected (0.30 sec)


    merestart mysql :
        root@scb:/home/rhane# /etc/init.d/mysql restart

        Rather than invoking init scripts through /etc/init.d, use the service(8)

        utility, e.g. service mysql restart

        Since the script you are attempting to invoke has been converted to an

        Upstart job, you may also use the stop(8) and then start(8) utilities,

        e.g. stop mysql ; start mysql. The restart(8) utility is also available.

        mysql stop/waiting

        mysql start/running, process 221   



    masuk kembali ke mysql :
root@scb:/home/rhane# mysql -u root -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 53

Server version: 5.1.54-1ubuntu4-log (Ubuntu)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

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



    Start slave :
mysql> start slave;

Query OK, 0 rows affected, 1 warning (0.00 sec)

    Memakai data base yang sebelumnya dibuat di Server:
mysql> use tugas_sister_replikasi;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A



Database changed

mysql> show tables;

+----------------------------------+

| Tables_in_tugas_sister_replikasi |

+----------------------------------+

| coba                             |

| test                             |

+----------------------------------+

2 rows in set (0.00 sec)




    selesai

0 komentar:

Posting Komentar