Mongo接口

接口调用时须在请求头中设置whaleal-Token ,填写参数发起请求,返回内容为 JSON 格式的信息,返回特殊实体类将在最后提供实体类表格。 其参数为时间的都以时间戳形式传递。

有些接口调用时需用到clusterId、replicateId、eventId、mongoMemberId

eventId在"获取集群日志信息"接口处找到所需事件的id

mongoMemberId在“查找mongoDB集群信息数据”接口返回结果集中mongoMember集合中。

replicateId在“查找mongoDB集群信息数据”接口返回结果集中replicate集合中。

clusterId在“查找mongoDB集群信息数据”接口返回结果集中。


请求头默认格式,特殊情况特殊声明

whaleal-Token在调用登录接口时返回,在之后调用接口时将token放置请求头中。

登录接口调用获取whaleal-Token

KEY VALUE
Accept-Encoding gzip,deflate,br
Connection keep-alive
Content-Type application/json
whaleal-Token "token"


Deprecated 已弃用

1 创建mongodb单例

1.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/createMongoStandalone///


1.2 请求参数

Name Located in Description Required Schema
isNewCluster Path 是否时新集群 Yes boolean
clusterId Path 集群id Yes String
replicateId Path 复制集id Yes String
mongoMember Body 实体对象 Yes MongoMember
tag Params 标签 No String


img.png


Ex. 创建mongodb单例;其中 MongoMember 如下所示:
{
"hostName": "chen",
"hostId": "62bbfbe9a46517610435d615",
"port": "25567",
"dataDirectory": "/home/chen/data25567",
"logFile": "/home/chen/log25567.log",
"version": "mongodb-linux-x86_64-rhel70-4.2.21",
"deleteDataAndLogAble": "false",
"authAble": "false",
"userName": "",
"password": "",
"configurationOptions": {
    "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
    }
}

1.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String
data 返回数据 JSON


{
    "msg": "正在执行",
    "eventId": "62ce9a7ded494511782ff392",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "memberName": "null:27017",
        "hostName": null,
        "hostId": null,
        "port": "27017",
        "version": null,
        "upgradeVersion": null,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "currentTimeMillis": 1657707133455,
        "dataDirectory": "/var/ops/mongodb1657707133455/data/",
        "logFile": "/var/ops/mongodb1657707133455/log/log.log",
        "confPath": "/var/ops/mongodb1657707133455/mongo.conf",
        "deleteDataAndLogAble": false,
        "authAble": false,
        "runShCmd": null,
        "type": 11,
        "status": "无状态",
        "monitorServerStatus": false,
        "monitorTopAndOp": false,
        "collectMongoLog": false,
        "mongoLogFileOffset": 0,
        "operaLogTemp": [],
        "votes": 1,
        "priority": 1.0,
        "delay": 0,
        "buildIndexes": true,
        "procId": "",
        "clusterId": "62ce9a7ded494511782ff393",
        "replId": null,
        "clusterName": null,
        "tags": {},
        "configurationOptions": {},
        "operateVersion": 0
    }
}


2 单节点转为复制集.

2.1 请求路径

GET: http://{Server-Host}:{端口}/api/server/mongo/standaloneToReplicate/


2.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String


postman_mongo_standaloneToReplicate

2.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_standaloneToReplicate_result



3 创建mongodb复制集

3.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/createMongoReplica


3.2 请求参数

Name Located in Description Required Schema
mongoReplica Body mongo复制集实体对象 Yes MongoReplica
tag Params 标签 No String


img_3.png

Ex. 创建mongodb复制集;MongoReplica 如下所示:
{
    "userName": "",
    "password": "",
    "type": 1,
    "clusterId": "",
    "replicaName": "qaq",
    "deleteDataAndLogAble": false,
    "status": "",
    "authAble": "false",
    "operaLog": [],
    "memberList": [
        {
            "type": 31,
            "hostName": "chen",
            "hostId": "62bbfbe9a46517610435d615",
            "port": "25025",
            "version": "mongodb-linux-x86_64-rhel70-4.2.21",
            "votes": "1",
            "priority": "1",
            "delay": "",
            "buildIndexes": true,
            "dataDirectory": "/home/chen/data25025",
            "logFile": "/home/chen/log25025.log",
            "configurationOptions": {
                "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
            }
        }
    ],
    "replicationSettings": {
        "protocolVersion": null,
        "chainingAllowed": null,
        "writeConcernMajorityJournalDefault": null,
        "heartbeatTimeoutSecs": null,
        "electionTimeoutMillis": null,
        "catchUpTimeoutMillis": null,
        "catchUpTakeoverDelayMillis": null,
        "getLastErrorDefaults": null,
        "forceReconfigure": null
    }
}

