Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlAGReplica: Support automatic seeding #487

Closed
randomnote1 opened this issue Apr 11, 2017 · 12 comments · Fixed by #1915
Closed

SqlAGReplica: Support automatic seeding #487

randomnote1 opened this issue Apr 11, 2017 · 12 comments · Fixed by #1915
Labels
enhancement The issue is an enhancement request.

Comments

@randomnote1
Copy link
Contributor

Details of the scenario you try and problem that is occurring:
xSQLServerAlwaysOnAvailabilityGroupReplica resource does not set the seeding_mode property in SQL 2016. This needs to be set to support automatic seeding.

The DSC configuration that is using the resource (as detailed as possible):
n/a

Version of the Operating System, SQL Server and PowerShell the DSC Target Node is running:
all

Version of the DSC module you're using, or 'dev' if you're using current dev branch:
dev

@randomnote1
Copy link
Contributor Author

I am unable to locate the seeding_mode property in SMO. So far the only place I've been able to locate it is in sys.availability_replicas.

@johlju johlju added enhancement The issue is an enhancement request. help wanted The issue is up for grabs for anyone in the community. labels Apr 11, 2017
@johlju
Copy link
Member

johlju commented Apr 13, 2017

Maybe this can be used. "Enable automatic seeding on an existing availability group" and "Stop automatic seeding" in this documentation.
https://docs.microsoft.com/en-us/sql/database-engine/availability-groups/windows/automatically-initialize-always-on-availability-group

I can't seem to find it in SMO either for SQL Server 2016.

@johlju
Copy link
Member

johlju commented Apr 13, 2017

I think the resource xSQLServerAlwaysOnAvailabilityGroup also need to have this parameter?

@johlju
Copy link
Member

johlju commented Apr 13, 2017

I also found this issue that could be good to know about when coding this
FIX: The SEEDING_MODE setting is ignored when you add an AlwaysOn AG replica to an existing AG in SQL Server 2016

@johlju
Copy link
Member

johlju commented Apr 13, 2017

For direct seeding, you must allow database creation on each secondary replica by calling ALTER AVAILABILITY GROUP with the GRANT CREATE ANY DATABASE option.
https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-availability-group-transact-sql

Sorry for all the comments. Just dumping new knowledge from my research. :) I was curious when the property was missing from SMO. :)

@randomnote1
Copy link
Contributor Author

No worries! I've been collecting stuff for this in the back of my head. Once I finish up the AG database resource, I'll wrap back around to this.

@Zuldan
Copy link

Zuldan commented Apr 13, 2017

@johlju here is a nice little blog from Mike Fal on how to setup direct seeding. At the end of the blog he points out there is no Powershell or SMO support (like you've already discovered). He does have the T-SQL code to get Direct Seeding going. Hope this helps.

http://www.mikefal.net/2016/06/14/tsql2sday-sql-2016-direct-seeding/

@johlju
Copy link
Member

johlju commented Apr 16, 2017

@randomnote1 Sounds great! Looking forward to both. 😄

@Zuldan Thanks for providing the blog article!

@johlju johlju changed the title xSQLServerAlwaysOnAvailabilityGroupReplica: Support automatic seeding SqlAGReplica: Support automatic seeding Dec 23, 2017
@stummsft
Copy link

stummsft commented Aug 7, 2018

As of SQL 2017, SMO now contains support for the Seeding mode properties and they work even against down-level managed servers. Since we try to import the SqlServer module, this should make it available even when running locally on down-level servers. The DSC resource should check if the "IsSeedingModeSupported" property exists and is set to $true, and if so set the .SeedingMode property to "Automatic" if it is specified in the resource configuration. Optionally, throw an error if the resource property is supplied as "Automatic" but either IsSeedingModeSupported does not exist or is equal to $false.

@codykonior
Copy link
Contributor

Having this is still desirable.

  • Add a SeedingMode property to SqlAG which will fill out the SMO property if it's available.
  • Any replica where SeedingMode = 'Auto' the ALTER AVAILABILITY GROUP GRANT CREATE ANY DATABASE will also be run on that replica.

So for setting up a new AG and adding in other AGs it will all work. For edge cases where SMO is out of date, or the server is unpatched, or down-level, that's not this resource's problem.

@garentsen
Copy link

when will this feature become available?

@johlju
Copy link
Member

johlju commented Feb 2, 2021

As soon as someone in the community send in a PR I'm happy to review a change that supports this. This open for anyone in the community to pick up.

johlju pushed a commit that referenced this issue May 4, 2023
- SqlAg
  - Added optional parameter `SeedingMode` that will set the SeedingMode for the
    SQL Server 2016 and higher. This parameter can only be used together with the
    module _SqlServer_ installed (tested  v21.0.17099). The parameter will be
    ignored if SQLPS module will be used.
- SqlAgReplica
  - Added optional parameter `SeedingMode` that will set the SeedingMode for the
    SQL Server 2016 and higher (issue #487).
    This parameter can only be used together with the module _SqlServer_ installed
    (tested v21.0.17099). The parameter will be ignored if SQLPS module will be
    used.
@johlju johlju removed the help wanted The issue is up for grabs for anyone in the community. label May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants