【发布时间】:2016-01-31 04:07:43
【问题描述】:
这里从 JSON 输出中提取。 JSON文档automationConfig是MongoDB Ops Manager,用于管理mongod的商业产品。
$ cat automationConfig | jq '.processes[]'
{
"args2_6": {
"net": {
"port": 28200
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-cache-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_0",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_0/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-ca-sc-wooom-stack4-prd-1.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-cache-dbspace_0",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28200
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-cache-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_1",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_1/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-ca-sc-wooom-stack4-prd-2.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-cache-dbspace_1",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28200
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-cache-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_2",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-cache-dbspace/wooomtest-cache-dbspace_2/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-ca-sc-wooom-stack4-prd-3.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-cache-dbspace_2",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28000
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-identity-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_3",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_3/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-id-sc-wooom-stack4-prd-1.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-identity-dbspace_3",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28000
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-identity-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_4",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_4/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-id-sc-wooom-stack4-prd-2.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-identity-dbspace_4",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28000
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-identity-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_5",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-identity-dbspace/wooomtest-identity-dbspace_5/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-id-sc-wooom-stack4-prd-3.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-identity-dbspace_5",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28300
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-library-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_6",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_6/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-lib-sc-wooom-stack4-prd-1.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-library-dbspace_6",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28300
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-library-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_7",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_7/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-lib-sc-wooom-stack4-prd-2.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-library-dbspace_7",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28300
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-library-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_8",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-library-dbspace/wooomtest-library-dbspace_8/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-lib-sc-wooom-stack4-prd-3.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-library-dbspace_8",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28100
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-storage-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_9",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_9/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-st-sc-wooom-stack4-prd-1.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-storage-dbspace_9",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28100
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-storage-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_10",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_10/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-st-sc-wooom-stack4-prd-2.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-storage-dbspace_10",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28100
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-storage-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_11",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-storage-dbspace/wooomtest-storage-dbspace_11/mongodb.log"
}
},
"authSchemaVersion": 5,
"disabled": false,
"hostname": "node-z5-wooomtest-st-sc-wooom-stack4-prd-3.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-storage-dbspace_11",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28400
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-support-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_12",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_12/mongodb.log"
}
},
"authSchemaVersion": 5,
"hostname": "node-z5-wooomtest-sup-sc-wooom-stack4-prd-1.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-support-dbspace_12",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28400
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-support-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_13",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_13/mongodb.log"
}
},
"authSchemaVersion": 5,
"hostname": "node-z5-wooomtest-sup-sc-wooom-stack4-prd-2.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-support-dbspace_13",
"processType": "mongod",
"version": "3.0.7"
}
{
"args2_6": {
"net": {
"port": 28400
},
"operationProfiling": {},
"replication": {
"replSetName": "wooomtest-support-dbspace"
},
"storage": {
"dbPath": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_14",
"engine": "wiredTiger"
},
"systemLog": {
"destination": "file",
"path": "/data/wooomtest-support-dbspace/wooomtest-support-dbspace_14/mongodb.log"
}
},
"authSchemaVersion": 5,
"hostname": "node-z5-wooomtest-sup-sc-wooom-stack4-prd-3.sc-wooom-stack4-prd.local",
"logRotate": {
"sizeThresholdMB": 1000,
"timeThresholdHrs": 24
},
"name": "wooomtest-support-dbspace_14",
"processType": "mongod",
"version": "3.0.7"
}
我只能提取版本
$ cat automationConfig | jq '.processes[] .version'
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
"3.0.7"
现在我希望使用 shell 工具 jq 将数字“3.0.7”替换为“3.0.6”。
我正在关注这个docs.mongodb.com,但希望降级(而不是升级)。
【问题讨论】:
-
cat automationConfig | jq '.processes[].version = "3.0.6"'?
标签: mongodb search replace sed jq