카테고리 없음2017. 12. 27. 14:06


MariaDB replication 구성을 하고 운영하던 중 binary log 파일이 계속 쌓여 

파일 시스템이 차게 되었다. 

binary log 를 지우는 방법과 위치를 변경하는 방법을 알아보자. 


●  bin log 삭제 


mysql c;lient 에서 명령어로 지울수 있다. 


mysql -u root -proot123


MariaDB [(none)]> show binary logs;

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

| Log_name           | File_size |

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

| mariadb-bin.000001 |       353 |

| mariadb-bin.000002 |       330 |

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

2 rows in set (0.00 sec)


MariaDB [(none)]> purge master logs to 'mariadb-bin.000002';

Query OK, 0 rows affected (0.01 sec)


MariaDB [(none)]> show binary logs;

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

| Log_name           | File_size |

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

| mariadb-bin.000002 |       330 |

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

1 row in set (0.00 sec)


mariadb-bin.000002 이전까지의 로그들을 삭제한다. 




● MariaDB bin log 위치 변경


1. 설정 변경 ( my.cnf)


-  service mysqld stop


- vi /etc/my.cnf  아래 내용 추가

---------------------------------------------

log_bin=/DATA/binlog/mariadb-bin     ## /DATA/binlog 까지가 경로

 ##  mariadb-bin  는 포맷

binlog_cache_size = 2M

max_binlog_size = 50M

expire_logs_days = 10

---------------------------------------------


2. 폴더 생성 


 cd /DATA

 mkdir binlog


 touch mariadb-bin.index


3. DB 재기동 


[mysql@oracdb binlog]$ service mysqld start

Starting mysqld (via systemctl):  ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===

Authentication is required to manage system services or units.

Authenticating as: root

Password: 

==== AUTHENTICATION COMPLETE ===

[  OK  ]

 

[mysql@oracdb binlog]$ cd /DATA/binlog

[mysql@oracdb binlog]$ ls -l

total 8

-rw-rw----. 1 mysql mysql 330 Dec 26 15:49 mariadb-bin.000001

-rw-rw-r--. 1 mysql mysql  34 Dec 26 15:49 mariadb-bin.index

 


4. Replication  재설정 


@master 


[mysql@oracdb binlog]$ ifconfig

ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 10.10.10.48  netmask 255.255.255.0  broadcast 10.10.10.255

        inet6 fe80::250:56ff:fe01:147  prefixlen 64  scopeid 0x20<link>

        ether 00:50:56:01:01:47  txqueuelen 1000  (Ethernet)

        RX packets 18041  bytes 1460721 (1.3 MiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 13598  bytes 1529832 (1.4 MiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

 

MariaDB [(none)]> show master status;

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

| File               | Position | Binlog_Do_DB | Binlog_Ignore_DB |

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

| mariadb-bin.000002 |      330 |              |                  |

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



@slave


stop slave;



CHANGE MASTER TO MASTER_HOST='10.10.10.48',

MASTER_USER = 'replicant',

MASTER_PASSWORD = 'replicant',

MASTER_PORT=3306,

MASTER_LOG_FILE = 'mariadb-bin.000002',

MASTER_LOG_POS = 330;

 

START SLAVE;

 


5. 서비스 확인 


MariaDB [(none)]> use mysql

Database changed

MariaDB [mysql]> SELECT variable_value

    -> FROM information_schema.global_status

    -> WHERE variable_name='SLAVE_RUNNING';

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

| variable_value |

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

| ON             |

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

1 row in set (0.01 sec)


MariaDB [mysql]> 




끗. 공감구걸



반응형
Posted by 돌고래트레이너