!!!!NanoServer已死,烧香!!!donnetcore 只支持1.x

 

入门参考https://docs.microsoft.com/zh-cn/windows-server/get-started/nano-server-quick-start

1、创建VHD

Import-module .\NanoServerImageGenerator.psm1 -Verbose

New-NanoServerImage -Edition Standard -DeploymentType Guest -MediaPath j:\ -BasePath d:\vm\nano -TargetPath d:\vm\nano\nano.vhd -ComputerName Nano -Package Microsoft-NanoServer-IIS-Package –EnableRemoteManagementPort

               
 

2、使用VHD创建虚拟机(在其它操作系统上也可以应用此镜像,如WIN8.1)

 

 

3、远程管理

A、连接

@@@code
Set-Item WSMan:\localhost\Client\TrustedHosts "10.168.1.125"
Enter-PSSession -ComputerName "10.168.1.125" -Credential "administrator"
@@#

               

B、共享文件夹

参考https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-2_5-nano_server_on_core.html

 

以SCSI方式挂载其它虚拟磁盘 参考

@@@code
Get-Dis
Get-Partition
Set-Disk -Number 1 -IsOffline $false
Set-Disk -Number 1 -IsReadOnly $false  Remove-Partition -DriveLetter D  Set-Partition -DriveLetter E -NewDriveLetter D  
 mkdir c:\temp
net share AspNetCoreSampleForNano=c:\PublishedApps\AspNetCoreSampleForNano /GRANT:EVERYONE`,FULL  (启用文件共享没什么效果)
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=yes
netsh advfirewall firewall set rule group="@FirewallAPI.dll,-28502" new enable=yes  net share ShareTemp=c:\temp /GRANT:EVERYONE`,FULL
@@#

               
 

C、开端口

参考http://www.pstips.net/manage-firewall-using-powershell.html

               
 

New-NetFirewallRule -Name "MyService" -DisplayName "我的服务" -Protocol TCP -LocalPort 80,8080,3413-3420 -Action Allow -Enabled True

               
 

               
 

D、安装NET CORE

参考https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script

./dotnet-install.ps1 -Channel 2.0 -InstallDir C:\cli

如果提示错误

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

             
 

IIS

参考 https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-2_5-nano_server_on_core.html

下载安装脚本,执行命令

             
 

             
 

自服务

参考https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/windows-service?view=aspnetcore-2.1

Cmd /c sc create MyService binPath= "c:\temp\publish\WebApplication2.exe" start= auto

Cmd /c sc start MyService

(使用独立发布,安装了2.0框架,在CENTOS中安装了2.1,独立发布出现DLL的版本签名不一致,最终使用框架依赖发布)

public
class
Program

{

public
static
void Main(string[] args)

{

// BuildWebHost(args).Run();

CreateWebHostBuilder(args).RunAsService();

}

             
 

public
static IWebHost BuildWebHost(string[] args)

//WebHost.CreateDefaultBuilder(args)

// .UseStartup<Startup>()

// .Build();

{

//在IIS启动

var config = new ConfigurationBuilder()

.SetBasePath(Directory.GetCurrentDirectory())

.AddJsonFile("hosting.json", optional: true)

.Build();

return
new WebHostBuilder()

.UseConfiguration(config)

.UseKestrel()

.UseContentRoot(Directory.GetCurrentDirectory())

.UseIISIntegration()

.UseStartup<Startup>()

.Build();

}

             
 

public
static IWebHost CreateWebHostBuilder(string[] args)

{

//以服务形式启动

var pathToExe = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

var pathToContentRoot = Path.GetDirectoryName(pathToExe);

             
 

var config = new ConfigurationBuilder()

.SetBasePath(pathToContentRoot)

.AddJsonFile("hosting.json", optional: true)

.Build();

             
 

return
new WebHostBuilder()

.UseConfiguration(config)

.UseKestrel()

.UseContentRoot(pathToContentRoot)

.UseStartup<Startup>().Build();

}

             
 

}

             
 

         
 

Linux下安装NETCORE

#netcor 安装脚本

#vi /etc/sysconfig/network-scripts/ifcfg-eth0 (可能不是这个名字),将onboot=no修改为yes

ip addr

service network restart

ip addr

     
 

#使用CRT登录方便复制

su

     
 

yum -y install net-tools

ifconfig

mkdir /opt/dotnet

cd /opt/dotnet

     
 

yum -y install wget

yum -y install icu

     
 

wget -c https://dot.net/v1/dotnet-install.sh

     
 

chmod +x dotnet-install.sh

./dotnet-install.sh -Channel 2.1 -InstallDir /opt/dotnet

export PATH=$PATH:/opt/dotnet

./dotnet --info

     
 

yum -y install zip unzip

yum -y install lrzsz

     
 

#部署网站

mkdir /app

cd /app

mkdir BandServer

     
 

#使用rz指令上传网站压缩包,使用unzip解压,注意压缩包的相对目录

#unzip publish.zip

#添加防火墙

firewall-cmd --zone=public --add-port=3415/tcp --permanent

firewall-cmd --reload

     
 

#启动网站观察是否工作正常

dotnet BandServer.dll

     
 

     
 

#配置守护进程

     
 

yum -y install python-setuptools

easy_install supervisor

supervisord --version

     
 

echo_supervisord_conf > /etc/supervisord.conf

     
 

#编辑supervisord.conf在末尾添加应用(如下,记得去除#)

# [program:bandserver]

# directory=/app/BandServer

# command=/opt/dotnet/dotnet BandServer.dll

# autostart=true

# autorestart=true

# stderr_logfile=/var/log/bandserver.err.log

# stdout_logfile=/var/log/bandserver.out.log

# user=root

# stopsignal=INT

# redirect_stderr=true

     
 

     
 

#设置为开机执行

# vi /etc/rc.local

#添加 supervisord -c /etc/supervisord.conf

#chmod +x /etc/rc.local

systemctl enable rc-local

#手动启动守护

supervisord -c /etc/supervisord.conf

supervisorctl start all

supervisorctl status

     
 

#重启

# reboot

       
 

       
 

     

Nano Server速记的更多相关文章

  1. 微软发布 Windows Server 2016 预览版第三版,开发者要重点关注Nano Server

    微软已经发布 Windows Server 2016 和 System Center 2016 第三个技术预览版,已经提供下载.Windows Server 2016 技术预览版第三版也是首个包括了容 ...

  2. ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core

    原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...

  3. 部署微软Nano Server的好处是什么?

    虚拟化对数据中心效率和硬件利用率产生了戏剧性的影响,但是接下来有关系统整合的主要责任落 在了操作系统的重量上.虚拟机通常运行企业级操作系统,比如Windows Server,但是Windows Ser ...

  4. Docker windows nano server容器中安装ssh实现远程登录管理

    [问题] 使用ServiceMonitor.exe作为前台进程运行起来的容器无法attach. 无法远程连接到运行中的容器中进行管理. [解决方法] 在container中新建管理员用户,通过SSH实 ...

  5. 远离DoS攻击 Windows Server 2016发布DNS政策

             Windows Server 2016的网络功能虽然没有获得像Docker容器和Nano Server同等重要的关注,但是管理员们应该了解的是,新的域名系统(Domain Name ...

  6. Windows Server 2016-存储新增功能

    本章给大家介绍有关Windows Server 2016 中存储方面的新增功能,具体内容如下: 1.Storage Spaces Direct: 存储空间直通允许通过使用具有本地存储的服务器构建高可用 ...

  7. Windows Server 2016-增强IPAM

    Windows Server 2016网络功能可能没有像Docker容器或Nano Server那样得到关注,但是管理员应该了解新的域名系统服务器和IP地址管理功能如何帮助他们获得对网络环境的更多控制 ...

  8. Windows Server 2016-Nano Server介绍

    WindowsServer 2016 提供了新的安装选项:Nano Server.Nano Server 是针对私有云和数据中心进行优化的远程管理的服务器操作系统. 类似于 Windows Serve ...

  9. Windows Server 2016-系统安装软硬件要求

    本章为大家补充介绍安装 Windows Server 2016的最低系统要求. 如果安装时选择通过"服务器核心"选项进行安装,则应注意,没有安装任何 GUI 组件,并且将不能使用服 ...

随机推荐

  1. 实现AutoMapper(1.0版本)

    最近有个需求就是实体之间自动转换,网上肯定有很多现成的实现,不过还是自己写了一个,就当对java高级特性的一个熟悉的过程.这中间包含了泛型,反射,lamada表达式.对于想了解java高级特性的人来说 ...

  2. ajax调用WebAPI添加数据

    //获取账号名 var Name = document.getElementById("Text1").value;//获取密码 var Pass = document.getEl ...

  3. python的学习笔记01_1 python2和python3的区别和环境

    1.python2 与 python3 区别: 关于这两个版本的区别,从宏观上来讲: python2:源码不标准,混乱(很多技术大佬写的都有自己语言的特点,看起来很不pythoner)由于python ...

  4. 安卓4.0以上系统怎么不用root激活XPOSED框架的方法

    在大多单位的引流或业务操作中,基本上都需要使用安卓的高端技术Xposed框架,近期,我们单位购买了一批新的安卓4.0以上系统,基本上都都是基于7.0以上版本,基本上都不能够刷入root超级权限,即便是 ...

  5. Windows下docker的安装以及遇到的问题

      最近因为业务的需要,需要在本地搭建服务环境测试,不想去安装各种软件,于是就想到了用docker来满足我的需要.由于第一次在Windows下安装(以前一直是在linux下使用,但由于内存等硬件的限制 ...

  6. centos7下报错: import requests ImportError: No module named requests

    在网上扒了一个python脚本,在centos7上执行的时候报错: import requestsImportError: No module named requests 原因是:requests是 ...

  7. 超好用的C#控制台应用模板

    本文是Wei的公众号投稿文章: 默认模板之缺 在工作学习中,我们经常需要创建一些简单的控制台应用(Console App)去验证某个想法,或者作为小工具交付给其他同事. 通常我们的选择是 Visual ...

  8. 微信小程序 写一个获取验证码 及setInterval 使用基本方法

    <!--index.wxml--> <view class="container"> <view class="container_cont ...

  9. springcloud之config配置中心-Finchley.SR2版

    本篇和大家分享的是springcloud-config配置中心搭建,写到这里突然想起自己曾今开源过基于Redis发布订阅编写的一个配置中心,刚看了git星数有点少哈哈,这里顺势发个连接欢迎大侠们点赞: ...

  10. 【机器学习】--模型评估指标之混淆矩阵,ROC曲线和AUC面积

    一.前述 怎么样对训练出来的模型进行评估是有一定指标的,本文就相关指标做一个总结. 二.具体 1.混淆矩阵 混淆矩阵如图:  第一个参数true,false是指预测的正确性.  第二个参数true,p ...