MariaDB 에서 원격 서버 FEDERATED 로 linked server 처럼 연결하기 > 개발

본문 바로가기
사이트 내 전체검색

개발

MariaDB 에서 원격 서버 FEDERATED 로 linked server 처럼 연결하기

페이지 정보

profile_image
작성자 관리자 (119.♡.119.69)
댓글 0건 조회 87회 작성일 23-04-19 20:44

본문

## Installing the Plugin

Although the plugin's shared library is distributed with MariaDB by default, the plugin is not actually installed by MariaDB by default. There are two methods that can be used to install the plugin with MariaDB.

The first method can be used to install the plugin without restarting the server. You can install the plugin dynamically by executing INSTALL SONAME or INSTALL PLUGIN. For example:
```
INSTALL SONAME 'ha_federatedx';
```

## Uninstalling the Plugin

You can uninstall the plugin dynamically by executing UNINSTALL SONAME or UNINSTALL PLUGIN. For example:
```
UNINSTALL SONAME 'ha_federatedx';
```

## How do you use FederatedX?

To use this handler, it's very simple. You must have two databases running, either both on the same host, or on different hosts.

First, on the foreign database you create a table, for example:
```
CREATE TABLE test_table (
  id    int(20) NOT NULL auto_increment,
  name  varchar(32) NOT NULL default '',
  other  int(20) NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY name (name),
  KEY other_key (other))
DEFAULT CHARSET=latin1;
```
Then, on the server that will be connecting to the foreign host (client), you create a federated table without specifying the table structure:
```
CREATE TABLE test_table ENGINE=FEDERATED
  CONNECTION='mysql://root@127.0.0.1:9306/federatedx/test_federatedx';
```
Notice the "ENGINE" and "CONNECTION" fields? This is where you respectively set the engine type, "FEDERATED" and foreign host information, this being the database your 'client' database will connect to and use as the "data file". Obviously, the foreign database is running on port 9306, so you want to start up your other database so that it is indeed on port 9306, and your FederatedX database on a port other than that. In my setup, I use port 5554 for FederatedX, and port 5555 for the foreign database.

Alternatively (or if you're using MariaDB before version 10.0.2) you specify the federated table structure explicitly:
```
CREATE TABLE test_table (
  id    int(20) NOT NULL auto_increment,
  name  varchar(32) NOT NULL default '',
  other  int(20) NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY name (name),
  KEY other_key (other))
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:9306/federatedx/test_federatedx';
```
In this case the table structure must match exactly the table on the foreign server.



## 참고

## FederatedX 에 대해서

https://mariadb.com/kb/en/about-federatedx/
https://runebook.dev/ko/docs/mariadb/about-federatedx/index

## FederatedX vs Federated 차이

https://mariadb.com/kb/en/differences-between-federatedx-and-federated/



## troubleshooting

Windows 용 서버에서 아래와 같은 오류가 발생시, so 를 빼고 시도해 본다.
```
mysql> install soname 'ha_federated.so';
```
```
localhost: 오류
SQL 오류 (1126): Can't open shared library 'C:\Program Files\MariaDB 10.3\lib\plugin\ha_federated.so.dll' (errno: 0, The specified module could not be found.)
```



## 참고

https://sarc.io/index.php/mariadb/1167-mariadb-federated
https://stricky.tistory.com/325

추천0

댓글목록

등록된 댓글이 없습니다.

Total 384건 1 페이지
  • RSS
개발 목록
번호 제목 조회 추천 날짜
3846006-06
38392004-23
38289004-20
열람중88004-19
380126004-12
379134004-11
378100004-11
377113004-10
376109004-10
375146003-22
374204003-15
373182003-09
372163012-05
371188010-02
370211009-08
369254009-07
368215008-19
367196008-18
366285008-11
365350008-10

검색


사이트 정보

Copyright © Baragi.Net. All rights reserved.