原始问题正在编辑中。
编辑:所以我想出了问题。该应用程序的数据库已设置为副本集,而这正是这里所缺少的。我遵循了文章https://docs.mongodb.com/manual/tutorial/deploy-replica-set-for-testing/中提到的所有步骤 但现在无法设置副本集
[LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
2019-08-12T09:32:27.102+0530 I CONTROL [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
2019-08-12T09:32:27.103+0530 I CONTROL [LogicalSessionCacheRefresh] Sessions collection is not set up; waiting until next sessions refresh interval: Replication has not yet been configured
这是我在运行命令时得到的
mongod --replSet rsSpeQue --port 27017 --bind_ip localhost --dbpath \SpeQueRS\rsSpeQue1 --smallfiles --oplogSize 128
设置在端口27017上设置的副本。命令输出> db.runCommand(“ getCmdLineOpts”)
{
"argv" : [
"C:\\Program Files\\MongoDB\\Server\\4.0\\bin\\mongod.exe",
"--config",
"C:\\Program Files\\MongoDB\\Server\\4.0\\bin\\mongod.cfg",
"--service"
],
"parsed" : {
"config" : "C:\\Program Files\\MongoDB\\Server\\4.0\\bin\\mongod.cfg",
"net" : {
"bindIp" : "127.0.0.1",
"port" : 27017
},
"service" : true,
"storage" : {
"dbPath" : "C:\\Program Files\\MongoDB\\Server\\4.0\\data",
"journal" : {
"enabled" : true
}
},
"systemLog" : {
"destination" : "file",
"logAppend" : true,
"path" : "C:\\Program Files\\MongoDB\\Server\\4.0\\log\\mongod.log"
}
},
"ok" : 1
}
基本上,没有设置副本集。我在这里想念什么?
答案 0 :(得分:0)
由于您没有提供任何.NET Core 2.2应用程序中安装的C#代码和nu-gets,因此我在此处给出一个通用答案。尝试以下方法,让我知道是否可以解决问题:
为MongoDB更改appsettings.Development.json中的connectionString,如下所示:
WITH XMLNAMESPACES(DEFAULT'http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition')
SELECT c.ItemID as ReportID,
c.Name as ReportName,
c.path as ReportPath,
CAST(CONVERT( xml, CONVERT(varbinary(MAX), Content)) AS varchar(MAX)) as ReportContent,
CONVERT( xml, CONVERT(varbinary(MAX), Content) ).value('(/Report/DataSets/DataSet/Query/CommandText/text())[1]','varchar(1000)') as ReportQuery
INTO #RSTemp
FROM [dbo].[Catalog] c
WHERE Content IS NOT NULL AND type =2
GO
SELECT *
FROM #RSTemp
WHERE ReportContent LIKE '%Any SQL command, table name or comment I want to search for!%'
}
确保您已安装以下Nuget(并非强制要求全部安装,但便于以后操作)
"ConnectionStrings": {
"DefaultConnection": "mongodb://localhost:27017?connect=replicaSet"
然后,确保C#语法代码如下:
<PackageReference Include="mongocsharpdriver" Version="2.7.3" />
<PackageReference Include="MongoDB.Bson" Version="2.7.3" />
<PackageReference Include="MongoDB.Driver" Version="2.7.3" />
<PackageReference Include="MongoDB.Driver.Core" Version="2.7.3" />