3.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
data 返回数据 JSON
msg 返回消息 String
eventId 事件ID String


{
    "msg": "正在执行",
    "eventId": "62da7357239d00094230b51a",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "replicaName": null,
        "memberList": [],
        "type": 1,
        "clusterId": "62cf7903ed494511782ff4f9",
        "deleteDataAndLogAble": false,
        "status": null,
        "operaLog": [],
        "replicationSettings": {},
        "replicationOtherSettings": {},
        "authAble": false,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "protocolVersion": 1,
        "writeConcernMajorityJournalDefault": false
    }
}


4 创建mongodb分片

4.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/createMongoSharded


4.2 请求参数

Name Located in Description Required Schema
mongoShard Body 实体对象 Yes MongoShard
tag Params 文件名称 No String


img_5.png

Ex. 创建mongodb分片;其中 MongoShard 如下所示:

{
    "clusterName": "fenpian",
    "deleteDataAndLogAble": "false",
    "authAble": "false",
    "userName": "",
    "password": "",
    "shardingMap": {
        "shard1": {
            "memberList": [
                {
                    "type": 1,
                    "hostName": "chen",
                    "hostId": "62bbfbe9a46517610435d615",
                    "port": "44567",
                    "version": "mongodb-linux-x86_64-rhel70-4.2.21",
                    "votes": "1",
                    "priority": "1",
                    "delay": "",
                    "buildIndexes": "true",
                    "dataDirectory": "/home/chen/data44567",
                    "logFile": "/home/chen/log44567.log",
                    "configurationOptions": {
                        "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
                    }
                }
            ],
            "replicationSettings": {
                "replicaSetId": "shard1",
                "protocolVersion": null,
                "chainingAllowed": null,
                "writeConcernMajorityJournalDefault": null,
                "heartbeatTimeoutSecs": null,
                "electionTimeoutMillis": null,
                "catchUpTimeoutMillis": null,
                "catchUpTakeoverDelayMillis": null,
                "getLastErrorDefaults": null,
                "forceReconfigure": null
            }
        }
    },
    "config": {
        "memberList": [
            {
                "type": 1,
                "hostName": "server100",
                "hostId": "62b153a344ba1b7771c42df7",
                "port": "44567",
                "version": "mongodb-linux-x86_64-rhel70-4.2.21",
                "votes": "1",
                "priority": "1",
                "delay": "",
                "buildIndexes": "true",
                "dataDirectory": "/home/chen/data44567",
                "logFile": "/home/chen/log44567.log",
                "configurationOptions": {
                    "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
                }
            }
        ],
        "replicationSettings": {
            "replicaSetId": "config",
            "protocolVersion": "",
            "chainingAllowed": "",
            "writeConcernMajorityJournalDefault": "",
            "heartbeatTimeoutSecs": "",
            "electionTimeoutMillis": "",
            "catchUpTimeoutMillis": "",
            "catchUpTakeoverDelayMillis": "",
            "getLastErrorDefaults": "",
            "forceReconfigure": ""
        }
    },
    "mongoS": [
        {
            "logFile": "/home/chen/log44567.log",
            "dataDirectory": "/home/chen/data44567",
            "hostName": "server200",
            "version": "mongodb-linux-x86_64-rhel70-4.2.21",
            "port": "44567",
            "configurationOptions": {
                "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
            },
            "hostId": "62cbbd7607bebb71b8429e5e"
        }
    ]
}

4.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String
data 返回数据 JSON


