2017-01-26 111 views
0

我創建一個共享的羣集使用三個配置服務器,在副本設定了三個服務器,並使用mongos客戶端以下the official tutorial,但是當我嘗試創建一個收集與MongoDB的分片集羣錯誤14037

db.createCollection("XYZ") 

我得到

/* 1 */ 
{ 
    "ok" : 0.0, 
    "errmsg" : "can't create user databases on a --configsvr instance", 
    "code" : 14037, 
    "codeName" : "Location14037" 
} 

我的服務器狀態

/* 1 */ 
{ 
    "host" : "mongo-1", 
    "version" : "3.4.1", 
    "process" : "mongos", 
    "pid" : NumberLong(1), 
    "uptime" : 16325.0, 
    "uptimeMillis" : NumberLong(16324905), 
    "uptimeEstimate" : NumberLong(16324), 
    "localTime" : ISODate("2017-01-26T02:04:32.110Z"), 
    "asserts" : { 
     "regular" : 0, 
     "warning" : 0, 
     "msg" : 0, 
     "user" : 0, 
     "rollovers" : 0 
    }, 
    "connections" : { 
     "current" : 4, 
     "available" : 419426, 
     "totalCreated" : 23 
    }, 
    "extra_info" : { 
     "note" : "fields vary by platform", 
     "page_faults" : 0 
    }, 
    "network" : { 
     "bytesIn" : NumberLong(70779), 
     "bytesOut" : NumberLong(106181), 
     "physicalBytesIn" : NumberLong(70779), 
     "physicalBytesOut" : NumberLong(106181), 
     "numRequests" : NumberLong(1865) 
    }, 
    "opcounters" : { 
     "insert" : 0, 
     "query" : 54, 
     "update" : 0, 
     "delete" : 0, 
     "getmore" : 0, 
     "command" : 864 
    }, 
    "sharding" : { 
     "configsvrConnectionString" : "production/10.7.0.28:27019,10.7.0.29:27019,10.7.0.30:27019", 
     "lastSeenConfigServerOpTime" : { 
      "ts" : Timestamp(6379728405545353, 1), 
      "t" : NumberLong(2) 
     } 
    }, 
    "tcmalloc" : { 
     "generic" : { 
      "current_allocated_bytes" : 2719976, 
      "heap_size" : 6291456 
     }, 
     "tcmalloc" : { 
      "pageheap_free_bytes" : 167936, 
      "pageheap_unmapped_bytes" : 0, 
      "max_total_thread_cache_bytes" : 1045430272, 
      "current_total_thread_cache_bytes" : 777824, 
      "total_free_bytes" : 3403544, 
      "central_cache_free_bytes" : 194040, 
      "transfer_cache_free_bytes" : 2431680, 
      "thread_cache_free_bytes" : 777824, 
      "aggressive_memory_decommit" : 0, 
      "formattedString" : "------------------------------------------------\nMALLOC:  2719976 ( 2.6 MiB) Bytes in use by application\nMALLOC: +  167936 ( 0.2 MiB) Bytes in page heap freelist\nMALLOC: +  194040 ( 0.2 MiB) Bytes in central cache freelist\nMALLOC: +  2431680 ( 2.3 MiB) Bytes in transfer cache freelist\nMALLOC: +  777824 ( 0.7 MiB) Bytes in thread cache freelists\nMALLOC: +  1171648 ( 1.1 MiB) Bytes in malloc metadata\nMALLOC: ------------\nMALLOC: =  7463104 ( 7.1 MiB) Actual memory used (physical + swap)\nMALLOC: +   0 ( 0.0 MiB) Bytes released to OS (aka unmapped)\nMALLOC: ------------\nMALLOC: =  7463104 ( 7.1 MiB) Virtual address space used\nMALLOC:\nMALLOC:   508    Spans in use\nMALLOC:    24    Thread heaps in use\nMALLOC:   4096    Tcmalloc page size\n------------------------------------------------\nCall ReleaseFreeMemory() to release freelist memory to the OS (via madvise()).\nBytes released to the OS take up virtual address space but no physical memory.\n" 
     } 
    }, 
    "mem" : { 
     "bits" : 64, 
     "resident" : 28, 
     "virtual" : 228, 
     "supported" : true 
    }, 
    "metrics" : { 
     "cursor" : { 
      "timedOut" : NumberLong(0), 
      "open" : { 
       "multiTarget" : NumberLong(0), 
       "singleTarget" : NumberLong(0), 
       "pinned" : NumberLong(0), 
       "total" : NumberLong(0) 
      } 
     }, 
     "commands" : { 
      "addShard" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(3) 
      }, 
      "aggregate" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(12) 
      }, 
      "buildInfo" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(14) 
      }, 
      "create" : { 
       "failed" : NumberLong(9), 
       "total" : NumberLong(9) 
      }, 
      "enableSharding" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(1) 
      }, 
      "find" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(54) 
      }, 
      "grantRolesToUser" : { 
       "failed" : NumberLong(7), 
       "total" : NumberLong(10) 
      }, 
      "isMaster" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(48) 
      }, 
      "listCollections" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(19) 
      }, 
      "ping" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(618) 
      }, 
      "replSetGetStatus" : { 
       "failed" : NumberLong(14), 
       "total" : NumberLong(14) 
      }, 
      "revokeRolesFromUser" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(1) 
      }, 
      "saslContinue" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(62) 
      }, 
      "saslStart" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(31) 
      }, 
      "serverStatus" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(2) 
      }, 
      "usersInfo" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(8) 
      }, 
      "whatsmyuri" : { 
       "failed" : NumberLong(0), 
       "total" : NumberLong(12) 
      } 
     } 
    }, 
    "ok" : 1.0 
} 

並且分片狀態

--- Sharding Status --- 
    sharding version: { 
    "_id" : 1, 
    "minCompatibleVersion" : 5, 
    "currentVersion" : 6, 
    "clusterId" : ObjectId("58891625f1d4d70889a9787b") 
} 
    shards: 
    { "_id" : "production", "host" : "production/10.7.0.14:27018,10.7.0.16:27018,10.7.0.9:27018", "state" : 1 } 
    active mongoses: 
    "3.4.1" : 1 
    balancer: 
    Currently enabled: yes 
    Currently running: yes 
     Balancer lock taken at Wed Jan 25 2017 17:20:29 GMT-0400 (VET) by ConfigServer:Balancer 
    Failed balancer rounds in last 5 attempts: 0 
    Migration Results for the last 24 hours: 
     No recent migrations 
    databases: 
    { "_id" : "base", "primary" : "production", "partitioned" : true } 

我在做什麼錯?

在此先感謝。

+0

您需要連接到您的'mongos'路由器,然後創建集合 – ares

+0

@ares im使用mongo shell連接到mongos路由器,執行查詢後出現錯誤。或者我應該以不同的方式做到這一點? – bitgandtter

+0

你是否用'--configsvr'選項啓動了'mongos'。錯誤很明顯。 – ares

回答

2

回答我自己的問題,其真正的虛擬問題。問題是,因爲配置服務器是一個副本集,該副本集和分片副本集之間的名稱必須是唯一的,在我的情況下,不會導致問題。