Cara menggunakan port mysql 0

Untuk dapat mencoba melakukan replikasi master to master mysql ini, harap siapkan (minimal) 2 server mysql siap pakai, misalnya dengan IP 10. 2. 9. 1 dan 10. 2. 9. 2

MySQL Master untuk Menguasai Langkah Replikasi

1. Sesuaikan konfigurasi masing-masing server MySQL sebagai master. Ubah di setiap file /etc/my. cnf
Untuk master server 1 misalnya

[mysqld]
port=3306
datadir=/home/mysql/
socket=/usr/local/mysql/tmp/mysql.sock
user=mysql
old_passwords=0
#symbolic-links=0
#query_cache_size = 268435456
query_cache_size = 256M
query_cache_type=1
query_cache_limit = 1048576
log = 1
long_query_time = 1
slow_query_log	= 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
general_log	= 1
general_log_file =	/var/log/mysqld.log
server_id           = 1
log_bin             = /var/log/mysql/mysql-bin.log
log_bin_index       = /var/log/mysql/mysql-bin.log.index
relay_log           = /var/log/mysql/mysql-relay-bin
relay_log_index     = /var/log/mysql/mysql-relay-bin.index
expire_logs_days    = 10
max_binlog_size     = 100M
log_slave_updates   = 1
bind-address = 0.0.0.0
local-infile = 0

sedangkan untuk master server 2

[mysqld]
port=3306
datadir=/home/mysql
socket=/usr/local/mysql/tmp/mysql.sock
user=mysql
old_passwords=0
#symbolic-links=0
query_cache_size = 268435456
query_cache_type=1
query_cache_limit=1048576
log = 1
long_query_time = 1
slow_query_log	= 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
general_log	= 1
general_log_file =	/var/log/mysqld.log
server_id           = 2
log_bin             = /var/log/mysql/mysql-bin.log
log_bin_index       = /var/log/mysql/mysql-bin.log.index
relay_log           = /var/log/mysql/mysql-relay-bin
relay_log_index     = /var/log/mysql/mysql-relay-bin.index
expire_logs_days    = 10
max_binlog_size     = 100M
log_slave_updates   = 1
bind-address = 0.0.0.0
local-infile = 0
_

