Centos7部署.NetCore3.1
1、注册微软签名密码密钥及微软相关支持
*向微软提交,表明要用core*
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
2、安装指定版本
*安装SDK版本*
sudo yum install netcore-sdk-3.1
3、将项目发布并拷贝至centos中
1、选定项目,右键发布
2、拷贝至centos文件夹中
3、执行命令"dotnet xxx.dll"
如项目带输入参数,在dll后输入即可
"dotnet xxx.dll --name xx --env xx"
由于个人项目中设计的HttpRequest,执行时报如下异常
*原因:Consul地址不对,应指向consul地址*
Unhandled exception.System .Net.Http,HttpRequestException: Connection refused
---> System.Net.Sockets.SocketException (111): Connect ion refused
at System.Net .Http . ComnectHe lper . CommectAsync (String host, Int32 port,Cance1lationToken cancella
tionToken)--- End of inner exception stack trace
at System . Net,Http . ConnectHe lper CommectAsymcCString host, Int32 port, Cance 1 lat ionToken cance lla
t ionToken)
at System . Net .Http . HttpConnect ionPool .CommectAsync (Ht tpRequestMessage request, Boolean a llowHttp2
Cance 1 lat ionToken cance 1 lat ionToken )
at System Net,Http,HttpConmect ionPool . CreateHttp11Connect ionAsync CHttpRequestMessage request, Can
ce 1 lat ionToken cance 1 lat ionToken)
at System. Net .Http . HttpConnect ionPoo 1.Ge tHt tpConnect ionAsymc (Ht tpRequestMessage request, Cancella
t ionToken cance 1 lat ionToken)
at System . Net .Http . Ht tpCommect ionPoo 1 SendWi thRe tryAsync CHt tpRequestMessage request, Boolean doRe
questruth, Cance 1 lat ionToken cance 1 lat ionToken)
at System . Net .Http . Red irectHand ler . SendAsync (Ht tpRequestMessage request, Cance 1 lat ionToken cance 1
lat ionToken)
at System . Net,Http .Ht tpCl ient . F in i shSendAsyncBuf f ered(Task 1 sendTask, Ht tpReques tMessage request
Cance 1 lat ionTokenSource cts, Boo lean disposeCts)
at Consul .GetRequest“1. Execute (Cance 1 lat ionToken ct)
at Winton . Extens ions . Conf igurat ion,Consu 1. Consu lConf igurat ionProvider . GetKvPa irs (Boo lean wa itForC
hange )
at Winton . Extens ions . Conf igurat ion,Consu 1.Consu lConf igurat ionProvider . DoLoad ( )
at Winton . Extens ions . Conf igurat ion,Consu 1,Consu lConf igurat ionProvider . Load()
at Microsof t . Extens ions . Conf igurat ion . Conf igurat ionRoot. . ctorCIList 1 providers )
at Microsof t . Extens ions . Conf igurat ion . Conf igurat ionBui lder . BuildO
at GSHIS . Schedu leService . Program. <>c. <CreateHostBuilder>b_ 1 0CHostBu i lderContext hostContext, IS
erviceCol lection services) in D:\SourceGSHIS\Schedu leService\srcSchedu le\GSHIS . Schedu leService\Pro
gram.cs:line 40
at Microsof t,Extens ions .Host ing .HostBui lder .CreateServiceProvider(
at Microsof t . Extens ions . Host ing .HostBui lder . BuildO
at GSHIS . Schedu leService . Program. Ma in(Str ing[] args) in D:\SourceGSHIS\Schedu leService\srcSched
u le\GSHIS . Schedu leService\Program.cs:line 23
Aborted
修改Consul地址后,执行时异常如下
*原因:在Window中,Consul的配置信息来源于应用程序参数*
*在实际发布过程中,并不能写入项目中*
*1、控制台启动应用时代入 dotnet xxx.dll --name xx --env Dxx *
*2、写入appsettings.json中*
Unhandled exception. Consul.ConsulRequestException : Unexcepted response,status code internalServeError: No Path to Datacenter