cluster : 여러 시스템이나 자원이 연결되어 하나의 시스템으로 동작되는 것.
분산되어 구축이 될 경우 시스템 장애 발생시 빠른 대처가 가능.
smb --> 동기화
비동기식 --> DB의 복제가 아닌 로그정보를 볼 때 DBMS에 전달된 쿼리문의 확인이 가능. 이 쿼리문을 백업 DB가 실행.
---> master slave방식.
장점 : 부하가 적음
단점 : 연결이 끊길 수 있으며 완전히 동일한 데이터라는 보장이 없음. Slave DB는 백업에만 사용하기에 서버 활용성이 떨어짐. 불필요한 조회 쿼리를 실행.
Replication --> DB복제를 의미
방식 : 1. Master/Slave 2. Master/Master 3. Master/다중 Slave
서버 고유 넘버를 지정하여 이 고유넘버를 서로 인식하여 작동.
실시간데이터 백업이 가능.
DB 서버 부하분산이 가능.
단. Master는 주로 삽입/삭제/수정, Slave는조회.
show variables like 'general_log%
general_log : 모든 로그, ErrodrLog
서비스 재시작시 OFF상태가 됨.
general_log의 경우 너무 많은 로그가 쌓이게 되므로 용량 문제가 발생 가능.
-->
정보를 전부 백업 로그서버에 보내서 처리.
고정적으로 활성화 시키기 위한 방법
mysql-bin : binary타입 log를 생성.
vim /etc/my.con.d/server.cnf
general_log = on
general_log_file = /var/log/mariadb/general.log
log-bin = /var/log/mariadb/mariadb-bin
# -> binary type log 생성
server-id = 1
binlog_format = low
expire_logs_days = 2
# --> 보관기간
grant replication slave on *.* to "slave_db"@"%" identified by "asd123!@";
show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 342 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
vim /etc/my.con.d/client.cnf
[mariadb]
log-bin = mysql-bin
server-id = 2
binlog_format = row
expire_logs_days = 2
change master to
master_host = "172.16.20.6",
master_user = "slave_db",
master_password = "asd123!@",
master_port = 3306,
master_log_file = "mysql-bin.000003",
master_log_pos = 342;
start slave;
MariaDB [(none)]> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.20.6
Master_User: slave_db
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 117144
Relay_Log_File: mariadb-relay-bin.000016
Relay_Log_Pos: 555
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: cacti
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: 117144
Relay_Log_Space: 866
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
Master_SSL_Crl:
Master_SSL_Crlpath:
Using_Gtid: No
Gtid_IO_Pos:
Replicate_Do_Domain_Ids:
Replicate_Ignore_Domain_Ids:
Parallel_Mode: conservative
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Slave_DDL_Groups: 1
Slave_Non_Transactional_Groups: 0
Slave_Transactional_Groups: 141
1 row in set (0.000 sec)
특정 테이블/db 백업 무시 설정
#/etc/my.cnf.d/client.cnf
replicate-ignore-table=cacti.settings
replicate-ignore-db=cacti
'네트워크 및 서버 > 서버' 카테고리의 다른 글
DNSSec (0) | 2024.12.10 |
---|---|
SSH 인증서 로그인 (0) | 2024.12.10 |
Web Server 로드밸런싱 구현 (2) (0) | 2024.12.03 |
Web Server 로드밸런싱 (0) | 2024.12.02 |
Clamav / Amavis (0) | 2024.11.25 |