400-800-0824
info@ymatrix.cn
400-800-0824
info@ymatrix.cn
400-800-0824
info@ymatrix.cn
400-800-0824
info@ymatrix.cn
400-800-0824
info@ymatrix.cn
YMatrix 文档
集群部署
SQL参考
工具指南
本示例演示如何使用PXF连接SQLServer2016
sudo yum install pxf-matrixdb3-5.16.1-1.el7.x86_64.rpm -y
sudo mkdir /usr/local/pxfconf
sudo chown mxadmin.mxadmin -R /usr/local/pxfconf
sudo chown mxadmin.mxadmin -R /usr/local/pxf-matrixdb3
export PXF_HOME=/usr/local/pxf-matrixdb3
export PXF_CONF=/usr/local/pxfconf
export PATH=$PXF_HOME/bin:$PATH
cd $PXF_CONF/servers
mkdir sqlserv_server
初始化PXF:
pxf cluster init
从https://docs.microsoft.com/en-us/sql/connect/jdbc/using-the-jdbc-driver?view=sql-server-ver15 下载jdbc驱动: sqljdbc4.jar 将驱动放入pxf库目录(所有节点都需要):
cp sqljdbc4.jar $PXF_CONF/lib
同步配置到其它节点:
pxf cluster sync
启动节点:
pxf cluster start
查看集群状态:
pxf cluster status
创建插件:
postgres=# create extension pxf_fdw ;
CREATE EXTENSION
定义SERVER:
DROP SERVER sqlserv_server cascade;
CREATE SERVER sqlserv_server FOREIGN DATA WRAPPER jdbc_pxf_fdw OPTIONS (
jdbc_driver 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
db_url 'jdbc:sqlserver://{ip}:{端口};databaseName={数据库名}',
batch_size '10000',
fetch_size '2000'
);
创建用户映射:
CREATE USER MAPPING FOR mxadmin SERVER sqlserv_server OPTIONS ( user '{用户名}' , pass '{密码}');
创建外部表:
CREATE FOREIGN TABLE foreign_sqlserver (
id int4 ,
banzu varchar(20) ,
banzu_name varchar(50) ,
realdate timestamp
)
SERVER sqlserv_server
OPTIONS (resource '{源数据库schema.表名}');
通过外部表访问SQL Server数据:
select * from foreign_sqlserver limit 10;