MySQL

[MySQL] FEDERATED (DBLINK)

bbugge 2020. 7. 24. 11:24

// MySQL의 DBLINK 는 FEDERATED.

// db 설치전 –with-federated-storage-engine 옵션을 주어 설치해서 사용할 수도 있지만, mysql 명령어로 engine을 설치하여 사용할 수 있음.

 

mysql > install plugin federated soname 'ha_federated.so'

$ vi /etc/my.cnf

// mysqld에 federated 추가

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# 바이너리 로그 설정
log-bin=/var/log/mariadb/mysql-bin

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

performance_schema=on
federated

 

$ systemctl restart mysqld

 

MariaDB [(none)]> show engines;
+--------------------+---------+--------------+------+------------+
| Engine             | Support | Transactions | XA   | Savepoints |
+--------------------+---------+--------------+------+------------+
| MRG_MyISAM         | YES     | NO           | NO   | NO         |
| CSV                | YES     | NO           | NO   | NO         |
| MEMORY             | YES     | NO           | NO   | NO         |
| MyISAM             | YES     | NO           | NO   | NO         |
| Aria               | YES     | NO           | NO   | NO         |
| InnoDB             | DEFAULT | YES          | YES  | YES        |
| FEDERATED          | YES     | NO           | NO   | NO         |
| SEQUENCE           | YES     | YES          | NO   | YES        |
| PERFORMANCE_SCHEMA | YES     | NO           | NO   | NO         |
+--------------------+---------+--------------+------+------------+

 

ENGINE=FEDERATED DEFAULT CHARSET=UTF8 CONNECTION='mysql://user_id:user_pw@192.168.0.1:3306/db_name/tbl_name';

 

 

// federated engine을 사용하면 해당 테이블의 프레임만 저장이 되고 데이터는 connection 통해서 CRUD 일어남.

// log는 서버 별로 따로 쓰여짐.