首页 文章 精选 留言 我的

精选列表

搜索[小程序·云开发],共10036篇文章
优秀的个人博客,低调大师

MongoDB学习笔记(三)--权限 && 导出导入备份恢复 && fsync和锁

权限 绑定内网IP访问MongoDB服务 在启动的时候带上 –bind_ip 192.168.1.1 参数,可以使指定IP访问。 mongod --bind_ip 192.168.1.1 连接时必须指定IP,否则会失败。 mongo 192.168.1.1 用户 MongoDB中默认有一个空的admin数据库,在admin.system.users中保存的用户比其他数据库中设置的权限更大。在admin.system.users中没有添加任何用户的情况下,鸡屎在MongoDB启动时启用了 –auth 参数,客户端不进行任何认证依然可以连接到数据库,并且可以对数据库进行任何操作。 建立系统root用户 使用addUser()函数添加一个root用户。 建立指定权限的用户 使用addUser()函数为test库添加了一个只读权限的用户,设置只读只需要在addUser()函数中传入第3个参数值为true。 执行指定文件中的内容 text.js的内容是 var count = db.yyd.count(); printjson('count if yyd is : ' + count); 查看活动进程 db.currentOp(); 结束进程 db,killOp(opid号) serverStatus 获取运行中的MongoDB服务器统计信息。 db.runCommand({"serverStatus":1}); mongostat 便捷的查看serverStatus的结果。 导出 导入 备份 恢复 fsync和锁 fsync命令会强制服务器将所有缓冲区写入磁盘。还可以选择上锁阻止对数据库的进一步写入,直到释放锁为止。 db,runCommand({"fsync":1,"lock":1}); 上锁之后便可以不用停掉服务器,也不用牺牲备份的实施特性,只是会导致写入操作暂时被阻塞。 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3558446.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Choosing Between ElasticSearch, MongoDB & Hadoop