{
    "msg": "正在执行",
    "eventId": "62da73c4239d00094230b51c",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "clusterName": null,
        "clusterId": "62cf8e51ed494511782ff6c8",
        "config": null,
        "mongoS": [],
        "shardingMap": {},
        "operaLog": [],
        "deleteDataAndLogAble": false,
        "authAble": false,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "status": null
    }
}


5 操作开启认证的集群

5.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/operateClusterAbleAuth/


5.2 请求参数

Name Located in Description Required Schema
clusterId Path 文件名称 Yes String
map Body 传参 Yes Map


postman_mongo_operateClusterAbleAuth

Ex. 操作开启认证的集群;其中map 如下所示:
{
    "authAble": "true",    //false 时 不需要其余参数
    "userName": "123",
    "password": "123"
}

5.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String


postman_mongo_operateClusterAbleAuth_result



6 添加shard

6.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/addShard/


6.2 请求参数

Name Located in Description Required Schema
clusterId Path 集群id Yes String
mongoReplica Body mongo复制集实体对象 Yes MongoReplica



Ex. 添加shard;其中 MongoReplica 如下所示:

{
    "type": 3,
    "clusterId": "",
    "replicaName": "qwe",
    "authAble": "true",
    "userName": "",
    "password": "",
    "deleteDataAndLogAble": false,
    "status": "",
    "operaLog": [],
    "memberList": [
        {
            "type": 51,
            "hostName": "chen",
            "hostId": "62bbfbe9a46517610435d615",
            "port": "44453",
            "version": "mongodb-linux-x86_64-rhel70-4.2.21",
            "votes": "1",
            "priority": "1",
            "delay": "",
            "buildIndexes": true,
            "dataDirectory": "/home/chen/data44453",
            "logFile": "/home/chen/log44453.log",
            "configurationOptions": {
                "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
            }
        }
    ]
}

6.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_addShard_result



7 纳管集群信息

7.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/mongoManaged


7.2 请求参数

Name Located in Description Required Schema
mongoMember Body mongo成员实体对象 Yes MongoMember


postman_mongo_mongoManaged

Ex. 纳管集群信息;其中 MongoMember 如下所示:
{
    "hostName": "chen",
    "hostId": "62bbfbe9a46517610435d615",
    "port": "27017",
    "authAble": "false",
    "userName": "",
    "password": "",
    "authDBName": "",
    "clusterName": "fp"
}

7.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
data 返回数据 JSON


{
    "msg": "正在执行",
    "code": 1000,
    "data": {
        "id": "62cfa41fed494511782ff7a2",
        "createTime": 1657775135326,
        "updateTime": 1657775135326,
        "clusterName": "fp",
        "type": 1,
        "mongoMember": {
            ...
        },
        "mongoReplica": null,
        "mongoShard": null,
        "status": null,
        "fcv": null,
        "tag": null,
        "create": true
    }
}


8 升降级

8.1 请求路径

GET: http://{Server-Host}:{端口}/api/server/mongo/upgrade///


8.2 请求参数

type: 1 升级,-1 降级
Name Located in Description Required Schema
clusterId Path 集群id Yes String
version Path 版本 Yes String
type Path 集群类型 Yes String


postman_mongo_upgrade


8.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_upgrade_result



9 针对节点进行操作.

9.1 请求路径

GET: http://{Server-Host}:{端口}/api/server/mongo/operate///


9.2 请求参数

operateType:updateMongoMemberInfo,startUp,shuntDown,restart,delete,canalQPS,openQPS,canalTopAndOP,openTopAndOP,canalCollectMongoLog,openColletMongoLog ,becomePrimary ,removeMember
Name Located in Description Required Schema
clusterId Path 集群id Yes String
mongoMemberId Path mongo集群id Yes String
operateType Path 操作类型 Yes String


postman_mongo_operate


9.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_operate_result



10 针对集群进行操作

10.1 请求路径

GET: http://{Server-Host}:{端口}/api/server/mongo/operate//


10.2 请求参数

operateType:updateMongoMemberInfo,startUp,shuntDown,restart,delete,mdiag
Name Located in Description Required Schema
clusterId Path 集群id Yes String
operateType Path 操作类型 Yes String


postman_mongo_operate


10.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_operate_result



11 更新集群信息

11.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/updateClusterInfo


11.2 请求参数

Name Located in Description Required Schema
mongoClusterInformation Body Mongo集群信息实体对象 Yes JSON


img_11.png

Ex. 更新集群信息;其中MongoClusterInformation 如下所示:
{
    "id": "62cfa574ed494511782ff7c1",
    "createTime": 1657775520238,
    "updateTime": 1657775520238,
    "clusterName": "chen:63343",
    "type": 1,
    "mongoMember": {
        "id": "62cfa574ed494511782ff7c1",
        "createTime": 1657775520238,
        "updateTime": 1657776654587,
        "memberName": "chen:63343",
        "hostName": "chen",
        "hostId": "62bbfbe9a46517610435d615",
        "port": "63343",
        "version": "4.2.21",
        "upgradeVersion": null,
        "userName": "",
        "password": "",
        "authDbName": "admin",
        "currentTimeMillis": 1657775476157,
        "dataDirectory": "/home/chen/data63343",
        "logFile": "/home/chen/log63343.log",
        "confPath": "/home/chen/data63343/chen_63343.conf",
        "deleteDataAndLogAble": false,
        "authAble": false,
        "runShCmd": "",
        "type": 11,
        "status": "正在运行",
        "monitorServerStatus": false,
        "monitorTopAndOp": false,
        "collectMongoLog": false,
        "mongoLogFileOffset": 0,
        "operaLogTemp": [],
        "votes": 1,
        "priority": 1,
        "delay": 0,
        "buildIndexes": true,
        "procId": "10654",
        "clusterId": "62cfa574ed494511782ff7c1",
        "replId": null,
        "clusterName": null,
        "tags": {},
        "configurationOptions": {
        },
        "operateVersion": 80
    },
    "mongoReplica": null,
    "mongoShard": null,
    "status": "正常",
    "fcv": "4.2",
    "tag": "",
    "create": true
}

11.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String


postman_mongo_updateClusterInfo_result

---


12 创建单节点

12.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/createMongoStandalone


12.2 请求参数

Name Located in Description Required Schema
mongoMember Body Mongo对象 Yes MongoMember
tag Params 标签 No String


img_34.png

Ex. 创建单节点;mongoMember 如下所示:
{
    "hostName": "chen",
    "hostId": "62bbfbe9a46517610435d615",
    "port": "25567",
    "dataDirectory": "/home/chen/data25567",
    "logFile": "/home/chen/log25567.log",
    "version": "mongodb-linux-x86_64-rhel70-4.2.21",
    "deleteDataAndLogAble": "false",
    "authAble": "false",
    "userName": "",
    "password": "",
    "configurationOptions": {
        "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
    }
}

12.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String
data 返回数据 JSON

img_35.png

{
    "msg": "正在执行",
    "eventId": "62fb0d67fe07726988b7621b",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "memberName": "null:27017",
        "hostName": null,
        "hostId": null,
        "port": "27017",
        "version": null,
        "upgradeVersion": null,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "currentTimeMillis": 1660620135962,
        "dataDirectory": "/var/ops/mongodb1660620135962/data/",
        "logFile": "/var/ops/mongodb1660620135962/log/log.log",
        "confPath": "/var/ops/mongodb1660620135962/mongo.conf",
        "authAble": false,
        "runShCmd": null,
        "type": 11,
        "status": "无状态",
        "monitorServerStatus": false,
        "monitorTopAndOp": false,
        "collectMongoLog": false,
        "mongoLogFileOffset": 0,
        "operaLogTemp": [],
        "votes": 1,
        "priority": 1.0,
        "delay": 0,
        "buildIndexes": true,
        "procId": "",
        "clusterId": "62fb0d67fe07726988b7621c",
        "replId": null,
        "clusterName": null,
        "tags": {},
        "configurationOptions": {},
        "operateVersion": 0
    }
}


13 复制集添加节点

13.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/replAddMember//


13.2 请求参数

Name Located in Description Required Schema
mongoMember Body Mongo对象 Yes MongoMember
clusterId Path 集群id Yes String
replicateId Path 复制集id Yes String


img_36.png

