YMatrix 文档
集群部署
SQL参考
- ABORT
- ALTER_DATABASE
- ALTER_EXTENSION
- ALTER_EXTERNAL_TABLE
- ALTER_FOREIGN_DATA_WRAPPER
- ALTER_FOREIGN_TABLE
- ALTER_FUNCTION
- ALTER_INDEX
- ALTER_RESOURCE_GROUP
- ALTER_RESOURCE_QUEUE
- ALTER_ROLE
- ALTER_RULE
- ALTER_SCHEMA
- ALTER_SEQUENCE
- ALTER_SERVER
- ALTER_TABLE
- ALTER_TABLESPACE
- ALTER_TYPE
- ALTER_USER_MAPPING
- ALTER_VIEW
- ANALYZE
- BEGIN
- CHECKPOINT
- COMMIT
- COPY
- CREATE_DATABASE
- CREATE_EXTENSION
- CREATE_EXTERNAL_TABLE
- CREATE_FOREIGN_DATA_WRAPPER
- CREATE_FOREIGN_TABLE
- CREATE_FUNCTION
- CREATE_INDEX
- CREATE_RESOURCE_GROUP
- CREATE_RESOURCE_QUEUE
- CREATE_ROLE
- CREATE_RULE
- CREATE_SCHEMA
- CREATE_SEQUENCE
- CREATE_SERVER
- CREATE_TABLE
- CREATE_TABLE_AS
- CREATE_TABLESPACE
- CREATE_TYPE
- CREATE_USER_MAPPING
- CREATE_VIEW
- DELETE
- DROP_DATABASE
- DROP_EXTENSION
- DROP_EXTERNAL_TABLE
- DROP_FOREIGN_DATA_WRAPPER
- DROP_FOREIGN_TABLE
- DROP_FUNCTION
- DROP_INDEX
- DROP_RESOURCE_GROUP
- DROP_RESOURCE_QUEUE
- DROP_ROLE
- DROP_RULE
- DROP_SCHEMA
- DROP_SEQUENCE
- DROP_SERVER
- DROP_TABLE
- DROP_TABLESPACE
- DROP_TYPE
- DROP_USER_MAPPING
- DROP_VIEW
- END
- EXPLAIN
- GRANT
- INSERT
- LOAD
- LOCK
- REINDEX
- RELEASE_SAVEPOINT
- RESET
- REVOKE
- ROLLBACK_TO_SAVEPOINT
- ROLLBACK
- SAVEPOINT
- SELECT INTO
- SET ROLE
- SET TRANSACTION
- SET
- SHOW
- START TRANSACTION
- TRUNCATE
- UPDATE
- VACUUM
工具指南
PXF访问SQL Server
本示例演示如何使用PXF连接SQLServer2016
1. PXF安装
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
2. 配置
初始化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
3. 启动并查看集群状态
启动节点:
pxf cluster start
查看集群状态:
pxf cluster status
4. 访问
创建插件:
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;