@JunQiu
2018-09-18T11:20:33.000000Z
字数 4025
阅读 1577
summary_2018/07 mongodb docker net linux
## profiling LevelsLevel Description0 The profiler is off and does not collect any data. This is the default profiler level.1 The profiler collects data for operations that take longer than the value of slowms.(仅记录慢查询)2 The profiler collects data for all operations.## set Level// Set the value of slowms using the profile command or db.setProfilingLevel() shell helper method.db.setProfilingLevel(level)// Set the value of --slowms from the command line at startup.// Set the value of slowOpThresholdMs in a configuration file.## For development purposes in testing environments, you can enable database profiling for an entire mongod instance.mongod --profile 1 --slowms 15 --slowOpSampleRate 0.5## get Level// db.getProfilingStatus()// db.getProfilingLevel()## View Profiler Data:query system.profile collection## Profiler Overhead(花销)When enabled, profiling has a minor effect on performance. The system.profile collection is a capped collection with a default size of 1 megabyte.(capped 有操作限制,但效率更高)## Change Size of system.profile Collection// on the Primary 主节点Disable profiling.Drop the system.profile collection.Create a new system.profile collection.Re-enable profiling.Example:db.setProfilingLevel(0)db.system.profile.drop()db.createCollection( "system.profile", { capped: true, size:4000000 } )db.setProfilingLevel(1)// on a Secondary 子节点you must stop the secondary, run it as a standalone, and then perform the steps above. When done, restart the standalone as a member of the replica set.关闭子节点->独立运行->运行上面的操作->作为子节点加上去// Exampledb.system.profile.find( {} ).limit(1).pretty(){"op" : "command", # 操作类型"ns" : "test.col", # 集合"command" : {"collStats" : "col","scale" : 1,"$db" : "test","lsid" : {"id" : UUID("d2634aa9-f9d0-420b-9587-bef043d83960")},"$readPreference" : {"mode" : "primaryPreferred"}},"numYield" : 0,"locks" : { # 锁的类型"Global" : {"acquireCount" : {"r" : NumberLong(2)}},"Database" : {"acquireCount" : {"r" : NumberLong(1)}},"Collection" : {"acquireCount" : {"r" : NumberLong(1)}}},"responseLength" : 13813,"protocol" : "op_msg","millis" : 1,"ts" : ISODate("2018-07-25T03:25:58.781Z"),"client" : "127.0.0.1","allUsers" : [ ],"user" : ""}# 一些比较重要的字段nscanned:The number of index keys that MongoDB scanned in order to carry out the operation.,3.2以前叫keysExamined//一般来说,如果远远高于nreturned,则数据库会扫描许多索引键以查找结果文档。考虑创建或调整索引以提高查询性能。docsExamined:The number of documents in the collection that MongoDB scanned in order to carry out the operation.fromMultiPlanner:A boolean that indicates whether the query planner evaluated multiple plans before choosing the winning execution plan for the query.locks:锁的类型,锁花费的时间nreturned:The number of documents returned by the operation.(如果远大于扫描的数量,可以考虑加索引)responseLength:The length in bytes of the operation’s result document. A large responseLength can affect performance. (大小过大可以考虑,减少字段,或者limit(),batchSize())millis:所花费的时间(毫秒)ts:操作的时间戳
Example:挂载/test目录到容器的/soft目录docker run -v /test:/softTips:1、容器目录不可以为相对路径2、宿主机目录如果不存在,则会自动生成3、如果宿主主机为相对目录,则会在/var/lib/docker/volumes/下(可以使用docker inspect查看image内的"Mounts"部分)
### 在计算机网络中,按照IP地址分类标准:一些特殊IP地址:// 127.0.0.1 回环地址,一般本地域名localhsot// 0.0.0.0 网络号和主机号都全部为0,表示“本网络上的本主机”,只能用作源地址(在路由中,0.0.0.0表示的是默认路由)// 255.255.255.255 广播地址,用于本网络的广播(同一个广播域)Tips:{127,}:即网络号为127的任意ip地址。都是内部主机回环地址(loopback),永远都不能出现在主机外部的网络中。(mac只保留了127.0.01作环回地址)### 在服务器中listen// 0.0.0.0 指的是本机上的所有IPV4地址,如果一个主机有两个IP地址,都会监听// 127.0.0.1 一个环回地址。注意并不表示“本机”,用作测试(相当于仅监听了这张虚拟网卡(loopback)的地址:127.0.0.1)(而且可以监听0.0.0.0????,应该是被回送到了127.0.0.1)### 检测端口占用情况// netstat用来查看系统当前系统网络状态信息,包括端口,连接情况等-t : 指明显示TCP端口-u : 指明显示UDP端口-l : 仅显示监听套接字(LISTEN状态的套接字)-p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序-n : 不进行DNS解析-a 显示所有连接的端口Tips:可以结合grep使用netstat -tunlp | grep 22// lsof的作用是列出当前系统打开文件(list open files),不过通过-i参数也能查看端口的连接情况lsof -i:22(不推荐,只能查看部分)
虚拟网卡loopback:

