sequoiadb四颗牙P 第七节 参考

7090阅读 0评论2020-04-28 brjl
分类:数据库开发技术


JSON 实例应用
1)创建域 company_domain ,在域下创建集合空间 company , 在集合空间下创建集合 employee ;


sdb


var db = new Sdb("localhost", 11810);
db.createDomain("company_domain", [ "group1", "group2", "group3" ], { AutoSplit: true } );
db.createCS("company", { Domain: "company_domain" } );
db.company.createCL("employee", { "ShardingKey": { "_id": 1}, "ShardingType": "hash", "ReplSize": -1, "Compressed": true, "CompressionType": "lzw", "AutoSplit": true, "EnsureShardingIndex": false });
 
2)给创建的 employee 集合插入下面 6 条数据;
db.company.employee.insert( { "empno": 10001, "ename": "Georgi", "age": 48 } );
db.company.employee.insert( { "empno": 10002, "ename": "Bezalel", "age": 21 } );
db.company.employee.insert( { "empno": 10003, "ename": "Parto", "age": 33 } );
db.company.employee.insert( { "empno": 10004, "ename": "Chirstian", "age": 40 } );
db.company.employee.insert( { "empno": 10005, "ename": "Kyoichi", "age": 23 } );
db.company.employee.insert( { "empno": 10006, "ename": "Anneke", "age": 19 } );


3)连接查询集合 employee 中age 大于20,小于30的数据;
db.company.employee.find( { "age": { "$gt": 20, "$lt": 30 } } );


4)将集合 employee 中 empno 为 10001 的记录的 age 更改为34;
db.company.employee.update( { "$set": { "age": 34 } }, { "empno": 10001 } );


5)删除集合 employee 中 empno 为 10006 的记录删除;
db.company.employee.remove( { "empno": 10006 } );


db.company.employee.find( {}, { "empno": "" } );


SequoiaFS 实例应用
1) 创建 fs_domain 域使用,在此域下创建集合空间 fscs,在此集合空间下创建集合 fscl ;
sdb
var db = new Sdb("localhost", 11810);
db.createDomain("fs_domain", [ "group1", "group2", "group3" ], { AutoSplit: true } );
db.createCS("fscs", { Domain: "fs_domain" } );
db.fscs.createCL("fscl", { "ShardingKey": { "_id": 1}, "ShardingType": "hash", "ReplSize": -1, "Compressed": true, "CompressionType": "lzw", "AutoSplit": true, "EnsureShardingIndex": false } );


2)创建挂载点目录" /opt/sequoiadb/sequoiafs/mountpoint ";
mkdir -p /opt/sequoiadb/sequoiafs/mountpoint


3) 创建 SequoiaFS 的配置文件夹" /opt/sequoiadb/sequoiafs/conf/fscs_fscl/001/ "和日志目录" /opt/sequoiadb/sequoiafs/log/fscs_fscl/001/ " ;
mkdir -p /opt/sequoiadb/sequoiafs/conf/fscs_fscl/001/
mkdir -p /opt/sequoiadb/sequoiafs/log/fscs_fscl/001/


4) 生成一个空的配置文件,SequoiaFS 服务在启动时会将指定的值写入该文件中,其他参数使用缺省值" /opt/sequoiadb/sequoiafs/conf/fscs_fscl/001/sequoiafs.conf " ;
touch /opt/sequoiadb/sequoiafs/conf/fscs_fscl/001/sequoiafs.conf


5)启动 SequoiaFS 服务,挂载上面创建的目录(可参考学习章节 “启动 SequoiaFS 服务” 相关内容 );
sequoiafs /opt/sequoiadb/sequoiafs/mountpoint -i localhost:11810 -l fscs.fscl --autocreate -c /opt/sequoiadb/sequoiafs/conf/fscs_fscl/001/ --diagpath  /opt/sequoiadb/sequoiafs/log/fscs_fscl/001/ -o big_writes -o max_write=131072 -o max_read=131072


6) 在 mount 目录下创建子目录 fsdir ,且在这个目录下创建文件 fsfile.txt 向文件 fsfile.txt 写入 " hello, this is a fsfile ! ";
mount 
cd  /opt/sequoiadb/sequoiafs/mountpoint 
mkdir fsdir
cd fsdir
echo  " hello, this is a fsfile ! ">fsfile.txt


7) 在数据库检查是否将文件夹中的文件挂载上去 ;


S3 对象存储部署
1)开启 RC 级别事务为读已提交,且配置为等锁模式;
sdb
var db = new Sdb("localhost", 11810);
db.updateConf( { transactionon: true, transisolation: 1, translockwait: true } );


2)创建元数据逻辑域;
db.createDomain("metaDomain", [ "group1", "group2", "group3" ], { AutoSplit: true} );
3)创建对象数据逻辑域;
db.createDomain("dataDomain", [ "group1", "group2", "group3" ], { AutoSplit: true} );
4)配置启动 SequoiaS3 实例;


cd /opt/sequoiadb/tools/sequoias3
echo 'server.port=8002' >> config/application.properties
echo 'sdbs3.sequoiadb.url=sequoiadb://localhost:11810' >> config/application.properties
echo 'sdbs3.sequoiadb.meta.domain=metaDomain' >> config/application.properties
echo 'sdbs3.sequoiadb.data.domain=dataDomain' >> config/application.properties
/opt/sequoiadb/tools/sequoias3/sequoias3.sh start


sdb
var db = new Sdb("localhost", 11810);
db.list(SDB_SNAP_COLLECTIONS);


5)创建桶 exambucket;
curl -v -X PUT "http://localhost:8002/exambucket" -H "Host: localhost:8002" -H "Authorization: AWS ABCDEFGHIJKLMNOPQRST:abcdefghijklmnopqrstuvwxyz0123456789ABCD"  
curl -v -X GET "http://localhost:8002" -H "Host: localhost:8002" -H "Authorization: AWS ABCDEFGHIJKLMNOPQRST:abcdefghijklmnopqrstuvwxyz0123456789ABCD" 


6)向 exambucket 中写入文件"/opt/sequoiadb/version.conf",命名为"version.conf";
curl -X PUT -T "/opt/sequoiadb/version.conf" "http://localhost:8002/exambucket/version.conf" -H "Host: localhost:8002" -H "Authorization: AWS ABCDEFGHIJKLMNOPQRST:abcdefghijklmnopqrstuvwxyz0123456789ABCD"  -H "Content-Type: text/plain"


7)从桶 exambucket 中下载文件对象 "version.conf" 保存为 /home/sdbadmin/version.conf ;
cd 
curl -o version.conf -X GET "http://localhost:8002/exambucket/version.conf" -H "Host: localhost:8002" -H "Authorization: AWS ABCDEFGHIJKLMNOPQRST:abcdefghijklmnopqrstuvwxyz0123456789ABCD"  -H "Content-Type: text/plain" 








上一篇:sequoiadb 四颗牙经典代码段 创建域、索引、看执行计划
下一篇:WARNING: too many parse errors PARSE ERROR: ospid=XXX error=12872 for statement