Nano Server速记
!!!!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 { public { // BuildWebHost(args).Run(); CreateWebHostBuilder(args).RunAsService(); } public //WebHost.CreateDefaultBuilder(args) // .UseStartup<Startup>() // .Build(); { //在IIS启动 var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("hosting.json", optional: true) .Build(); return .UseConfiguration(config) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); } public { //以服务形式启动 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 .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速记的更多相关文章
- 微软发布 Windows Server 2016 预览版第三版,开发者要重点关注Nano Server
微软已经发布 Windows Server 2016 和 System Center 2016 第三个技术预览版,已经提供下载.Windows Server 2016 技术预览版第三版也是首个包括了容 ...
- ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core
原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...
- 部署微软Nano Server的好处是什么?
虚拟化对数据中心效率和硬件利用率产生了戏剧性的影响,但是接下来有关系统整合的主要责任落 在了操作系统的重量上.虚拟机通常运行企业级操作系统,比如Windows Server,但是Windows Ser ...
- Docker windows nano server容器中安装ssh实现远程登录管理
[问题] 使用ServiceMonitor.exe作为前台进程运行起来的容器无法attach. 无法远程连接到运行中的容器中进行管理. [解决方法] 在container中新建管理员用户,通过SSH实 ...
- 远离DoS攻击 Windows Server 2016发布DNS政策
Windows Server 2016的网络功能虽然没有获得像Docker容器和Nano Server同等重要的关注,但是管理员们应该了解的是,新的域名系统(Domain Name ...
- Windows Server 2016-存储新增功能
本章给大家介绍有关Windows Server 2016 中存储方面的新增功能,具体内容如下: 1.Storage Spaces Direct: 存储空间直通允许通过使用具有本地存储的服务器构建高可用 ...
- Windows Server 2016-增强IPAM
Windows Server 2016网络功能可能没有像Docker容器或Nano Server那样得到关注,但是管理员应该了解新的域名系统服务器和IP地址管理功能如何帮助他们获得对网络环境的更多控制 ...
- Windows Server 2016-Nano Server介绍
WindowsServer 2016 提供了新的安装选项:Nano Server.Nano Server 是针对私有云和数据中心进行优化的远程管理的服务器操作系统. 类似于 Windows Serve ...
- Windows Server 2016-系统安装软硬件要求
本章为大家补充介绍安装 Windows Server 2016的最低系统要求. 如果安装时选择通过"服务器核心"选项进行安装,则应注意,没有安装任何 GUI 组件,并且将不能使用服 ...
随机推荐
- 《前端之路》之 JavaScript 进阶技巧之高阶函数(下)
目录 第二章 - 03: 前端 进阶技巧之高阶函数 一.防篡改对象 1-1:Configurable 和 Writable 1-2:Enumerable 1-3:get .set 2-1:不可扩展对象 ...
- 8天入门docker系列 —— 第五天 使用aspnetcore小案例熟悉容器互联和docker-compose一键部署
这一篇继续完善webnotebook,如果你读过上一篇的内容,你应该知道怎么去挂载webnotebook日志和容器的远程访问,但是这些还远不够,webnotebook 总要和一些数据库打交道吧,比如说 ...
- .net mvc + layui做图片上传(一)
图片上传和展示是互联网应用中比较常见的一个功能,最近做的一个门户网站项目就有多个需要上传图片的功能模块.关于这部分内容,本来功能不复杂,但后面做起来却还是出现了一些波折.因为缺乏经验,对几种图片上传的 ...
- Flink源码分析 - 源码构建
原文地址:https://mp.weixin.qq.com/s?__biz=MzU2Njg5Nzk0NQ==&mid=2247483692&idx=1&sn=18cddc1ee ...
- Windows下docker的安装以及遇到的问题
最近因为业务的需要,需要在本地搭建服务环境测试,不想去安装各种软件,于是就想到了用docker来满足我的需要.由于第一次在Windows下安装(以前一直是在linux下使用,但由于内存等硬件的限制 ...
- java maven项目update project默认编译器1.5问题解决
解决办法一:在项目中的pom.xml指定jdk版本,如下 <build> <plugins> <plugin> <groupId>org.apache. ...
- Java成神之路技术整理(长期更新)
以下是Java技术栈微信公众号发布的关于 Java 的技术干货,从以下几个方面汇总. Java 基础篇 Java 集合篇 Java 多线程篇 Java JVM篇 Java 进阶篇 Java 新特性篇 ...
- 【ElasticSearch篇】--ElasticSearch从初识到安装和应用
一.前述 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口,在企业中全文搜索时,特别常用. 二.常用概念 clu ...
- 《前端之路》之四 JavaScript 的闭包、作用域、作用域链
04:JavaScript 的闭包 一.定义: 常规定义: 闭包的定义: 有权利访问外部函数作用域的函数. 通俗定义: 1.函数内部包含了函数.然后内部函数可以访问外部函数的作用域. 2.内部函数可以 ...
- Accept 与 Content-Type
Accept 表示请求方希望的资源类型,或者能解析识别的类型 Content-Type 表示实际发送的资源类型 这里资源类型通过 MIME types 表示. Accept Accept 是浏览器发送 ...