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 "" -h "host: localhost:8002" -h "authorization: aws abcdefghijklmnopqrst:abcdefghijklmnopqrstuvwxyz0123456789abcd"
curl -v -x get "" -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" "/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 "/version.conf" -h "host: localhost:8002" -h "authorization: aws abcdefghijklmnopqrst:abcdefghijklmnopqrstuvwxyz0123456789abcd" -h "content-type: text/plain"
阅读(9498) | 评论(0) | 转发(1) |