
หลังจากได้เตรียม server สำหรับ MySQL replication ด้วยการทำให้ข้อมูลของทั้งสองเครื่องเหมือนกันเรียบร้อยแล้ว ก็มาถึงขั้นตอนการ setup replication ซึ่งขั้นตอนนี้จะต้องรันคำสั่ง “show master status” เพื่อตรวจสอบ bin-log และ position ที่เครื่อง master เพื่อนำข้อมูลที่ได้ไปใช้กับคำสั่ง CHANGE MASTER TO ที่เครื่อง slave แต่เมื่อรันคำสั่ง “show master status” ที่เครื่อง master แล้วกลับพบว่าได้ผลลัพธ์ “Empty set (0.00 sec)” มาแทนที่จะได้ข้อมูล bin-log และ position และเมื่อไปตรวจสอบที่ไฟล์ error log ของ MySQL กลับไม่มีข้อมูลอะไรเลย ต่อมาจึงลองใช้คำสั่ง “show binary logs” เพื่อตรวจสอบข้อมูลของ binary log ก็พบข้อความว่า “ERROR 1381 (HY000): You are not using binary logging” ซึ่งทำให้รู้ว่าน่าจะเกิดปัญหาจากการสร้าง binary log ไฟล์
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 117905 Server version: 5.5.14-log MySQL Community Server (GPL) 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> show master status; Empty set (0.00 sec) mysql> show binary logs; ERROR 1381 (HY000): You are not using binary logging
วิธีแกัไขสามารถทำได้ดังนี้
ให้ตรวจสอบก่อนว่าใน /etc/my.cnf ได้มีค่า log-bin นี้แล้วหรือยัง ถ้ายังไม่มีให้ใส่ตามตัวอย่างด้านล่างได้ดังนี้
log-bin = /var/lib/mysql/log-bin
แต่ถ้ามีแล้วก็แสดงว่าเป็นปัญหาที่ permission ของ directory ที่ใช้เก็บ bin-log ไฟล์ วิธีแก้ไขคือให้ owner และ group ของ directory นี้เป็น mysql โดยสามารถทำตามตัวอย่างด้านล่างได้ดังนี้
[root@ezylinux ~]# service mysql stop [root@ezylinux ~]# chown -R mysql:mysql /path/of/bin-log [root@ezylinux ~]# service mysql start
Related posts:
- How to update the max_connections in MySQL ปัญหาการเกิด error “too many connections” ในขณะที่ query database...
- ติดตั้ง MySQL Cluster ในบทความนี้จะใช้เครื่องจำนวน 4 เครื่อง โดยแต่ละเครื่องจะมีหน้าที่ storages node จำนวน 2...
- Show line numbers in vi/vim editor. ในบางครั้งเราต้องการที่จะค้นหาข้อความที่อยู่ในบรรทัดใดบรรทัดหนึ่งของไฟล์ที่ต้องการแก้ไข ซึ่งครั้งหนึ่งผมก็เคยต้องการค้นหาว่าบรรทัดที่เกิด error ตามที่ Log แสดงออกมานั้นมีข้อมูลอะไรอยู่ ซึ่งตอนแรกๆก็ไม่ได้ค้นหาวิธีว่ามันทำอย่างไรให้แสดงเลขบรรทัดออกมา ช่วงนั้นก็อาศัยความถึกเข้าสู้ด้วยการนับบรรทัดเอา...
- How to Remove LILO, GRUB or Master Boot Record from system โดยทั่วไป Hard disk จะมีการเก็บ binary code ของ system...
- How to set a crontab to run command on the last day of every month. เป็นที่ทราบกันดีว่าใน crontab ของ linux มีแค่การกำหนด เวลา วัน เดือน...


November 12th, 2011
Tum.
Posted in
Tags: 