2. Instal replikasi ke setiap server, login ke server1 sebagai root
a. buat 3 pengguna untuk replikasi ini. mysqlchkuser, mmm_monitor, mmm_agent, dan replikasi
b. Berikan mmm_monitor sebagai replikasi klien
c. Berikan mmm_agent sebagai super dan replikasi klien
d. Berikan replikasi sebagai budak
e. hak siram mysql
f. flush juga baca lock mysql
g. periksa status master mysql
deskripsi langkah-langkah di atas dalam perintah dan respons di konsol sebagai berikut

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.5.12-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement
mysql> create user 'mysqlchkuser'@'localhost' identified by 'mysql321';
Query OK, 0 rows affected (0.06 sec)
mysql> create user 'mmm_monitor'@'%' identified by 'monitor_password';
Query OK, 0 rows affected (0.06 sec)
mysql> create user 'mmm_agent'@'%' identified by 'agent_password';
Query OK, 0 rows affected (0.00 sec)
mysql> create user 'replication'@'%' identified by 'replication_password';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'monitor_password';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY 'agent_password';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%' IDENTIFIED BY 'replication_password';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> flush tables with read lock;
Query OK, 0 rows affected (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |     1044 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

h. Dump database master server 1 ke master server 2 dengan mysqldump

mysqldump -u root -p --all-databases > /tmp/database-backup.sql

i. Transfer file backup ke master server 2 dengan scp,

scp /tmp/database-backup.sql 10.2.9.2:~/
_

j. Buka kunci tabel di master 1
3. Login ke master server 2 sebagai root di mysql
a. siram hak istimewa yang tersedia
b. ubah master mysql dengan master_host = '10. 2. 9. 1' (atau sesuai dengan IP server master Anda 1) diikuti oleh port (biasanya 3306), pengguna master (dalam hal ini 'replikasi'), kata sandi pengguna, dan file log mastering

mysql> flush privileges;
Query OK, 0 rows affected (0.46 sec)
mysql> CHANGE MASTER TO master_host='10.2.9.1', master_port=3306, master_user='replication', -> master_password='replication_password', master_log_file='mysql-bin.000001', master_log_pos=1044;

c. jalankan slave di server master 2 dan periksa status slave

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status \G run command
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.2.9.1
                  Master_User: replication
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000001
          Read_Master_Log_Pos: 1044
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 253
        Relay_Master_Log_File: mysql-bin.000001
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          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: 1044
              Relay_Log_Space: 409
              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:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
1 row in set (0.00 sec)
_

d. memeriksa status master

mysql> show master status -> ;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 27957968 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 27957968 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

4. Kembali ke server master 1 dan pengaturan master
a. Ganti mysql master dengan master host sesuai IP master server 2, sesuaikan port, user, password dan log file

mysql> CHANGE MASTER TO master_host='10.2.9.2', master_port=3306, master_user='replication', -> master_password='replication_password', master_log_file='mysql-bin.000002', master_log_pos=27957968;
Query OK, 0 rows affected (0.34 sec)
_

b. jalankan budak dan periksa statusnya

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G run command
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.2.9.1
                  Master_User: replication
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000002
          Read_Master_Log_Pos: 27957968
               Relay_Log_File: mysql-relay-bin.000002
                Relay_Log_Pos: 253
        Relay_Master_Log_File: mysql-bin.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          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: 27957968
              Relay_Log_Space: 409
              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:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2
1 row in set (0.00 sec)
_

5. Percobaan replikasi
a. Di server master konsol 1, silakan lihat daftar basis data
b. Cobalah untuk membuat database baru

[mysqld]
port=3306
datadir=/home/mysql
socket=/usr/local/mysql/tmp/mysql.sock
user=mysql
old_passwords=0
#symbolic-links=0
query_cache_size = 268435456
query_cache_type=1
query_cache_limit=1048576
log = 1
long_query_time = 1
slow_query_log	= 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
general_log	= 1
general_log_file =	/var/log/mysqld.log
server_id           = 2
log_bin             = /var/log/mysql/mysql-bin.log
log_bin_index       = /var/log/mysql/mysql-bin.log.index
relay_log           = /var/log/mysql/mysql-relay-bin
relay_log_index     = /var/log/mysql/mysql-relay-bin.index
expire_logs_days    = 10
max_binlog_size     = 100M
log_slave_updates   = 1
bind-address = 0.0.0.0
local-infile = 0
_0

c. Coba periksa di master server 2, database sampel replikasi otomatis juga harus dibuat

[mysqld]
port=3306
datadir=/home/mysql
socket=/usr/local/mysql/tmp/mysql.sock
user=mysql
old_passwords=0
#symbolic-links=0
query_cache_size = 268435456
query_cache_type=1
query_cache_limit=1048576
log = 1
long_query_time = 1
slow_query_log	= 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
general_log	= 1
general_log_file =	/var/log/mysqld.log
server_id           = 2
log_bin             = /var/log/mysql/mysql-bin.log
log_bin_index       = /var/log/mysql/mysql-bin.log.index
relay_log           = /var/log/mysql/mysql-relay-bin
relay_log_index     = /var/log/mysql/mysql-relay-bin.index
expire_logs_days    = 10
max_binlog_size     = 100M
log_slave_updates   = 1
bind-address = 0.0.0.0
local-infile = 0
_1

Banyak. Selamat mencoba dan nikmati master MySQL untuk menguasai replikasi data
Referensi
1. ibu. web. id (http. // ibu. web. id/pemrograman/database/mysql/2012/replikasi-master-ke-master-mysql/)
2. MySQL-mmm. org (http. //mysql-mmm. org/mmm2. panduan)
3. Linux. web. id (http. //alinux. web. id/2011/08/16/replikasi-master-ke-master-mysql. html)

Apa port default MySQL?

Umumnya server Apache menggunakan port default 80, sedangkan untuk MySQL server menggunakan port default 3306. Agar masalah dapat diselesaikan dan Anda dapat menggunakan XAMPP, Anda perlu mengubah port default XAMPP.

Berapa banyak port localhost?

80 adalah port dari URL Localhost anda, silahkan ganti dengan port yang sesuai dengan aplikasi atau website anda di Localhost. Setelah menjalankan perintah, informasi berikut akan muncul.

Langkah-langkah menjalankan program database MySQL?

MySQL Membuat Database dan Tabel .
Buka command prompt dengan menekan ctrl + R lalu ketik cmd dan enter
Buka MySQL dengan mengetikkan cd AppServ\MySQL\bin\MySQL
Saat diminta password, masukkan password yang anda buat (namun biasanya password defaultnya adalah “root”)

Bagaimana cara memulai layanan MySQL?

Klik menu Mulai > Panel Kontrol > Sistem dan Keamanan > Alat Administratif dan dari jendela yang terbuka, klik dua kali Layanan. Untuk mulai menjalankan layanan Windows dari MySQL, klik kanan pada MySQL dan pilih Mulai pada menu pop-up yang muncul .