CẤU HÌNH HYPER-V REPLICA WITH SELF-SIGNED CERTIFICATES

Hyper-V Replica with self-signed certificates


Yêu cầu thực tế:
Có 02 Hyper-V server (workgroup):
O365-HOST01-SVR
O365-HOST02-SVR
Cấu hình replica cho 02 máy chủ Hyper-V

Phân tích:
Việc replica giữa các Hyper-V server có thể thực hiện qua http (80) hoặc https (443).
Đối với https thì cần có certicate chứng thực giữa các server.

Search google một vòng thì có khá nhiều bài viết hướng dẫn replicate (http hoặc https),  tạo self-signed certificates sử dụng công cụ MakeCert hoặc Powershell.

Tôi đã thử và....không thành công. :(

Ở  bài viết này, tôi chia sẻ cách làm thành công của bản thân bằng Powershell

Về Powershell thì có khác biệt khá lớn giữa Powershell 4.0 và Powershell 5.0

Tôi sẽ sử dụng lệnh New-SelfSignedCertificate trong Powershell 5.0 trên Windows 10.

Thực hiện:

1/ Tạo cert chứng thực:
powershell

###  Tạo root cert:
New-SelfSignedCertificate -Type "Custom" -KeyExportPolicy "Exportable" -Subject "CN=rep.365vnsysadmin.local" -CertStoreLocation "Cert:\LocalMachine\My" -KeySpec "Signature" -KeyUsage "CertSign"

   PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\My
Thumbprint                                Subject
----------                                -------
FB43F101DCE62A76724EA3C5C4A9FDFAC59306DC  CN=rep.365.vnsysadmin.local

###Tạo cert chứng thực cho O365-HOST01-SVR
New-SelfSignedCertificate -type "Custom" -KeyExportPolicy "Exportable" -Subject "CN=O365-HOST01-SVR" -CertStoreLocation "Cert:\LocalMachine\My" -KeySpec "KeyExchange" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2") -Signer "Cert:LocalMachine\My\FB43F101DCE62A76724EA3C5C4A9FDFAC59306DC" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"

   PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\My
Thumbprint                                Subject
----------                                -------
B9D01709D0D4F660AC2F53FC00BCE0CA37309E76  CN=O365-HOST01-SVR

######Tạo cert chứng thực cho O365-HOST02-SVR
New-SelfSignedCertificate -type "Custom" -KeyExportPolicy "Exportable" -Subject "CN=O365-HOST02-SVR" -CertStoreLocation "Cert:\LocalMachine\My" -KeySpec "KeyExchange" -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2") -Signer "Cert:LocalMachine\My\FB43F101DCE62A76724EA3C5C4A9FDFAC59306DC" -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"

   PSParentPath: Microsoft.PowerShell.Security\Certificate::LocalMachine\My
Thumbprint                                Subject
----------                                -------
918130D8ABCC6CA9899306759F73F0BC71F91E1F  CN=O365-HOST02-SVR


Kiểm tra trong Certificates (Local Computer) --- Personal -- Certicates sẽ thấy 03 cert vừa tạo.

3. Export certificates

- Export cert cho O365-HOST01-SVR/O365-HOST02-SVR

 Chọn lần lượt các cert của từng server (tạo ở trên) - click export - "Yes, export the private key" - Next (bỏ chọn  "Include all certificates in the certification path if possible". )
-- Finish.

- Export root cert, trong trường hợp này là rep.365.vnsysadmin.local


4. Import certificates cho 02 Hyper-V servers.

Trên lần lượt các Hyper-V servers, import lần lượt
Personal cert: Certificates (Local Computer) --- Personal -- Certicates
Trusted Root Certification Authorities  -- Certicates

Kiểm tra tình trạng cert cẩn thận sau khi import. :)

5. Thay đổi khóa registry "giúp" certicates có hiệu lực

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Virtualization\Replication" /v DisableCertRevocationCheck /d 1 /t REG_DWORD /f

6. Kiểm tra và cấu hình  certicate để Replica cho các Hyper-V server .



hoặc dùng Powershell:
PS C:\Users\Administrator> Get-ChildItem Cert:LocalMachine\My | fl Subject,Thumbprint

Subject    : CN=O365-HOST02-SVR
Thumbprint : 918130D8ABCC6CA9899306759F73F0BC71F91E1F



Set-VMReplicationServer –ReplicationEnabled $true -AllowedAuthenticationType Certificate -CertificateThumbprint "918130D8ABCC6CA9899306759F73F0BC71F91E1F" –ReplicationAllowedFromAnyServer $true –DefaultStorageLocation "D:\2.Backup\Replicate_Target"

7. Cấu hình cho phép các VM có thể Replication qua lại giữa các máy chủ Hyper-V

Chúc may mắn.  :)

http://blog.vnsysadmin.com/2016/12/hyper-v-replica-with-self-signed-certificates.html




Để bắt đầu tham gia Giao dịch tài chính:


Viết nhận xét

Các bạn có thể viết lời nhận xét cho bài viết, nhưng cần tuân thủ một số quy tắc sau:

» Các nhận xét/bình luận phải nghiêm túc, không dung tục, không spam.
» Nội dung phải liên quan tới chủ đề bài viết.
» Viết bằng tiếng việt có dấu hoặc tiếng Anh. Nội dung viết không dấu sẽ bị xóa.
» Hãy để lại tên của bạn khi nhận xét/bình luận, để tôi có thể dễ dàng trả lời bạn khi cần.

Chúc các bạn tìm được những kiến thức bổ ích khi tình cờ ghé thăm blog này.