完成PostgreSQL与SDB的对接。要求如下:
1.完成PostgreSQL的部署安装;
2.完成与SDB的对接;
3.从PG创建外表映射到SDB集合,验证对接是否成功;
PostgreSQL的部署安装
为安装程序添加权限
cd /home/ysx/sequoiadb-3.4
chmod u+x sequoiasql-postgresql-3.4-x86_64-installer.run
运行安装程序
./sequoiasql-postgresql-3.4-x86_64-installer.run
创建PGSQL实例
/opt/sequoiasql/postgresql/bin/sdb_sql_ctl addinst myinst -D database/5432/
查看实例列表
/opt/sequoiasql/postgresql/bin/sdb_sql_ctl listinst
开启实例进程
/opt/sequoiasql/postgresql/bin/sdb_sql_ctl start myinst
查看实例状态
/opt/sequoiasql/postgresql/bin/sdb_sql_ctl status
创建SDB-PGSQL的database
cd /opt/sequoiasql/postgresql
bin/sdb_sql_ctl createdb test myinst
进入到SDB-PGSQL Shell环境
bin/psql -p 5432 test
PostgreSQL与SDB的对接
加载SequoiaDB连接驱动
CREATE EXTENSION sdb_fdw;
配置与SequoiaDB连接参数
CREATE SERVER sdb_server FOREIGN DATA WRAPPER sdb_fdw
OPTIONS
(
address 'ysx:11810,ysx1:11810,ysx2:11810',
service '11810',
user 'sdbadmin',
password '1234',
preferedinstance 'A'
);
关联SequoiaDB的集合空间以及集合
CREATE FOREIGN TABLE employee
(
empno int,
ename VARCHAR(64),
age int
)
SERVER sdb_server
OPTIONS ( collectionspace 'company', collection 'employee', decimal 'on' );
从PG创建外表映射到SDB集合,验证对接是否成功
//新增
insert into employee(empno,ename,age) values(1,'A',11);
insert into employee(empno,ename,age) values(2,'B',22);
//删除
delete from employee where empno =1;
//查找
select * from employee where empno=2;
//更新:
update employee set ename='Jacky' where empno=2;
select * from employee where empno=2;
进入到SDB Shell中查看结果验证对接成功:
var db=new Sdb()
db.company.employee.find()