摘要: http://my.oschina.net/baowenke/blog/97756 阅读全文
posted @ 2013-02-19 10:43 醇酒醉影 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 重命名集合> show collectionstianyc_test9> db.runCommand({'renameCollection':'Gps.tianyc_test9', 'to':'Gps.tianyc_test99'}){ "ok" : 1 }> show collectionstianyc_test99另:通过db.listCommands(),可以查看到所有mongo的命令。 阅读全文
posted @ 2013-02-06 16:20 醇酒醉影 阅读(1414) 评论(0) 推荐(0) 编辑
摘要: 使用集合 db.tianyc_test8 进行测试,该表建立在一个分片集群上,初始索引只有_id。> db.tianyc_test8.stats(){ "sharded" : true, "ns" : "Gps.tianyc_test8", "count" : 15960997, "numExtents" : 45, "size" : 7768445412, "storageSize" : 11004829696, "totalIndexS 阅读全文
posted @ 2013-02-05 11:26 醇酒醉影 阅读(2848) 评论(0) 推荐(0) 编辑
摘要: 可以通过包装来使用mongo的高级查询。$maxscan:integer 指定查询最多扫描的文档数量。$min:document 查询的开始条件$max:document 查询的结束条件$hint:document 指定服务器使用哪个索引进行查询。$explain:boolean 获取查询执行的细节,而并非真正执行查询。$snapshot:boolean 确保查询的结果是在查询执行那一刻的一致快照。例如 $explain:> db.tianyc05.find().limit(2).skip(1).sort({age:1}).explain(){ "cursor" : 阅读全文
posted @ 2013-02-04 15:25 醇酒醉影 阅读(1603) 评论(0) 推荐(0) 编辑
摘要: 使用游标。> db.tianyc05.find(){ "_id" : 1, "age" : 32, "name" : { "first" : "tian", "last" : "yc" }, "sex" : "m" }{ "_id" : 2, "age" : 27, "name" : { "first" : "tian&q 阅读全文
posted @ 2013-02-04 15:09 醇酒醉影 阅读(1743) 评论(0) 推荐(0) 编辑
摘要: 查询mongo的内嵌文档。> db.tianyc05.find(){ "_id" : 1, "name" : { "first" : "tian", "last" : "yc" } }{ "_id" : 2, "name" : { "first" : "tian", "last" : "yx" } }{ "_id" : 3, &qu 阅读全文
posted @ 2013-02-04 14:53 醇酒醉影 阅读(1978) 评论(0) 推荐(0) 编辑
摘要: 查询数组。此时你可能会使用到$all、$size。> db.tianyc04.find(){ "_id" : 1, "fruit" : [ "apple", "banana", "peach" ] }{ "_id" : 2, "fruit" : [ "apple", "orange", "peach" ] }{ "_id" : 3, "fruit" : 阅读全文
posted @ 2013-02-04 11:53 醇酒醉影 阅读(17838) 评论(0) 推荐(0) 编辑
摘要: mongo的find中,还可以使用正则表达式。> db.tianyc02.find({name:/xTtt/i}){ "_id" : ObjectId("50ea6eba12729d90ce6e3423"), "name" : "xttt", "age" : 111 }{ "_id" : ObjectId("50ea6eba12729d90ce6e3424"), "name" : "xttt", "a 阅读全文
posted @ 2013-02-04 11:41 醇酒醉影 阅读(5321) 评论(0) 推荐(0) 编辑
摘要: 关于null:若某列值为null,则设置条件null查询时,会返回该行文档,但同时还会返回不存在该列的文档。> db.tianyc02.find(){ "_id" : ObjectId("50ea6eba12729d90ce6e3423"), "name" : "xttt", "age" : 111 }{ "_id" : ObjectId("50ea6eba12729d90ce6e3424"), "name" : "xt 阅读全文
posted @ 2013-02-04 11:36 醇酒醉影 阅读(3609) 评论(0) 推荐(0) 编辑
摘要: mongo通find来查找文档。可以执行精确匹配和模糊匹配。2. 模糊匹配2.1比较> $gt , >= $gte, < $lt, <= $lte, != $ne> db.tianyc02.find(){ "_id" : ObjectId("50ea6eba12729d90ce6e3423"), "name" : "xttt", "age" : 111 }{ "_id" : ObjectId("50ea6eba12729d90ce6e3 阅读全文
posted @ 2013-02-04 11:28 醇酒醉影 阅读(51391) 评论(0) 推荐(1) 编辑
摘要: mongo通find来查找文档。可以执行精确匹配和模糊匹配。1. 精确匹配#查询全部> db.tianyc02.find(){ "_id" : ObjectId("50ea6eba12729d90ce6e3423"), "name" : "xttt", "age" : 111 }{ "_id" : ObjectId("50ea6eba12729d90ce6e3424"), "name" : "xttt", &q 阅读全文
posted @ 2013-02-04 11:07 醇酒醉影 阅读(6341) 评论(0) 推荐(1) 编辑
摘要: 1. upsert将update的第三个参数设置为true,存在则更新,不存在则插入。> db.tianyc03.find(){ "_id" : ObjectId("50ea6b6f12729d90ce6e341b"), "age" : 16, "companies" : [ "teletek" ], "name" : "xtt" }> db.tianyc03.update({count:20},{$inc:{count:3}}, true)& 阅读全文
posted @ 2013-02-04 10:44 醇酒醉影 阅读(7132) 评论(0) 推荐(0) 编辑
摘要: 除了查询条件,还可以使用修改器对文档进行更新。1. $inc> db.tianyc03.find(){ "_id" : ObjectId("50ea6b6f12729d90ce6e341b"), "name" : "xtt", "age" : 11 }> db.tianyc03.update({name:'xtt',age:11},{'$inc':{age:5}})> db.tianyc03.find(){ "_id" : O 阅读全文
posted @ 2013-02-04 09:31 醇酒醉影 阅读(15305) 评论(0) 推荐(0) 编辑
摘要: 可以根据条件来更新指定的文档,但要注意查询条件的唯一性:> db.tianyc04.remove()> db.tianyc04.insert({name:'tyc',age:20})> db.tianyc04.insert({name:'tyc',age:30})> db.tianyc04.insert({name:'tyc',age:32})> db.tianyc04.find(){ "_id" : ObjectId("510c83ad13d7e50c2281b048"), 阅读全文
posted @ 2013-02-02 11:32 醇酒醉影 阅读(4582) 评论(0) 推荐(0) 编辑
摘要: mongo-日期类型(1)当通过mongo shell来插入日期类型数据时,使用new Date()和使用Date()是不一样的:> db.tianyc04.insert({mark:1, mark_time:new Date()})> db.tianyc04.insert({mark:2, mark_time:Date()})> db.tianyc04.find(){ "_id" : ObjectId("5126e00939899c4cf3805f9b"), "mark" : 1, "mark_time& 阅读全文
posted @ 2013-02-02 10:36 醇酒醉影 阅读(50459) 评论(3) 推荐(2) 编辑
摘要: > db.tianyc04.insert({mark:1, mark_time:new Date()})> db.tianyc04.insert({mark:1, mark_time:Date()})> db.tianyc04.find(){ "_id" : ObjectId("510c714c045d7d8d7b6ec1bb"), "mark" : 1, "mark_time" : ISODate("2013-02-02T01:52:12.281Z") }{ "_i 阅读全文
posted @ 2013-02-02 09:53 醇酒醉影 阅读(323) 评论(0) 推荐(0) 编辑
摘要: mongo提供了help功能,可以帮助我查看一些命令。下面是示例:> help db.help() help on db methods db.mycoll.help() help on collection methods rs.help() help on replica set methods help connect connecting to a db help help admin ... 阅读全文
posted @ 2013-02-01 16:50 醇酒醉影 阅读(1696) 评论(1) 推荐(0) 编辑
摘要: 1. 新建数据库命名的大小写数据库的命令应使用小写字母,但大写字母也是支持的,例如 TYC。不过此时不能再添加 tyc 数据库了,会提示错误:> use TYCswitched to db TYC> show collections> show dbsGps 73.8720703125GBTYC (empty)admin (empty)config 0.0625GBtest 0.078125GB> db.tianyc.t1.insert({name:'x'})> show collectionssystem.indexestianyc.t1> 阅读全文
posted @ 2013-02-01 16:14 醇酒醉影 阅读(1620) 评论(0) 推荐(0) 编辑
摘要: 组织集合的一种惯例是使用“.”字符分开的按命名空间划分的子集合。例如,一个带有博客功能的应用可能包含2个集合,分别是blog.posts和blog.authors。这样做的目的只是为了使得组织结构更清晰,便于管理,也就是说blog集合和这两个集合之间没有任何关系。在mongoDB中使用子集合来组织数据是个很好的方法,在此强烈推荐。 阅读全文
posted @ 2013-02-01 16:05 醇酒醉影 阅读(440) 评论(0) 推荐(0) 编辑
摘要: 1. 下载jythonhttp://www.jython.org/2. 安装$java -jar jython-2.5.3.jar3. 配置.bash_profile中增加classpathCLASSPATH=/home/tianyc/tools/jython-2.5.3.jarexport CLASSPATH.bashrc中增加aliasalias jython='java -jar /home/tianyc/tools/jython-2.5.3.jar'4. 使用[tianyc@TeletekHbase ~]$ jythonJython 2.5.3 (2.5:c56500f 阅读全文
posted @ 2013-01-29 17:31 醇酒醉影 阅读(746) 评论(0) 推荐(0) 编辑
摘要: 业务开发测试HBase之旅一:HTable基本概念http://www.taobaotest.com/blogs/qa?bid=13850业务开发测试HBase之旅二:通过HBase Shell与HBase交互http://www.taobaotest.com/blogs/qa?bid=13871业务开发测试HBase之旅三:通过Java Api与HBase交互http://www.taobaotest.com/blogs/qa?bid=13894业务开发测试HBase之旅四:HBase MapReduce实例分析http://www.taobaotest.com/blogs/qa?bid=1 阅读全文
posted @ 2013-01-29 11:21 醇酒醉影 阅读(292) 评论(0) 推荐(0) 编辑
摘要: 修改linux的时间可以使用date指令修改日期:时间设定成2009年5月10日的命令如下:#date -s 05/10/2009修改时间:将系统时间设定成上午10点18分0秒的命令如下。#date -s 10:18:00 阅读全文
posted @ 2013-01-25 16:49 醇酒醉影 阅读(168) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/sundongsdu/article/details/8101287启动后,通过jps命令查看各个节点的服务启动情况,当发现有服务没启动时,需要查看对应的log。例如:1. namenode没启动,查看日志,发现配置完毕后,启动前需要首先格式化namenode2. s2无法连通localhost,需要将主机名写入/etc/hosts文件中。但不可对应到127.0.0.1,而是对应到主机ip。例如:[root@TeletekTest logs]# cat /etc/hosts127.0.0.1 localhost localhost.localdom.. 阅读全文
posted @ 2013-01-25 15:01 醇酒醉影 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 一、单向ssh-keygen -t rsa单向无密码访问远程服务器操作比较简单,比如服务器A需要无密码访问服务器B(A–>B),那么只需要在服务器A生成密钥对,将生成的公钥上传到服务器B的相关用户目录下的.ssh目录中(没有的话手动创建,注意,它的目录权限是700),并将公钥文件名称改为authorized_keys(注意,这个文件的权限应该是644),请注意.ssh目录及authorized_keys文件的权限,权限不符,会使配置无效。二、双向将本机的id_rsa.pub文件中的内容加到对方的authorized_keys文件中即可。三、遇到的问题有时候按步骤设置好了,ssh时仍然提示 阅读全文
posted @ 2013-01-25 14:22 醇酒醉影 阅读(3398) 评论(0) 推荐(0) 编辑
摘要: http://lesca.me/archives/iptables-tutorial-structures-configuratios-examples.html 阅读全文
posted @ 2013-01-25 14:02 醇酒醉影 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1. 在主机1和主机2上安装jdk(提示的错误可以忽略),并设置JAVA_HOME。两台主机步骤设置相同。[root@TeletekTest tianyc]# pwd/home/tianyc[root@TeletekTest tianyc]# ll总用量 218000-rw-r--r--. 1 tianyc NEU 62793050 12月 17 15:38 hadoop-1.0.4.tar.gz-rw-r--r--. 1 tianyc NEU 48611465 12月 17 15:28 hbase-0.94.3.tar.gz-rw-r--r--. 1 tianyc NEU 1118083.. 阅读全文
posted @ 2013-01-22 17:33 醇酒醉影 阅读(204) 评论(0) 推荐(0) 编辑
摘要: MR是一种线性可伸缩的编程模型。MR适合以批处理的方式处理需要分析的整个数据集的问题,尤其是即席分析。RDBMS适用于点查询和更新。MR适合一次写入,多次读取数据的应用;而RDBMS更适合持续更新的数据集。MR对于非结构化或半结构化的数据非常有效,因为在处理数据时才对数据进行解释。换句话说:MR输入的键和值并不是数据固有的属性,而是由分析数据的人员来选择的。web服务器日志是一个典型的非规范化数据记录(例如,每次都需要记录客户端主机全名,导致同一客户端全名可能多次出现),这也是MR非常适合于分析各种日志文件的原因之一。 阅读全文
posted @ 2013-01-21 17:35 醇酒醉影 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 在mongo2.2.2版本中,mongodump的collections文件,会同步生成一个metadata.json文件。这与之前的版本不同。目前查看到的该json文件中只包含了索引信息。该信息在mongorestore时会使用到,恢复完毕数据后,会创建索引。但该json文件中不包含分片信息,所以如果恢复集群中的表,还是需要先建好分片表,然后再执行mongorestore(执行时不要用drop参数)。C:\>mongodump -h 192.168.69.205 --port 1234 -d testDB -c test_tianyc01 -o D:\tianyuechaoconnec 阅读全文
posted @ 2013-01-09 15:30 醇酒醉影 阅读(1456) 评论(0) 推荐(0) 编辑
摘要: 升级步骤1. 关闭balancer登陆mongos,执行sh.stopBalancer(),或者连接到mongos>use config>db.settings.update( { _id: "balancer" }, { $set : { stopped: true } } , true );关闭balancer后,需检查是否还有migretion:If a migration is in progress, the system will complete the in-progress migration. After disabling, you can 阅读全文
posted @ 2013-01-09 14:25 醇酒醉影 阅读(1332) 评论(0) 推荐(0) 编辑
摘要: 1. I get some errors when setup JDK, these can be ignored.[root@localhost tools]# rpm -ivh jdk-7u10-linux-i586.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%]Unpacking JAR files... rt.jar...Error: Could not open input file: 阅读全文
posted @ 2013-01-09 11:46 醇酒醉影 阅读(2327) 评论(0) 推荐(1) 编辑
摘要: 连接上需要关闭的副本集,使用db.shutdownServer()命令正常关闭mongod服务。对于1个仲裁、3个副本集的mongo集群,连续关闭两个secondry后,剩下的primary会自动变成secondry。 阅读全文
posted @ 2012-12-10 09:58 醇酒醉影 阅读(1570) 评论(0) 推荐(0) 编辑
摘要: 1.3.4以上版本,可以使用logRotate命令将日志文件进行切换。不过在Windows平台,需要2.0.3以上版本才行。D:\>mongo 127.0.0.1:1234MongoDB shell version: 1.8.3connecting to: 127.0.0.1:1234/test> use adminswitched to db admin> db.runCommand("logRotate"){ "ok" : 1 }>D:\mongodb208\db1>dir驱动器 D 中的卷是 D卷的序列号是 CEF6- 阅读全文
posted @ 2012-12-10 09:51 醇酒醉影 阅读(1626) 评论(0) 推荐(0) 编辑
摘要: 1. 当前状态C:\>mongo 127.0.0.1:2222MongoDB shell version: 1.8.3connecting to: 127.0.0.1:2222/testneu:PRIMARY> rs.conf(){ "_id" : "neu", "version" : 3, "members" : [ { "_id" : 0, "host" : "ZJNO9LZF6G8LBPS:1111" }, { "_id&quo 阅读全文
posted @ 2012-12-08 10:45 醇酒醉影 阅读(5417) 评论(0) 推荐(0) 编辑
摘要: # 插入数据db.testgeo.insert({loc:[0 ,10]})db.testgeo.insert({loc:[1 ,10]})db.testgeo.insert({loc:[2 ,10]})db.testgeo.insert({loc:[3 ,10]})db.testgeo.insert({loc:[4 ,10]})db.testgeo.insert({loc:[5 ,10]})db.testgeo.insert({loc:[6 ,10]})db.testgeo.insert({loc:[7 ,10]})db.testgeo.insert({loc:[8 ,10]})db.tes 阅读全文
posted @ 2012-11-30 16:51 醇酒醉影 阅读(373) 评论(0) 推荐(0) 编辑
摘要: Create Or Replace Trigger "TRIGER"Before Insert On <table_name> Referencing Old As Old New As New For Each RowBeginSelect SEQ.Nextval Into :new.ID From DUAL;End; 阅读全文
posted @ 2012-11-09 08:51 醇酒醉影 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 使用python连接到本地的sqlserver数据库时,需要将服务“属性”中的“安全性”设置为“SQL Server和windows身份验证模式”使用sa登录,提示该账户被禁用:>>> pyodbc.connect("DRIVER={SQL Server};SERVER=XP-201210161011;DATABASE=test;UID=sa;PWD=sa")Traceback (most recent call last): File "<stdin>", line 1, in <module>pyodbc.P 阅读全文
posted @ 2012-11-02 17:21 醇酒醉影 阅读(2086) 评论(0) 推荐(0) 编辑
摘要: mongo-日期类型(2)mongo中的日期类型,使用ISO格式,例如:ISODate("2012-11-02T07:58:51.718Z")。下面来测试一下:C:\>mongo 127.0.0.1:2222/testMongoDB shell version: 1.8.3connecting to: 127.0.0.1:2222/testtype "help" for helpneu:PRIMARY> db.t2.insert({mydate:ISODate("2012-11-02T07:58:51.718Z")})ne 阅读全文
posted @ 2012-11-02 16:28 醇酒醉影 阅读(24255) 评论(0) 推荐(2) 编辑
摘要: 一、中文字符的查询在windows的cmd命令中,查询mongo数据时,中文会出现乱码:C:\>mongo 127.0.0.1:2222/testMongoDB shell version: 1.8.3connecting to: 127.0.0.1:2222/testneu:PRIMARY> show collectionssystem.indexest1yctshardneu:PRIMARY> db.t1.find(){ "_id" : ObjectId("50937174e513bab18cd6d3cb"), "name 阅读全文
posted @ 2012-11-02 15:56 醇酒醉影 阅读(9512) 评论(0) 推荐(0) 编辑
摘要: json越来越流行,通过python获取到json格式的字符串后,可以通过eval函数转换成dict格式:>>> a='{"name":"yct","age":10}'>>> eval(a){'age': 10, 'name': 'yct'}支持字符串和数字,其余格式的好像不支持:>>> a='{"name":"yct","age":10," 阅读全文
posted @ 2012-11-01 17:02 醇酒醉影 阅读(50914) 评论(2) 推荐(0) 编辑
摘要: --logpath指定日志的输出路径。 如果对文件夹有读写权限,系统会在文件不存在时创建它。它会将已有文件覆盖掉,清除所有原来的日志记录。例如:D:\mongodb>mongod --dbpath=d:\mongodb\db --port 2222 --replSet neu/127.0.0.1:3333 --shardsvr --logpath=d:\mongodb\db\x.logall output going to: d:\mongodb\db\x.log此时会创建或清空x.log文件,将本次实例启动后的日志信息写入x.log文件中。如果想要保留原来的日志,需使用--logapp 阅读全文
posted @ 2012-10-31 17:01 醇酒醉影 阅读(2323) 评论(0) 推荐(0) 编辑