Ex. 创建单节点;mongoMember 如下所示:
{
    "authAble": "true",
    "userName": "",
    "password": "",
    "type": 1,
    "hostName": "server100",
    "hostId": "62ecdb15dce5916b2b6f1b3c",
    "votes": 1,
    "delay": 10000,
    "priority": 1,
    "port": "34535",
    "dataDirectory": "/home/chen/data34535",
    "logFile": "/home/chen/data34535/log.log",
    "version": "mongodb-linux-x86_64-enterprise-rhel70-4.0.25",
    "deleteDataAndLogAble": "",
    "configurationOptions": {
        "storage.wiredTiger.engineConfig.cacheSizeGB": "0.3"
    }
}

13.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String
data 返回数据 JSON

img_37.png


{
    "msg": "正在执行",
    "eventId": "62fb0fc8fe07726988b76242",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "memberName": "null:27017",
        "hostName": null,
        "hostId": null,
        "port": "27017",
        "version": null,
        "upgradeVersion": null,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "currentTimeMillis": 1660620744008,
        "dataDirectory": "/var/ops/mongodb1660620744008/data/",
        "logFile": "/var/ops/mongodb1660620744008/log/log.log",
        "confPath": "/var/ops/mongodb1660620744008/mongo.conf",
        "authAble": false,
        "runShCmd": null,
        "type": 11,
        "status": "无状态",
        "monitorServerStatus": false,
        "monitorTopAndOp": false,
        "collectMongoLog": false,
        "mongoLogFileOffset": 0,
        "operaLogTemp": [],
        "votes": 1,
        "priority": 1.0,
        "delay": 0,
        "buildIndexes": true,
        "procId": "",
        "clusterId": "62f5bf0ac8b0132564c7d481",
        "replId": null,
        "clusterName": null,
        "tags": {},
        "configurationOptions": {},
        "operateVersion": 0
    }
}


14 添加mongos

14.1 请求路径

POST: http://{Server-Host}:{端口}/api/server/mongo/addMongoS/


14.2 请求参数

Name Located in Description Required Schema
mongoMember Body Mongo对象 Yes MongoMember
clusterId Path 集群id Yes String


img_38.png

Ex. 创建单节点;mongoMember 如下所示:
{
    "hostName": "usdp",
    "hostId": "62f343c86ccc6972abb87835",
    "port": "29003",
    "dataDirectory": "/home/guanfei/data/sharding3/mongos/data28/",
    "logFile": "/home/guanfei/data/sharding3/mongos/data28/mongodb.log",
    "version": "mongodb-linux-x86_64-enterprise-rhel70-3.2.21",
    "configurationOptions": {
        "storage.wiredTiger.engineConfig.cacheSizeGB": "1"
    }
}

13.3 返回结果

Description Schema
code 状态符:1000成功,其余异常 int
msg 返回消息 String
eventId 事件id String
data 返回数据 JSON

img_39.png


{
    "msg": "正在执行",
    "eventId": "62fb1061fe07726988b76246",
    "code": 1000,
    "data": {
        "id": null,
        "createTime": 0,
        "updateTime": 0,
        "memberName": "null:27017",
        "hostName": null,
        "hostId": null,
        "port": "27017",
        "version": null,
        "upgradeVersion": null,
        "userName": null,
        "password": null,
        "authDbName": "admin",
        "currentTimeMillis": 1660620897087,
        "dataDirectory": "/var/ops/mongodb1660620897087/data/",
        "logFile": "/var/ops/mongodb1660620897087/log/log.log",
        "confPath": "/var/ops/mongodb1660620897087/mongo.conf",
        "authAble": false,
        "runShCmd": null,
        "type": 11,
        "status": "无状态",
        "monitorServerStatus": false,
        "monitorTopAndOp": false,
        "collectMongoLog": false,
        "mongoLogFileOffset": 0,
        "operaLogTemp": [],
        "votes": 1,
        "priority": 1.0,
        "delay": 0,
        "buildIndexes": true,
        "procId": "",
        "clusterId": "62f35136bae6034d49b2a0f9",
        "replId": null,
        "clusterName": null,
        "tags": {},
        "configurationOptions": {},
        "operateVersion": 0
    }
}


results matching ""

    No results matching ""