An interesting trend has been developing in the IT landscape over the past few years. Many new technologies develop and immediately latch onto the “Big Data” buzzword. And as older technologies add “Big Data” features in an attempt to keep up with the Joneses, we areseeing a blurring of the boundaries between various technologies. Say you have search engines such as ElasticSearch or Solr storing JSON documents, MongoDB storing JSON documents, or a pile of JSON documents stored in HDFS on a Hadoop cluster. Interestingly enough, you can fulfill many of the same use cases with any of these three configurations. ElasticSearch as a NoSQL database? Superficially, that doesn’t sound right, but nonethelessit is a valid scenario. Likewise, MongoDB with support for MapReduce over sharded collections can accomplish many of the same things as Hadoop. And, of course, with the many tools that you can layer on top of a Hadoop base (Hive, HBase, Pig, and the like) you can query data from your Hadoop cluster in a multitude of ways. Given that, can we now say that Hadoop, MongoDB and ElasticSearch are all exactly equivalent? Of course not. Each tool still has a niche for which it is most ideally suited, but each has enough flexibility to fulfill multiple roles. The question now becomes “What is the ideal use for each of these technologies”, and that my friends is what we will explore now. ElasticSearch has begun to spread beyond its roots as a “pure” search engine and now adds some features for analytics and visualization - but at its core,remains primarily a full-text search engine for locating documents by keyword. ElasticSearch builds on top of Lucene and supports extremely fast lookup and a rich query syntax. If you have millions (or more) of text documents and you need to locate documents by keywords located in that text, ElasticSearch fits the bill perfectly. Yes, if your documents are JSON you can treat ElasticSearch as a sort of lightweight “NoSQL database”. But ElasticSearch is not quite a “database engine” and provides less support for complex calculations and aggregation as part of a query - although the “statistics” facet does provide some ability to retrieve calculated statistical information scoped to the given query. Facets in ElasticSearch are intended mainly to support a “faceted navigation” facility. If you are looking to return a (usually small) collection of documents in response to a keyword query, and want the ability to support faceted navigation around those documents, then ElasticSearch is probably your best, first choice. If you need to perform more complex calculations, run server-side scripts against your data, and easily run MapReduce jobs on your data, then MongoDB or Hadoop enter the picture. 假设你的目的是通过指定keyword查询取得一个文档集合(一般是较小的),而且具有支持对文档基于切面的导航,elasticsearch会非常合适,可是假设你希望支持很多其它复杂的计算,在server端你的数据上执行脚本,非常easy的在你的数据上执行mapreduce成寻。那么MongoDB和Hadoop就在被考虑的范围里边了。 MongoDB is a “NoSQL” database which is designed from the ground up to be highly scalable, with automatic sharding support and a number of additional performance optimizations. MongoDB is a document oriented database which stores document in a “JSON like” format (technically BSON) with some extensions beyond plain JSON - for example, a native date type. MongoDB provides a text index type for supporting full-text search against fields which contain text, so we can see that there is overlap between what you can do with ElasticSearch and MongoDB, in terms of basic keyword search against a collection of documents. Where MongoDB goes beyond ElasticSearch is its support for features like server-side scripts in Javascript, aggregation pipelines, MapReduce support and capped collections. With MongoDB, you can use aggregation pipelines to process documents in a collection, streaming them through a sequence of pipeline operators where each operator transforms the document. Pipeline operators can generate entirely new documents or remove documents from the final output. This is a very powerful facility for filtering, processing and transforming data as it is retrieved. MongoDB also supports running map/reduce jobs over the data in a collection, using custom Javascript functions for the map and reduce phases of the operation. This allows for ultimate flexibility in performing any type of calculation or transformation to the selected data. 与ES相比,MongoDB超过es的地方是支持server端的javascript和聚合管道 以及MapReduce的支持和capped collections Another extremely powerful feature in MongoDB is known as “capped collections”. With the capped collections facility, a user can define a maximum size for a collection - after which the collection can simply be written to blindly, and it will roll-over data as necessary to maintain the specified size limit. This feature is extremely useful for capture logs and other streaming data for analysis. 另外一个很NB的特征是capped collections;通过capped collections。用户能够定义为一个collection定义最大的size,用来插入数据(仅仅能插入更新 不能删除)。依照LRU挤出数据存放新插入的数据,这个特点很适合获取log数据和流数据的存储和分析 科普一下capped collections 特点: 1.仅仅能插入,更新,不能删除doc,能够使用drop()删除整个collection 2.LRU列表。相信大家对这个应该非常了解了,oracle里面非常多地方就是用的这个规则,假设指定的集合大小满了。那么会依照LRU挤出数据存放新插入的数据,这里记得更新是不能超出collection的大小的,不能挤出空间存放更新的数据,这个也合情合理。 3.插入的记录都是依照插入的顺序排列,普通的collection在_id上是肯定有索引的,可是这里是没有的 4.能够高速的查询和插入。假设写比读的比例大。建议不要建立索引。否则写会耗费非常多额外的资源。 As you can see, while ElasticSearch and MongoDB have some overlap in possible use cases, they are not the same tool. But what about Hadoop? Isn’t Hadoop “just MapReduce” which is supported by MongoDB anyway? Is there really a use case for Hadoop where MongoDB isjust as suitable. In a word, yes. Hadoop is the grand-father of MapReduce based cluster computing frameworks. Hadoop provides probably the overall most flexible and powerful environment for processing large amounts of data, and definitely fits niches for which you would not use ElasticSearch or MongoDB. To understand why this is true, look at how Hadoop abstracts storage - via HDFS - from the associated computational facility. With data stored in HDFS, any arbitrary job can be run against that data, using either Java code written to the core MapReduce API, or arbitrary code written in native languages using Hadoop Streaming. And starting with Hadoop2 and YARN, even the core programming model is abstracted so that you aren’t limited to MapReduce. With YARN you can, for example, implement MPI on top of Hadoop and write jobs in that style. Additionally, the Hadoop ecosystem provides a staggering array of tools that build on top of HDFS and core MapReduce to query, analyze and process data. Hive provides a “SQL like” language that allows Business Analysts to query data using a syntax they are already familiar with. HBase provides a column oriented database on top of Hadoop. Pig and Sizzle provide two more alternative programming models for querying Hadoop Data. With data stored in HDFS using Hadoop, you inherit the ability to simply plugin Apache Mahout to use advanced machine learning algorithms on your data. While using RHadoopis straightforward to use the R statistical language to perform advanced statistical analyses on Hadoop data. So while Hadoop and MongoDB also have some overlapping use cases, and share some useful functionality (seamless horizontal scalability, for example) it remains the case that each tool serves a specific purpose in enterprise computing. If you simply want to locate documents by keyword and perform simple analytics, then ElasticSearch mayfit the bill. If you need to query documents that can be modeled as JSON and perform moderately more sophisticated analysis, then MongoDB becomes a compelling choice. And if you have a huge quantity of data that needs a wide variety of different types of complex processing and analysis, then Hadoop provides the broadest range of tools and the most flexibility. As always, it is important to choose the right tool(s) for the job at hand. And in the “Big Data” space the sheer number of technologies and the blurry lines can make this difficult. As we can see, there are specific scenarios which best suit each of these technologies and, more importantly,the differences do matter. Though, the best news of all isyou are notlimited to using only one of these tools. Depending on the details of your use case, it may actually make sense to build a combination platform. For example, ElasticSearch and Hadoop are known to work well together, with ElasticSearch providing rapid keyword search, and Hadoop jobs powering the more complicated analytics. In the end, it takes ample research and careful analysis to make the best choices for your computing environment. Before selecting any technology or platform, take the time to evaluate it carefully, understand what scenarios it was designed to optimize for, and what tradeoffs and sacrifices it makes. Start with a small pilot project to “kick the tires” before converting your entire enterprise to a new platform, and slowly grow into the new stack. Follow these steps and you can successfully navigate the maze of “Big Data” technologies and reap the associated benefits.\ 本文转自:http://www.osintegrators.com/opensoftwareintegrators%7CChoosing-Between-ElasticSearch-MongoDB-%2526-Hadoop 本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5208702.html,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android Step Counter & Detector Sensor

