AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 743688
Accepted
the-wabbit
the-wabbit
Asked: 2015-12-18 03:50:19 +0800 CST2015-12-18 03:50:19 +0800 CST 2015-12-18 03:50:19 +0800 CST

在启用配额的故障转移群集中添加共享需要 10 分钟

  • 772

我有文件服务集群,其中一个文件服务器资源托管约 50,000 个用户主目录。主目录确实具有通过FSRM分配的配额模板。

当尝试使用故障转移群集管理器的“添加文件共享”向导添加新共享时,它首先检索所有已定义文件服务器群集资源的所有共享文件夹上的所有配额。在这种环境中需要大约 10 分钟。

我怎么可能

  • 加快配额枚举进程
  • 将配额枚举过程限制为仅单个文件服务器集群资源
  • 为新建共享向导完全禁用配额枚举

?

windows-server-2012-r2
  • 1 1 个回答
  • 3008 Views

1 个回答

  • Voted
  1. Best Answer
    the-wabbit
    2015-12-23T04:16:32+08:002015-12-23T04:16:32+08:00

    我终于解决了这个问题,完全取消了使用 GUI 来创建文件共享的要求。相反,我记录了使用 New-SmbShare 作为共享创建过程。以这种方式添加共享会绕过 GUI 向导正在执行的所有预配置检查,包括配额枚举。

    New-SmbShare -Name <ShareName> -ScopeName "<CAPName>" -Path "<LocalDirectoryToBeShared>" -FullAccess "Everyone" -Description "<Comment>"
    

    Server 2012 R2 / Windows 8.1 中引入了cmdlet New-SmbShare。对于以前(2012、2008R2、2008)版本的文件服务器集群,您可以借用从 Netapi32.dllNativeMethods中导入NetShareAdd函数的类,该脚本与MSDN 博客文章一起发布,关于 Fileover Cluster scopes 中的共享。

    我显着缩短的版本如下所示:

    #Using Win32 API NetShareAdd via p/invoke to be able to specify the scope in SHARE_INFO_503
    $signature = @"
    
        using System;
        using System.Runtime.InteropServices;
        using System.Collections;
    
        public class NativeMethods
        {
            [DllImport("Netapi32.dll")]
            public static extern uint NetShareAdd([MarshalAs(UnmanagedType.LPWStr)] string strServer, Int32 dwLevel, ref SHARE_INFO_503 buf, out uint parm_err);
    
            [StructLayoutAttribute(LayoutKind.Sequential)]
            struct SECURITY_DESCRIPTOR {
                public byte revision;
                public byte size;
                public short control;
                public IntPtr owner;
                public IntPtr group;
                public IntPtr sacl;
                public IntPtr dacl;
            }
    
            public enum SHARE_TYPE : uint
            {
                STYPE_DISKTREE = 0,
                STYPE_PRINTQ = 1,
                STYPE_DEVICE = 2,
                STYPE_IPC = 3,
                STYPE_SPECIAL = 0x80000000
            };
    
            [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
            public struct SHARE_INFO_503
            {
                public string shi503_netname;
                [MarshalAs(UnmanagedType.U4)]
                public SHARE_TYPE shi503_type;
                public string shi503_remark;
                [MarshalAs(UnmanagedType.U4)]
                public int shi503_permissions;
                [MarshalAs(UnmanagedType.U4)]
                public int shi503_max_uses;
                [MarshalAs(UnmanagedType.U4)]
                public int shi503_current_uses;
                public string shi503_path;
                public string shi503_passwd;
                public string shi503_servername;
                [MarshalAs(UnmanagedType.U4)]
                public int shi503_reserved;
                public IntPtr shi503_security_descriptor;
            }
    
    
            public static uint ShareFolder(string servername, string sharename, string path, string remark)
            {
                SHARE_INFO_503 shInfo = new SHARE_INFO_503();
                shInfo.shi503_netname = sharename;
                shInfo.shi503_type = SHARE_TYPE.STYPE_DISKTREE;
                shInfo.shi503_remark = remark;
                shInfo.shi503_permissions = 0;
                shInfo.shi503_max_uses = -1;
                shInfo.shi503_current_uses = 0;
                shInfo.shi503_path = path;
                shInfo.shi503_passwd = null;
                shInfo.shi503_servername = servername;
                shInfo.shi503_reserved = 0;
                shInfo.shi503_security_descriptor = IntPtr.Zero;
    
                uint nRetValue = 0;
                uint param_err = 0;
    
                nRetValue = NetShareAdd(servername, 503, ref shInfo, out param_err);
    
                //Console.WriteLine("Sharing " + path + " on " + servername + " as " + sharename + " returned " + nRetValue + " (" + param_err+ ")");
    
                return nRetValue;
            }
        }
    "@
    
    
    #Import the FailoverClusters PowerShell module if it is not already imported
    Import-Module FailoverClusters
    
    #Add the function type that will be used to share the folder in the defined scope
    Add-Type -TypeDefinition $signature
    

    用法很简单:

    [NativeMethods]::ShareFolder("<CAPname>", "<ShareName>", "<LocalDirectoryToBeShared>", "<Comment>")
    

    该ShareFolder函数在成功执行时返回 0 并立即完成,即使启用了配额也是如此。在托管 CAP/文件服务器资源的集群节点之一上运行。之后您可能必须修复共享 ACL,因为默认共享创建 ACL 只是Everyone:Read并且不能使用此方法指定。

    • 3

相关问题

  • 我在哪里可以找到 windows 2012 服务器(和 windows 8)上新安装的应用程序

  • ReFS 是否已准备好在 Hyper-V 2012 r2 群集上托管生产 VHDX?

  • Server 2012 重复数据删除:在 Hyper-V 主机或来宾 VM 上运行?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve