">

Foreign Data Wrapper Kurulumu Mssql den Postgresql'e Geçiş

Foreign Data Wrapper Kurulumu Mssql den Postgresql'e Geçiş

Merhaba Arkadaşlar,

Postgresql veri tabanımıza fdw kurulumu yapacağız mssql veri tabanına erişim sağlamak için. postgresql veritabanımızın sürümü 12 işletim sistemimizin sürümü ise cenot 7.

Aşağıdaki adımları sırası ile yapalım.

  • yum install gcc
  • yum install epel-release

yukardaki olmaz ise:

wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm

Yada:

sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E '%{rhel}').noarch.rpm

rpm -ivh epel-release-7-11.noarch.rpm

  • yum install freetds
  • yum install freetds-devel
  • yum install postgresql12-devel
  • yum install postgresql12-contrib
  • yum install centos-release-scl

yada:

http://mirror.centos.org/centos/6.10/extras/x86_64/Packages/ adresinden aşağıdaki paketleri yükleriz.

centos-release-scl-7-4.el6.centos.noarch.rpm

centos-release-scl-rh-2-4.el6.centos.noarch.rpm

  • yum install llvm-toolset-7
  • yum install devtoolset-7

Aşağıdaki dizine gidilir.

cd /home/eng

sudo mkdir ms_fdw

cd ms_fdw

Bu dizinde iken aşağıdaki komutlar çalıştırılarak tds_fdw dosyası indirilir.

  • wget https://github.com/GeoffMontee/tds_fdw/archive/master.zip
  • unzip master.zip
  • cd tds_fdw-master/
  • sudo mkdir -p /usr/lib64/llvm5.0sudo mkdir -p /usr/lib64/llvm5.0/bin
  • cd /usr/lib64/llvm5.0/bin
  • sudo ln -s /opt/rh/llvm-toolset-7/root/usr/bin/llvm-lto
  • sudo PATH=/usr/pgsql-12/bin:$PATH make USE_PGXS=1

Çıktısı:

gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/tds_fdw.o src/tds_fdw.c

gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/options.o src/options.c

gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -c -o src/deparse.o src/deparse.c

gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -shared -o tds_fdw.so src/tds_fdw.o src/options.o src/deparse.o -L/usr/pgsql-12/lib -Wl,--as-needed -L/usr/lib64/llvm5.0/lib -L/usr/lib64 -Wl,--as-needed -Wl,-rpath,'/usr/pgsql-12/lib',--enable-new-dtags -lsybdb

cp sql/tds_fdw.sql sql/tds_fdw--2.0.1.sql

cp README.md README.tds_fdw.md

/opt/rh/llvm-toolset-7/root/usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o src/tds_fdw.bc src/tds_fdw.c

5

/opt/rh/llvm-toolset-7/root/usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o src/options.bc src/options.c

/opt/rh/llvm-toolset-7/root/usr/bin/clang -Wno-ignored-attributes -fno-strict-aliasing -fwrapv -O2 -I./include/ -fvisibility=hidden -I. -I./ -I/usr/pgsql-12/include/server -I/usr/pgsql-12/include/internal -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include -flto=thin -emit-llvm -c -o src/deparse.bc src/deparse.c

  • sudo PATH=/usr/pgsql-12/bin:$PATH make USE_PGXS=1 install

Çıktısı:

/bin/mkdir -p '/usr/pgsql-12/lib'

/bin/mkdir -p '/usr/pgsql-12/share/extension'

/bin/mkdir -p '/usr/pgsql-12/share/extension'

/bin/mkdir -p '/usr/pgsql-12/doc/extension'

/bin/install -c -m 755 tds_fdw.so '/usr/pgsql-12/lib/tds_fdw.so'

/bin/install -c -m 644 .//tds_fdw.control '/usr/pgsql-12/share/extension/'

/bin/install -c -m 644 .//sql/tds_fdw--2.0.1.sql '/usr/pgsql-12/share/extension/'

/bin/install -c -m 644 .//README.tds_fdw.md '/usr/pgsql-12/doc/extension/'

/bin/mkdir -p '/usr/pgsql-12/lib/bitcode/tds_fdw'

/bin/mkdir -p '/usr/pgsql-12/lib/bitcode'/tds_fdw/src/

/bin/install -c -m 644 src/tds_fdw.bc '/usr/pgsql-12/lib/bitcode'/tds_fdw/src/

/bin/install -c -m 644 src/options.bc '/usr/pgsql-12/lib/bitcode'/tds_fdw/src/

/bin/install -c -m 644 src/deparse.bc '/usr/pgsql-12/lib/bitcode'/tds_fdw/src/

cd '/usr/pgsql-12/lib/bitcode' && /usr/lib64/llvm5.0/bin/llvm-lto -thinlto -thinlto-action=thinlink -o tds_fdw.index.bc tds_fdw/src/tds_fdw.bc tds_fdw/src/options.bc tds_fdw/src/deparse.bc

  • su - postgres
  • psql

create extension tds_fdw;

CREATE SERVER ms FOREIGN DATA WRAPPER tds_fdw OPTIONS(servername 'IP_ADRES',database 'mssql_database_name',port '1433);

CREATE USER MAPPING FOR nuxeo SERVER ms OPTIONS (username 'mssql_kullanıcı', password 'aaa*');

create schema ms_fdw;

IMPORT FOREIGN SCHEMA dbo FROM SERVER ms INTO ms_fdw;

Bu aşamada Artık MSSQL veri tabanındaki tüm verileri postgresql veri tabanında ms_fdw şemasında görünmektedir.

 

Umarım Faydalı olmuştur.

 

Yorumlar

Henüz yorum yapılmadı.

Yorum Yapın