package zhangphil.sensor; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; public class MainActivity extends AppCompatActivity { private String TAG = "ZHANG PHIL"; private SensorManager mSensorManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startSensor(); } /** * 启动传感器。 */ private void startSensor() { mSensorManager = (SensorManager) this.getSystemService(Context.SENSOR_SERVICE); Sensor mStepCounterSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER); Sensor mStepDetectorSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR); if (mSensorManager == null || mStepCounterSensor == null || mStepDetectorSensor == null) { throw new UnsupportedOperationException("设备不支持"); } mSensorManager.registerListener(mSensorEventListener, mStepCounterSensor, SensorManager.SENSOR_DELAY_NORMAL); mSensorManager.registerListener(mSensorEventListener, mStepDetectorSensor, SensorManager.SENSOR_DELAY_NORMAL); } private SensorEventListener mSensorEventListener = new SensorEventListener() { private float step, stepDetector; @Override public void onSensorChanged(SensorEvent sensorEvent) { /** * 计步计数传感器传回的历史累积总步数 */ if (sensorEvent.sensor.getType() == Sensor.TYPE_STEP_COUNTER) { step = sensorEvent.values[0]; Log.d(TAG, "STEP_COUNTER:" + step); } /** * 计步检测传感器检测到的步行动作是否有效? */ if (sensorEvent.sensor.getType() == Sensor.TYPE_STEP_DETECTOR) { stepDetector = sensorEvent.values[0]; Log.d(TAG, "STEP_DETECTOR:" + stepDetector); if (stepDetector == 1.0) { Log.d(TAG, "一次有效的步行"); } } } @Override public void onAccuracyChanged(Sensor sensor, int i) { } }; @Override protected void onDestroy() { super.onDestroy(); mSensorManager.unregisterListener(mSensorEventListener); } }

优秀的个人博客,低调大师

Ubuntu SVN安装&使用&命令

SVN 安装 apt-get install subversion checkout svn checkout svn://192.168.1.110/app 按提示输入相应的用户名和密码。 往版本库中添加新的文件 svn add *.c //(添加当前目录下所有的 c文件) 将改动的文件提交到版本库 svn commit -m “my commit“ test.cpp 删除文件 svn delete svn://192.168.1.100/app/php/helloworld.php -m “delete file” help帮助 svn help chechout checkout (co): Check out a working copy from a repository. usage: checkout URL[@REV]... [PATH] SVN常用命令 checkout svn checkout path(path 是服务器上的目录) //例如:svn checkout svn://192.168.1.100/app/ 添加新的文件 svn add file //例如:svn add test.php(添加test.php) 将改动的文件提交到版本库 svn commit -m “LogMessage“ [-N] [--no-unlock] PATH (如果选择了保持锁,就使用–no- unlock开关) //例如:svn commit -m “add test file for my test“ test.php 加锁/解锁 svn lock -m “LockMessage“ [--force] PATH //例如:svn lock -m “lock test file“ test.php 更新到某个版本 svn update -r m path //例如: //svn update如果后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本。 //svn update -r 200 test.php(将版本库中的文件test.php还原到版本200) //svn update test.php(更新,于版本库同步。如果在提交的时候提示过期的话,是因为冲突,需要先update,修改文件,然后清除svn resolved,最后再提交commit) 查看文件或者目录状态 svn status path(目录下的文件和子目录的状态,正常状态不显示) //【?:不在svn的控制中;M:内容被修改;C:发生冲突;A:预定加入到版本库;K:被锁定】 svn status -v path(显示 文件和子目录状态) //第一列保持相同,第二列显示工作版本号,第三和第四列显示最后一次修改的版本号和修改人。 //注:svn status、svn diff和 svn revert这三条命令在没有网络的情况下也可以执行的,原因是svn在本地的.svn中保留了本地版本的原始拷贝。 删除文件 svn delete path -m “delete test fle“ //例如:svn delete svn://192.168.1.100/app/php/test.php -m “delete test file” //或者直接svn delete test.php 然后再svn ci -m ‘delete test file‘,推荐使用这种 查看日志 svn log path //例如:svn log test.php 显示这个文件的所有修改记录,及其版本号的变化 查看文件详细信息 svn info path //例如:svn info test.php 比较差异 svn diff path(将修改的文件与基础版本比较) //例如:svn diff test.php svn diff -r m:n path(对版本m和版本n比较差异) //例如:svn diff -r 200:201 test.php 将两个版本之间的差异合并到当前文件 svn merge -r m:n path //例如:svn merge -r 200:205 test.php(将版本200与205之间的差异合并到当前文件,但是一般都会产生冲突,需要处理一下) 恢复本地修改 svn revert: 恢复原始未改变的工作副本文件 (恢复大部份的本地修改)。revert: //注意: 本子命令不会存取网络,并且会解除冲突的状况。但是它不会恢复被删除的目录 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/4300332.html如需转载请自行联系原作者

优秀的个人博客,低调大师

Docker 上传镜像&拉取镜像

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36367789/article/details/81623850 与git相似,docker也有自己的镜像仓库,官方仓库网站是https://hub.docker.com/,其实我们平时docker pull xxx就是从该仓库得到的镜像(在不设置国内镜像加速的情况下)。它和git仓库很相似。 创建账号 DockerHub:https://hub.docker.com/ 很多人在这里就出了问题,为什么都填完了但是不能点注册按钮呢?因为该网站目前来说注册是需要翻墙的,注册成功后再关闭翻墙。 我重新上传一个项目做示范,该镜像是从hub上pull到的一个nginx镜像,我把它上传到我的公开仓库。 上传镜像 先登录docker hub账号。 docker login [root@FantJ ~]# docker login Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one. Username (fantj): fantj Password: Login Succeeded [root@FantJ ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB [root@FantJ ~]# docker tag docker.io/nginx fantj/nginx [root@FantJ ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB fantj/nginx latest ae513a47849c 4 weeks ago 109 MB docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB [root@FantJ ~]# docker push fantj/nginx The push refers to a repository [docker.io/fantj/nginx] 7ab428981537: Mounted from library/nginx 82b81d779f83: Mounted from library/nginx d626a8ad97a1: Mounted from library/nginx latest: digest: sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90 size: 948 [root@FantJ ~]# 流程大概是:登录->tag操作->push 注:tag 的第二个参数的前缀是你的hub账户名 拉取镜像 我先把服务器上的镜像删除掉,然后再从hub中拉取镜像。 # 删除本地fantj/nginx镜像 [root@FantJ ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB fantj/nginx latest ae513a47849c 4 weeks ago 109 MB docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB [root@FantJ ~]# docker rmi fantj/nginx Untagged: fantj/nginx:latest Untagged: fantj/nginx@sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90 [root@FantJ ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB # 从hub中拉取fantj/nginx镜像 [root@FantJ ~]# docker pull fantj/nginx Using default tag: latest Trying to pull repository docker.io/fantj/nginx ... latest: Pulling from docker.io/fantj/nginx Digest: sha256:e4f0474a75c510f40b37b6b7dc2516241ffa8bde5a442bde3d372c9519c84d90 Status: Downloaded newer image for docker.io/fantj/nginx:latest [root@FantJ ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/openjdk 8-jre bef23b4b9cac 2 weeks ago 443 MB docker.io/fantj/nginx latest ae513a47849c 4 weeks ago 109 MB docker.io/nginx latest ae513a47849c 4 weeks ago 109 MB [root@FantJ ~]#

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册