Thiết kế hệ thống chuyên nghiệp OceanTech-Group

Chuyên thiết kế hệ thống Active Directory (AD), Email, Eco-System , Automation Interate System cho các doanh nghiệp vừa và nhỏ, cá nhân có nhu cầu kinh doanh…

GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T

NSX-T là gì? Tìm hiểu nền tảng ảo hóa mạng VMware NSX-T – OceanTech Group


Bạn đang thắc mắc NSX-T là gì? VMware NSX-T là nền tảng ảo hóa mạng giúp doanh nghiệp xây dựng hạ tầng mạng linh hoạt, bảo mật cao cho Data Center, Cloud và Kubernetes.


Giới thiệu nền tảng ảo hóa VMware NSX-T


Khi tìm hiểu NSX-T là gì, có thể thấy đây là nền tảng quan trọng trong Software-Defined Data Center (SDDC). Dưới đây là những thông tin chi tiết giúp bạn nắm vững về giải pháp này.

I. Giới thiệu VMware NSX-T

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 1-24f243b6-cc80-4ca4-a13d-b28b25cda054 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

VMware NSX-T Data Center là giải pháp ảo hóa hạ tầng mạng và bảo mật cho các Virtual Machine (ESXi, KVM) trên Server vật lý. Những điểm nổi bật của NSX-T là gì?

  • NSX-T là phiên bản thế hệ tiếp theo của VMware NSX (NSX-V) với khả năng tích hợp Kubernetes (K8S).
  • Cung cấp giải pháp bảo mật “Full Stack Layer 2 to Layer 7 Platform”.
  • Hỗ trợ hệ thống Software-Defined Data Center (SDDC) với 3 mặt phẳng: Control, Data và Management Plane.
  • Sử dụng giao thức đóng gói dữ liệu mới GENEVE (mạnh mẽ hơn VXLAN).
  • Triển khai dễ dàng qua file OVA/OVF trên ESXi hoặc KVM.

II. Kiến trúc VMware NSX-T Architecture

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2-f6c3f568-4e77-45a6-8797-197cc83db107 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Kiến trúc của VMware NSX-T hoạt động theo mô hình SDN (Software Defined Networking) gồm có Control Plane, Data Plane và Management Plane.

1. Management Plane

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 3-6ceac2f3-92b9-44bb-8fe0-026299864b89 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Management Plane cung cấp giao diện để người dùng tương tác. NSX-T Manager đóng vai trò là Entry Point quản lý qua WEB GUI hoặc RESTful API. Hệ thống yêu cầu Cluster 3 Node để đảm bảo tính dự phòng cao.

2. Control Plane

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 4-2d6d5db0-b284-4aca-9707-d08392b64a69 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Control Plane điều phối cấu hình từ Management xuống Data Plane. VMware chia thành phần này thành Central Control Plane (CCP) và Local Control Plane (LCP) chạy trên các Transport Node.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 5-b66f8476-024d-42d8-a81c-c55104433874 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Từ phiên bản NSX-T 3.0 trở đi, VMware đã kết hợp Manager và Controller thành một Appliance duy nhất để tối ưu hiệu năng.

3. Data Plane

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 6-f611a01f-9ac6-4e9e-b794-6eb55ae2a454 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Data Plane thực hiện chuyển tiếp gói tin. Các Edge Transport Nodes cung cấp dịch vụ mạng tập trung như Routing, NAT, DHCP, và Load Balancing trong hạ tầng ảo.

III. Khái niệm Segment, Transport Zone và Uplink

1. Segment và Transport Zone

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 7-224a9382-fe94-453f-a4b3-ed4148c5b02d GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Trong VMware NSX-T, Segment là phân đoạn mạng ảo (Logical Switch), còn Transport Zone là mặt phẳng chứa các Segment đó.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 8-3d7acd76-5568-411f-8a38-f2f237788a28 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI
Thiết kế hệ thống chuyên nghiệp OceanTech-Group 9-f5f5f622-107a-4dd8-ad82-c25062e45d2f GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Các gói tin Overlay sẽ được truyền tải qua Tunnel GENEVE, giúp kết nối các VM thuộc các Hypervisor khác nhau một cách tự động và bảo mật.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 10-dca88557-017c-4b64-8ea1-48a72144c264 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI
Thiết kế hệ thống chuyên nghiệp OceanTech-Group 11-07561d9d-82f5-4fe4-89a9-640f523d1498 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

2. Uplink và pNIC

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 12-69af7a10-0d77-4030-8d14-3946ea271d08 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Hệ thống định nghĩa Card mạng vật lý là pNICs. Thông qua Uplink Profile, quản trị viên có thể thiết lập các chính sách Teaming (Failover hoặc Load Balance) để tối ưu đường truyền.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 13-0ae7a8e7-3c6a-4bbe-b0c2-2b5b982e98c7 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI
Thiết kế hệ thống chuyên nghiệp OceanTech-Group 14-fa0978ad-3049-4a21-92ae-e29d52896c12 GIỚI THIỆU NỀN TẢNG ẢO HÓA VMWARE NSX-T Thủ thuật VMWARE NSX-T VMWARE ESXI

Qua bài viết này, hy vọng bạn đã hiểu rõ NSX-T là gì và những lợi ích vượt trội mà VMware NSX-T mang lại cho hạ tầng doanh nghiệp.

Bạn có thể tham khảo thêm tại: Tài liệu kỹ thuật VMware

Tham khảo thêm các dịch vụ của chúng tôi: Giải Pháp Ảo Hoá OceanTech


Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn

Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn


 
Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-bia Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache Mesos

Công nghệ Docker đã tạo ra một cuộc cách mạng đối với  quản lý cơ sở hạ tầng, để bây giờ Docker đã trở thành một từ “đồng nghĩa” với containers. Có một điều quan trọng cần nhớ là tất cả các docker đều là container nhưng không phải container nào cũng là docker. Trong khi docker là công nghệ container được sử dụng phổ biến nhất, nó cũng có thể được thay thế bởi một số lựa chọn khác. Trong bài viết này, chúng ta sẽ cùng khám phá các lựa chọn thay thế Docker cho ứng dụng SaaS.

Docker là gì?

Docker được coi là một application containerization platform phổ biến trong giới IT. Phần mềm mã nguồn mở này cho phép các nhà phát triển dễ dàng kết hợp các ứng dụng cùng với các thành phần phụ thuộc (dependencies), hệ điều hành, thư viện và các tài nguyên liên quan đến run-time khác trong containers và tự động triển khai chúng trên bất kỳ cơ sở hạ tầng nào. Khi kiến trúc native-cloud và môi trường multi-cloud đang trở thành lựa chọn phổ biến cho hầu hết các tổ chức. Docker là lựa chọn thuận tiện nhất để xây dựng, chia sẻ, triển khai và quản lý Container bằng cách sử dụng API và các lệnh đơn giản trong các môi trường này.

Docker hoạt động như thế nào?

Docker ban đầu được tạo cho nền tảng Linux. Tuy nhiên, nó hiện đã hỗ trợ Apple OS X và các môi trường Windows. Không giống như các máy ảo đóng gói toàn bộ hệ điều hành, Docker cô lập các tài nguyên trong lõi hệ điều hành, cho phép bạn chạy nhiều container trong cùng một hệ điều hành. Docker Engine là thành phần chính của hệ sinh thái Docker. Công cụ Docker tạo ra một daemon phía máy chủ và một CLI phía máy khách. Daemon phía máy chủ lưu trữ các Container, hình ảnh, dữ liệu và hình ảnh mạng trong khi CLI phía máy khách cho phép bạn giao tiếp với máy chủ bằng các API. Các Container Docker được gọi là Dockerfiles.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-1-1 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache MesosCác tính năng/lợi ích của Docker

Docker cung cấp nhiều lợi ích khác nhau cho các tổ chức. Dưới đây là một số lợi ích chính được cung cấp bởi công cụ này:

Tăng năng suất

So với máy ảo, Docker container dễ xây dựng, triển khai và quản lý hơn. Chúng bổ sung cho kiến ​​trúc cloud-native và CI/CD pipelines dựa trên DevOps, từ đó giúp các nhà phát triển cung cấp phần mềm chất lượng nhanh hơn.

Di chuyển liền mạch trên các cơ sở hạ tầng

Trái ngược với các Linux containers sử dụng các cấu hình dành riêng cho máy, các Docker containers là machine-agnostic, platform-agnostic và OS-agnostic. Do đó, chúng có thể dễ dàng di chuyển qua bất kỳ cơ sở hạ tầng nào.

Container có dung lượng nhẹ 

Mỗi Docker container chứa một quy trình duy nhất làm cho nó cực kỳ nhẹ. Đồng thời, nó cho phép bạn cập nhật ứng dụng một cách chi tiết. Bạn có thể chỉnh sửa/sửa đổi một quy trình nhất định mà không cần gỡ ứng dụng xuống.

Tự động tạo Container

Docker có thể lấy mã nguồn ứng dụng của bạn và tự động tạo container. Nó cũng có thể lấy container hiện có làm mẫu image nền tảng và tạo lại các container cho phép bạn sử dụng lại. Nó cũng đi kèm với một versioning mechanism, có nghĩa là mỗi Docker image có thể được cuộn lại một cách dễ dàng.

Tối ưu hóa chi phí

Khả năng chạy nhiều mã hơn trên mỗi máy chủ cho phép bạn tăng năng suất với chi phí tối thiểu. Sử dụng tối ưu các nguồn lực sẽ giúp tiết kiệm chi phí. Ngoài ra, các hoạt động được tiêu chuẩn hóa cho phép tự động hóa, tiết kiệm thời gian và nguồn nhân lực giúptiết kiệm chi phí.

Hỗ trợ rộng rãi 

Docker nhận được sự hỗ trợ lớn của cộng đồng. Bạn được hưởng lợi ích của hàng nghìn containers do người dùng tải lên trong sổ đăng ký mã nguồn mở thay vì dành thời gian tạo lại từ đầu.

Tại sao Microservices tốt hơn Kiến trúc Monolith?

Kiến trúc Microservices đã trở thành kiến ​​trúc chủ đạo trong thời gian gần đây. Trước khi hiểu tầm quan trọng của Microservices, điều quan trọng là phải biết những mặt trái của kiến ​​trúc nguyên khối (Kiến trúc Monolith). Theo truyền thống, các tổ chức sử dụng một kiến ​​trúc nguyên khối để xây dựng các ứng dụng. Kiến trúc này sử dụng mô hình thác nước để phát triển phần mềm, trong đó phần mềm được thiết kế và phát triển trước. Sau đó, code được gửi đến nhóm QA để thử nghiệm. Khi phát hiện ra lỗi, code sẽ được gửi lại cho developers. Sau khi thử nghiệm thành công, code được đẩy sang môi trường thử nghiệm và sau đó là môi trường sản xuất trực tiếp. Đối với bất kỳ thay đổi hoặc cập nhật code nào, bạn phải lặp lại toàn bộ quy trình.

Khi bạn xem xét phần mềm nguyên khối từ góc độ logic, bạn sẽ tìm thấy 3 lớp: lớp giao diện người dùng, lớp nghiệp vụ và lớp dữ liệu. Khi người dùng đưa ra yêu cầu, lớp nghiệp vụ chạy logic nghiệp vụ, lớp dữ liệu quản lý dữ liệu và lớp giao diện hiển thị nó cho người dùng. Mã liên quan đến cả 3 lớp được duy trì trong một codebase duy nhất. Mọi cam kết thay đổi sẽ diễn ra đối với cùng một codebase. Khi codebase phát triển, sự phức tạp trong việc quản lý nó cũng tăng theo. Khi một nhà phát triển đang làm việc trên một tính năng, anh ta phải kéo toàn bộ code vào máy cục bộ để làm cho nó hoạt động. Hơn nữa, mỗi thay đổi đều phải tạo ra các artifacts. Vấn đề lớn nhất là sự phối hợp nhịp nhàng giữa các đội nhóm. Kiến trúc nguyên khối không linh hoạt, không có khả năng mở rộng và đắt đỏ. Kiến trúc Microservices giải quyết tất cả những thách thức này.

Kiến trúc microservices tạo điều kiện cho phương pháp tiếp cận phát triển phần mềm cloud-native, trong đó phần mềm được phát triển dưới dạng các microservices có thể triển khai độc lập, rời rạc, giao tiếp với nhau thông qua các API. Mỗi dịch vụ đi kèm với stack công nghệ có thể được phân loại theo khả năng kinh doanh, cho phép bạn cập nhật độc lập hoặc mở rộng các thành phần một cách dễ dàng.

Microservices sử dụng kiến ​​trúc cloud-native rất phù hợp để phân phối liên tục dựa trên DevOps. Khi mỗi ứng dụng chạy bên trong container, bạn có thể dễ dàng thực hiện các thay đổi đối với ứng dụng bên trong container mà không cần phân phối cơ sở hạ tầng bên dưới, đạt được 99,99% thời gian hoạt động. Môi trường CI/CD và khả năng dễ dàng di chuyển ứng dụng giữa các môi trường khác nhau giúp rút ngắn thời gian phát hành ra thị trường. Nó cũng mang lại sự linh hoạt để theo dõi xu hướng thị trường và nhanh chóng thực hiện các thay đổi đối với ứng dụng của bạn, từ đó duy trì tính cạnh tranh.

Khi mỗi ứng dụng chạy trong một container riêng biệt, các nhà phát triển có quyền lựa chọn nhiều công nghệ đa dạng để xây dựng phần mềm chất lượng thay vì bị mắc kẹt với một công cụ duy nhất chuyên biệt cho một chức năng cụ thể. Điều này cũng đồng thời tối ưu hóa chi phí.

Microservices và Docker

Mặc dù microservices mang lại nhiều lợi ích cho các tổ chức tuy nhiên kiến trúc này cũng kèm với một số hạn chế nhất định. Một trong những hạn chế với người dùng lớn nhất dạng kiến trúc này gặp phải là yêu cầu theo dõi các dịch vụ được phân phối trên nhiều máy chủ. Khi microservices được mở rộng, số lượng dịch vụ hoạt động trên kiến trúc càng tăng. Như vậy, người sử dụng cần lưu ý phân bổ tài nguyên cẩn thận cho từng máy chủ nhỏ hơn. Tuy nhiên một số dịch vụ nhất định có quy mô quá nhỏ thường không sử dụng đầy đủ phiên bản AWS EC2, gây lãng phí tài nguyên và dẫn đến tăng chi phí tổng thể. Ngoài ra, kiến ​​trúc microservices bao gồm nhiều dịch vụ được phát triển bằng nhiều ngôn ngữ lập trình, framework làm việc. Việc phải triển khai nhiều mã microservices, library và framework khác nhau làm tăng độ phức tạp và chi phí cho người sử dụng. Công nghệ Docker giải quyết tất cả những thách thức kể trên bằng cách cung cấp giải pháp đa dạng và thân thiện với người dùng hơn.

Docker cho phép người dùng đóng gói từng microservice vào các container riêng biệt. Bạn có thể chạy nhiều container cho một phiên bản duy nhất, loại bỏ các vấn đề cấp phép quá mức. Docker hỗ trợ lưu trữ dữ liệu trừu tượng bằng cách lưu các dữ liệu ấy trên một container và tham chiếu nó từ các container khác. Một ưu điểm khác của phương pháp này là lưu trữ dữ liệu liên tục, trong đó dữ liệu được lưu trữ riêng biệt ngay cả sau khi bạn phá hủy container. Cách tiếp cận tương tự có thể được áp dụng cho các ngôn ngữ lập trình. Bạn có thể nhóm các library và framework cần thiết cho một ngôn ngữ và đóng gói chúng bên trong một Container và liên kết nó với các Container được yêu cầu để quản lý hiệu quả các giải pháp đa nền tảng. Bằng cách sử dụng công cụ giám sát nhật ký, bạn có thể theo dõi nhật ký của từng Container để có được thông tin chi tiết rõ ràng về luồng dữ liệu và hiệu suất ứng dụng.

Tại sao các nhà quản lý CNTT lại tìm kiếm các lựa chọn thay thế cho Docker?

Mặc dù Docker là công nghệ container hóa phổ biến nhất, tuy nhiên cũng bắt đầu xuất hiện các nhà quản lý CNTT tìm kiếm các giải pháp thay thế Docker. Có một số lý do để họ làm như vậy:

Thứ nhất, Docker không dễ sử dụng. Có khá nhiều vấn đề mà quản trị viên phải xử lý. Ví dụ, giám sát hiệu suất ứng dụng không xuất hiện. Trong khi Docker cung cấp các số liệu thống kê cơ bản, nhà quản lý cần tích hợp các công cụ của bên thứ 3 cho mục đích này. Thứ hai, lưu trữ dữ liệu liên tục không đơn giản, có nghĩa là nhà quản lý phải tự di chuyển dữ liệu ra bên ngoài Container và lưu trữ nó một cách an toàn. Thứ ba, điều phối Container đòi hỏi một lượng kiến ​​thức chuyên môn đáng kể trong việc định cấu hình và quản lý một công cụ điều phối như Docker Swarm, Kubernetes hoặc Apache Mesos. Thứ tư, các container docker yêu cầu nhiều lớp hơn để được bảo đảm khi so sánh với một ngăn xếp truyền thống. Tất cả những yếu tố này làm tăng thêm gánh nặng hành chính cho nhà quản lý. Nếu không hiểu đúng về công cụ này, việc chạy Docker sẽ trở nên phức tạp và tốn kém. Tuy nhiên, những lợi ích của Docker lớn hơn những nhược điểm nhỏ này. Thời gian và nỗ lực dành cho việc tìm hiểu Docker sẽ mang lại cho các nhà quản lý lợi ích lớn về lâu dài.

Dưới đây là 10 lựa chọn thay thế docker hàng đầu cho ứng dụng SaaS:

Giải pháp thay thế Docker số 1: Kiến trúc phi máy chủ (Serverless Architecture)

Kiến trúc không máy chủ là một giải pháp thay thế phổ biến cho công nghệ chứa Docker. Như tên đã chỉ ra, kiến ​​trúc không máy chủ loại bỏ nhu cầu quản lý máy chủ hoặc cơ sở hạ tầng cơ bản để chạy ứng dụng. Điều này không có nghĩa là máy chủ là không cần thiết nhưng công việc đó được xử lý thay thế bởi nhà cung cấp đám mây. Các nhà phát triển có thể chỉ cần viết một code ứng dụng, đóng gói nó và triển khai nó trên bất kỳ nền tảng nào. Họ có thể chọn mua các dịch vụ phụ trợ cụ thể cần thiết cho ứng dụng và triển khai nó trên nền tảng được yêu cầu.

Kiến trúc không máy chủ loại bỏ gánh nặng quản lý cơ sở hạ tầng hoặc sự phức tạp về cấu hình Docker / Kubernetes, khả năng mở rộng và nâng cấp để cung cấp thời gian nhanh hơn cho thị trường. Khả năng kích hoạt các sự kiện làm cho nó trở thành một lựa chọn tốt cho các quy trình làm việc theo trình tự và các CI / CD pipelines . Một trong những lợi thế lớn nhất của điện toán không máy chủ là bạn có thể mở rộng các ứng dụng vượt quá khả năng của nhà cung cấp đám mây.

Tính linh hoạt để mua các chức năng cụ thể cần thiết cho ứng dụng làm giảm đáng kể chi phí. Ví dụ: khi bạn chạy các Container docker và gặp phải lưu lượng truy cập tăng đột biến không thể đoán trước, bạn sẽ phải tăng dung lượng môi trường ECS. Tuy nhiên, bạn sẽ phải trả nhiều hơn cho các Container dịch vụ bổ sung và các bản sao Container. Với một doanh nghiệp SaaS, tối ưu hóa chi phí luôn được ưu tiên hàng đầu. Khi bạn triển khai kiến ​​trúc không máy chủ bằng AWS Lambda, bạn sẽ chỉ thay đổi quy mô các chức năng được yêu cầu trong thời gian chạy ứng dụng chứ không phải toàn bộ cơ sở hạ tầng. Bằng cách đó, bạn có thể tối ưu hóa chi phí. Hơn nữa, nó hợp lý hóa quá trình triển khai cho phép bạn triển khai nhiều dịch vụ mà không cần cấu hình phức tạp. Vì bạn có thể chạy code từ mọi nơi, bạn có thể chọn sử dụng máy chủ gần nhất và giảm độ trễ.

Mặt khác, việc khắc phục sự cố ứng dụng trở nên phức tạp khi ứng dụng phát triển khi bạn không biết điều gì đang xảy ra bên trong. Vì lý do này, serverless được gọi là công nghệ hộp đen. Điều quan trọng là phải thiết kế chiến lược ứng dụng phù hợp. Nếu không, bạn sẽ phải trả nhiều hơn cho chi phí nhân lực đắt đỏ. Autodesk, Droplr, PhotoVogue và AbstractAI là một vài ví dụ về các công ty sử dụng mô hình phi máy chủ.

Giải pháp thay thế Docker số 2: Virtual Machines (VM) từ VMware

Triển khai máy ảo từ VMware là một giải pháp thay thế khác cho Docker. VMware dẫn đầu trong phân khúc ảo hóa. Trong khi Docker trừ tượng tài nguyên ở cấp hệ điều hành, VMware ảo hóa lớp phần cứng. Một trong những dịch vụ quan trọng của VMware là bộ vSphere chứa các công cụ khác nhau để hỗ trợ hệ điều hành ảo hóa điện toán đám mây. vSphere sử dụng ESXi là trình siêu giám sát cho phép nhiều hệ điều hành chạy trên một máy chủ duy nhất. Vì vậy, mỗi hệ điều hành chạy với các tài nguyên chuyên dụng của nó.

Khi nói đến quá trình chứa, VMware ảo hóa phần cứng cùng với các tài nguyên bên dưới, có nghĩa là chúng không hoàn toàn bị cô lập. So với Docker, VMware VMs tốn nhiều tài nguyên hơn và không nhẹ và di động. Đối với các ứng dụng yêu cầu máy chủ đầy đủ, VMware hoạt động tốt nhất. Mặc dù các ứng dụng Docker nhẹ và chạy nhanh hơn, nhưng VMware đang nhanh chóng bắt kịp. Các phiên bản ESXi hiện tại ngang bằng hoặc hơn hẳn những chiếc máy trần.

Có nhiều tùy chọn để sử dụng VMware cho các nhiệm vụ ảo hóa (containerization). Ví dụ, bạn có thể cài đặt VMware vSphere ESXi hypervisor và sau đó cài đặt bất kỳ hệ điều hành nào lên trên nó. Photon là một hệ điều hành tập trung vào Container mã nguồn mở được cung cấp bởi VMware. Nó được tối ưu hóa cho các nền tảng đám mây như Google Compute Engine và Amazon Elastic Compute. Nó cung cấp một hệ thống quản lý vòng đời được gọi là tdnf dựa trên gói và tương thích với yum. Các ứng dụng Photon nhẹ, khởi động nhanh hơn và tiêu tốn ít dấu vết hơn. Ngoài ra, bạn có thể chạy bất kỳ bản phân phối Linux nào trên ESXi và chạy các Container bên trong Hệ điều hành.

Docker container chứa nhiều lớp hơn cần được bảo mật khi so sánh với máy ảo VMware. Đối với các môi trường yêu cầu bảo mật cao và lưu trữ liên tục, VMware là một lựa chọn tốt. Máy ảo VMware phù hợp nhất để ảo hóa máy trong môi trường IaaS. Mặc dù các máy ảo VMware có thể được sử dụng làm lựa chọn thay thế cho Docker, nhưng chúng không phải là công nghệ cạnh tranh và bổ sung cho nhau. Để tận dụng tối đa cả hai thế giới, bạn có thể chạy các Container Docker bên trong máy ảo VMware, làm cho nó siêu nhẹ và có tính di động cao.

Giải pháp thay thế Docker số 3: Các phiên bản đơn lẻ từ AWS, Azure và GCP

Một giải pháp thay thế khác cho Docker là triển khai các ứng dụng nguyên khối của bạn bằng cách sử dụng các phiên bản AWS hoặc máy ảo Azure và GCP. Khi bạn triển khai một phiên bản AWS EC2, nó sẽ cài đặt các thành phần cơ bản của HĐH và các gói bắt buộc khác. Bạn có thể sử dụng Amazon Machine Image (AMI) để tạo máy ảo trong phiên bản EC2. Chúng chứa các hướng dẫn để khởi chạy một phiên bản. AMI nên được nhà phát triển chỉ định trong AWS. Có các AMI được cấu hình sẵn cho các trường hợp sử dụng cụ thể. Bạn có thể sử dụng Amazon ECS cho mục đích điều phối. Hình ảnh AWS AMI không nhẹ khi so sánh với Container Docker.

Giải pháp thay thế Docker số 4: Apache Mesos

Apache Mesos là phần mềm quản lý trung tâm dữ liệu và Container mã nguồn mở được phát triển bởi Apache Software Foundation. Nó trước đây được gọi là Nexus. Mesos được viết bằng C ++. Nó hoạt động như một công cụ trừu tượng tách các tài nguyên ảo khỏi phần cứng vật lý và cung cấp tài nguyên cho các ứng dụng chạy trên đó. Bạn có thể chạy các ứng dụng như Kubernetes, Elastic Search, Hadoop, Spark, v.v. trên Mesos.

Mesos được tạo ra như một công cụ quản lý cụm tương tự như Tupperware và Borg nhưng khác ở chỗ nó là mã nguồn mở. Nó sử dụng một kiến ​​trúc mô-đun. Một tính năng quan trọng của Mesos là nó tóm tắt các tài nguyên của trung tâm dữ liệu trong khi nhóm chúng thành một nhóm duy nhất, cho phép quản trị viên quản lý hiệu quả các nhiệm vụ phân bổ tài nguyên trong khi mang lại trải nghiệm người dùng nhất quán và vượt trội. Nó cung cấp khả năng mở rộng cao hơn, trong đó bạn có thể thêm các ứng dụng và công nghệ mới mà không làm ảnh hưởng đến các cụm. Nó đi kèm với một môi trường tự phục hồi và chịu lỗi được cung cấp bởi Zookeeper. Nó làm footprint  và tối ưu hóa tài nguyên bằng cách cho phép bạn chạy các khối lượng công việc đa dạng trên cùng một cơ sở hạ tầng. Ví dụ,

Apache Mesos cho phép bạn chạy một tập hợp đa dạng khối lượng công việc trên đó bao gồm cả điều phối Container. Đối với điều phối Container, Mesos sử dụng một khuôn khổ điều phối được gọi là Marathon. Nó có thể dễ dàng chạy và quản lý khối lượng công việc quan trọng của sứ mệnh, điều này làm cho nó trở thành một ứng dụng yêu thích cho kiến ​​trúc doanh nghiệp.

Mesos không hỗ trợ khám phá dịch vụ. Tuy nhiên, bạn có thể sử dụng các ứng dụng chạy trên Mesos như Kubernetes cho mục đích này. Nó phù hợp nhất cho các môi trường trung tâm dữ liệu liên quan đến cấu hình phức tạp của một số cụm Kubernetes. Nó được phân loại là một công cụ quản lý cụm và cho phép các tổ chức chạy, xây dựng và quản lý các hệ thống phân tán tiết kiệm tài nguyên. Mesos cho phép bạn tách biệt các tác vụ trong Container Linux và nhanh chóng mở rộng quy mô lên hàng trăm và hàng nghìn node. Mở rộng quy mô dễ dàng là điểm khác biệt của nó với Docker.

Nếu bạn muốn chạy một tập hợp khối lượng công việc quan trọng và đa dạng trên một nền tảng đáng tin cậy cùng với khả năng di động qua các đám mây và trung tâm dữ liệu, thì Mesos là một lựa chọn tốt. Twitter, Uber, Netflix và Apple (Siri) là một số doanh nghiệp phổ biến sử dụng Apache Mesos.

Giải pháp thay thế Docker số 5: Công nghệ Cloud Foundry Container 

Cloud Foundry là một sản phẩm cung cấp Nền tảng như một dịch vụ (PaaS) mã nguồn mở được quản lý bởi Cloud Foundry Foundation. Công cụ này được viết bằng Ruby, Go và Java bởi các kỹ sư của VMware và được phát hành vào năm 2011. Cloud Foundry nổi tiếng nhờ hỗ trợ phân phối liên tục, tạo điều kiện cho việc quản lý vòng đời sản phẩm. Kiến trúc dựa trên bộ chứa của nó nổi tiếng với môi trường đa đám mây vì nó tạo điều kiện thuận lợi cho việc triển khai các bộ chứa trên bất kỳ nền tảng nào đồng thời cho phép bạn di chuyển liền mạch khối lượng công việc mà không làm ảnh hưởng đến ứng dụng.

Tính năng chính của Cloud Foundry là tính dễ sử dụng cho phép tạo mẫu nhanh chóng. Nó cho phép bạn viết và chỉnh sửa code từ bất kỳ IDE cục bộ nào và triển khai các ứng dụng được chứa trong Container lên đám mây. Cloud Foundry chọn gói xây dựng phù hợp và tự động định cấu hình nó cho các ứng dụng đơn giản. Công cụ này giới hạn số lượng cổng đã mở để tăng cường bảo mật. Nó hỗ trợ định tuyến động cho hiệu suất cao. Theo dõi tình trạng ứng dụng và khám phá dịch vụ xuất hiện ngay từ đầu.

Cloud Foundry sử dụng định dạng Container riêng có tên là Garden và công cụ điều phối Container có tên Diego. Tuy nhiên, khi Docker trở nên phổ biến và phần lớn người dùng bắt đầu sử dụng bộ chứa docker, Cloud Foundry phải hỗ trợ Docker. Để làm như vậy, nó đã đóng gói các bộ chứa docker ở định dạng Garden image. Tuy nhiên, không dễ dàng để chuyển những container đó sang các động cơ điều phối khác. Một thách thức khác đối với Cloud Foundry là Kubernetes. Trong khi Cloud Foundry hỗ trợ các ứng dụng không trạng thái (stateless), Kubernetes đủ linh hoạt để hỗ trợ các ứng dụng trạng thái (stateful) và không trạng thái. Tuân theo sở thích của người dùng, Cloud Foundry đã thay thế công cụ điều phối Diego bằng Kubernetes. Không có thời gian chạy Container và nền tảng điều phối, hệ sinh thái Container của Cloud Foundry trở nên ít liên quan hơn.  Chính sự thất bại của Cloud Foundry nhấn mạnh tầm quan trọng của việc làm cho một tổ chức có thể chứng minh được tương lai. Nó cũng nhấn mạnh tầm quan trọng của việc sử dụng các giải pháp Docker và Kubernetes.

Giải pháp thay thế Docker số 6: Rkt từ CoreOS

Rkt từ CoreOS là một giải pháp thay thế phổ biến cho công nghệ Container Docker. Rkt đã được giới thiệu vào năm 2014 như một công nghệ container có thể tương tác, mã nguồn mở và an toàn. Trước đây nó được gọi là CoreOS Rocket. Rkt đi kèm với một hệ sinh thái mạnh mẽ và cung cấp hỗ trợ container end-to-end, khiến nó trở thành một đối thủ nặng ký trong phân khúc container hóa.

Các bản phát hành ban đầu của Docker chạy dưới quyền root, cho phép tin tặc có được các đặc quyền của người dùng cấp cao khi hệ thống bị xâm phạm. Rkt được thiết kế với sự chú ý đến bảo mật và kiểm soát chi tiết. Rkt sử dụng định dạng Container appt và có thể dễ dàng tích hợp với các giải pháp khác. Nó sử dụng Pods cho cấu hình Container và khung gRPC cho các API RESTful. Hỗ trợ Kubernetes sẵn có. Bạn có thể quản lý các thùng chứa một cách trực quan.

Rkt cung cấp một hệ sinh thái công nghệ container toàn diện.. Sự hỗ trợ của cộng đồng là tốt. Mặc dù công cụ này là mã nguồn mở và miễn phí, nhưng Rkt sẽ tính phí hỗ trợ. Ví dụ, hỗ trợ của Kubernetes là $ 3000 cho 10 máy chủ. Verizon, Salesforce.com, CA Technologies và Viacom là một số doanh nghiệp nổi bật sử dụng CoreOS Rkt.

Mặc dù Rkt trở nên phổ biến trong một thời gian ngắn, nhưng tương lai của nó hiện đang chìm trong bóng tối. Vào năm 2018, RedHat đã mua lại CoreOS. Kể từ đó, Rkt mất phương hướng. Thêm vào tai ương của nó là việc rút hỗ trợ của Cloud Native Computing Foundation (CNCF) vào năm 2019. Trang Rkt Github cho thấy rằng dự án đã kết thúc. Là một dự án mã nguồn mở, bất kỳ ai cũng có thể phân nhánh nó để phát triển dự án mã của riêng họ.

Giải pháp thay thế Docker số 7: LXD

LXD là trình quản lý Container và máy ảo được cung cấp bởi công nghệ Container Linux (LXC) và được quản lý bởi Canonical Ltd., một công ty phần mềm có trụ sở tại Vương quốc Anh. Nó cho phép quản trị viên cung cấp trải nghiệm người dùng thống nhất và vượt trội trên hệ sinh thái Linux của VMs và Container. LXD được viết bằng Go và sử dụng daemon đặc quyền có thể được truy cập từ CLI thông qua API REST bằng các lệnh đơn giản. LXD tập trung vào ảo hóa hệ điều hành, cho phép bạn chạy nhiều máy ảo hoặc quy trình bên trong một Container. Ví dụ: bạn có thể chạy các máy chủ Linux, Apache, MySQL và PHP bên trong một Container duy nhất. Bạn cũng có thể chạy các Container Docker lồng nhau. Vì nó chạy các máy ảo khởi động khá nhanh nên nó tiết kiệm chi phí khi so sánh với các máy ảo thông thường. LXD giống một hệ điều hành độc lập hơn mang lại lợi ích của cả Container và máy ảo.

Vì nó sử dụng OS image đầy đủ với các phần phụ thuộc vào mạng và bộ nhớ, nên nó kém di động hơn khi so sánh với Docker. LXD cung cấp các tùy chọn hạn chế khi nói đến khả năng tương tác. Bạn có thể tích hợp nó với ít công nghệ hơn như OpenNebula hoặc OpenStack. LXD chỉ chạy trên các bản phân phối Linux và nó không hỗ trợ nền tảng Windows. LXD sử dụng Ubuntu và Ubuntu-daily image cho các bản phân phối Ubuntu. Đối với các bản phân phối khác, nó sử dụng máy chủ hình ảnh công khai .

Giải pháp thay thế Docker số 8: Podman

Podman là một công nghệ container phổ biến đang nhanh chóng hoàn thiện để cạnh tranh với Docker. Không giống như Docker sử dụng daemon để quản lý các Container, Podman tiếp cận các Container bằng một công nghệ không có Daemon gọi là Conmon để xử lý các tác vụ tạo Container, lưu trữ trạng thái và lấy các Container image, v.v. Khả năng này giúp quản lý nhiều Container bên ngoài sử dụng các lệnh cấp pod là điều làm cho Podman trở nên đặc biệt. So với công nghệ Docker, Conmon sử dụng ít bộ nhớ hơn. Để tạo nhóm, bạn cần tạo tệp kê khai bằng định dạng khai báo và ngôn ngữ tuần tự hóa dữ liệu YAML. Kubernetes sử dụng các tệp kê khai này cho khung điều phối Container của nó.

Podman tương tự như Docker có nghĩa là bạn có thể tương tác với các Container Podman bằng cách sử dụng các lệnh Docker. Không có daemon, Podman an toàn hơn với bề mặt tấn công ít hơn. Để truy cập từ xa tất cả các tài nguyên được hỗ trợ, bạn có thể sử dụng các API REST. Hơn nữa, Container Podman không cần quyền truy cập root, có nghĩa là bạn có thể kiểm soát chúng chạy với tư cách người dùng root của máy chủ, để có mức độ bảo mật cao hơn.

Một khả năng khác tách Podman khỏi Docker là bạn có thể nhóm các Container thành các nhóm và quản lý hiệu quả một nhóm các Container. Để sử dụng tính năng này trong Docker, bạn cần tạo tệp YAML do docker-soạn. Khả năng quản lý nhóm hiệu quả là điều mang lại lợi thế cho Podman so với các công cụ chứa đựng khác.

Giải pháp thay thế Docker số 9: Containerd

Containerd không phải là một sự thay thế cho Docker nhưng nó thực sự là một phần của công nghệ Docker. Containerd là thời gian chạy của Container thực hiện các tác vụ tạo, quản lý và hủy các Container trong thời gian thực, thực hiện các thông số kỹ thuật của Container Runtime Interfacer (CRI). Nó là một kernel abstraction layer trừu tượng hóa chức năng hệ điều hành hoặc Syscalls. Nó lấy các docker image và gửi chúng đến thời gian chạy cấp thấp được gọi là runc quản lý các Container.

Khi Docker được phát hành vào năm 2013, nó là một công cụ container toàn diện giúp các tổ chức tạo và chạy các container. Nhưng nó thiếu hệ thống điều phối Container. Vì vậy, Kubernetes đã được giới thiệu vào năm 2014 để đơn giản hóa các quy trình điều phối Container. Tuy nhiên, Kubernetes đã phải sử dụng Docker để tương tác với các container. Vì Kubernetes chỉ cần các thành phần bắt buộc để quản lý Container, nên nó đang tìm cách bỏ qua một số khía cạnh của công cụ. Kết quả là Dockershim. Trong khi Kubernetes phát triển Dockershim để vượt qua Docker, Docker đã đưa ra một công cụ điều phối Container được gọi là Docker Swarm thực hiện các nhiệm vụ của Kubernetes.

Khi công nghệ container phát triển và nhiều công ty tích hợp bên thứ 3 ra đời, việc quản lý các container của docker trở thành một nhiệm vụ phức tạp. Để tiêu chuẩn hóa công nghệ container, Open Container Initiative (OCI) đã được giới thiệu. Công việc của OCI là xác định các thông số kỹ thuật cho các tiêu chuẩn về Container và thời gian chạy. Để làm cho công nghệ docker trở nên mô-đun hơn, Docker đã trích xuất thời gian chạy của nó vào một công cụ khác gọi là containerd, công cụ này sau đó được tặng cho Cloud Native Computing Foundation (CNCF). Với containerd, Kubernetes có thể truy cập các thành phần Container cấp thấp mà không cần Docker. Trong các hệ thống mạng phân tán ngày nay, containerd giúp người quản trị tóm tắt các Syscalls và cung cấp cho người dùng những gì họ cần.

Phiên bản containerd mới nhất đi kèm với một hệ thống lưu trữ và phân phối hoàn chỉnh hỗ trợ hình ảnh Docker và định dạng OCI. Tóm lại, containerd giúp bạn xây dựng nền tảng Container mà không cần lo lắng về hệ điều hành bên dưới.

Giải pháp thay thế Docker số 10: runC

Tương tự như containerd, runC là một phần của hệ sinh thái Container Docker cung cấp chức năng cấp thấp cho các Container. Vào năm 2015, Docker đã phát hành runC như một công cụ thời gian chạy Container độc lập. Vì Docker là một công nghệ chứa toàn diện chạy các ứng dụng phân tán trên các nền tảng và môi trường khác nhau, nên nó sử dụng môi trường hộp cát để tóm tắt các thành phần bắt buộc của máy chủ bên dưới mà không cần viết lại ứng dụng. Để làm cho sự trừu tượng này có thể thực hiện được, Docker đã tích hợp các tính năng này vào một thành phần thời gian chạy Container cấp thấp thống nhất được gọi là runC. runC có tính di động cao, an toàn, nhẹ và có thể mở rộng, làm cho nó phù hợp cho các triển khai lớn. Vì không có sự phụ thuộc vào nền tảng Docker, runC cung cấp các Container tiêu chuẩn cho mọi người, ở mọi nơi.

runC cung cấp hỗ trợ riêng cho các Container Windows và Linux và các nhà sản xuất phần cứng như Arm, IBM, Intel, Qualcomm và các tính năng phần cứng tiên tiến như tpm và DPSK. Định dạng cấu hình Container runC được điều chỉnh bởi Dự án Container mở. Đó là khiếu nại OCI và thực hiện các thông số kỹ thuật OCI.

Giải pháp thay thế Docker bổ sung: Vagrant

Vagrant là một công cụ phần mềm mã nguồn mở của Hashicorp giúp các tổ chức xây dựng và quản lý môi trường triển khai phần mềm di động như VirtualBox. Với quy trình làm việc dễ dàng và tự động hóa, Vagrant cho phép các nhà phát triển tự động thiết lập môi trường phát triển di động. Mặc dù Docker có thể chạy phần mềm hiệu quả về chi phí trên một hệ thống chứa sẵn trên Windows, Linux và macOS, nhưng nó không cung cấp đầy đủ chức năng trên một số hệ điều hành nhất định như BSD. Khi bạn đang triển khai ứng dụng cho môi trường BSD, tính tương đương sản xuất mơ hồ sẽ tốt hơn Docker. Tuy nhiên, Vagrant không cung cấp các tính năng chứa đầy đủ. Khi bạn đang sử dụng môi trường có nhiều microservices, vagrant thiếu chức năng đầy đủ. Vì vậy, vagrant rất hữu ích khi bạn đang tìm kiếm quy trình phát triển nhất quán và dễ dàng hoặc khi có liên quan đến việc triển khai BDS.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-2-1 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache MesosThiết kế hệ thống chuyên nghiệp OceanTech-Group anh-3 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache Mesos

Ưu và nhược điểm của các lựa chọn thay thế docker

Sự thay thế trực tiếp cho công nghệ Docker là kiến ​​trúc không máy chủ. Tuy nhiên, nó khiến các tổ chức phụ thuộc nhiều vào các nhà cung cấp đám mây. Nó cũng không phù hợp với các ứng dụng dài hạn. VMware không cung cấp một hệ thống chứa toàn diện. Rkt và Cloud Foundry đang đi vào ngõ cụt. Apache Mesos đang trên đà trở nên lỗi thời nhưng đã nhận được sự ủng hộ của các thành viên vào giờ chót. Containerd và runC là các công cụ cấp thấp và hoạt động tốt với phần mềm Container cấp cao như Docker. Hầu hết các lựa chọn thay thế Docker đều tập trung vào nhà phát triển.

Docker cung cấp một hệ sinh thái Container toàn diện và mạnh mẽ phù hợp với Devops, microservices và các kiến ​​trúc gốc đám mây!

Giải pháp điều phối Container

Khi bạn sử dụng Container, việc có công cụ điều phối để quản lý việc triển khai các cụm này là cần thiết. Điều phối Container là việc tự động hóa các tác vụ quản lý Container như lập lịch, triển khai, mở rộng quy mô và giám sát các Container. Ví dụ, trong một môi trường chứa đựng, mỗi máy chủ chạy nhiều ứng dụng được viết bằng các ngôn ngữ lập trình khác nhau bằng cách sử dụng các công nghệ và khuôn khổ khác nhau. Khi bạn mở rộng quy mô thiết lập này lên hàng trăm và hàng nghìn lượt triển khai, nó sẽ trở thành một thách thức để duy trì hiệu quả hoạt động và bảo mật. Và nếu bạn phải di chuyển chúng giữa các môi trường tại chỗ, đám mây và nhiều đám mây, sự phức tạp sẽ tăng lên. Xác định cung cấp thừa tài nguyên, cân bằng tải trên nhiều máy chủ, cập nhật và khôi phục, thực hiện các tiêu chuẩn bảo mật của tổ chức trên toàn bộ cơ sở hạ tầng là một số thách thức bổ sung mà bạn phải đối mặt. Việc thực hiện các thao tác này theo cách thủ công đối với các triển khai cấp doanh nghiệp là không khả thi. Một công cụ điều phối Container sẽ giúp bạn trong vấn đề này.

Điều phối Container sử dụng mô hình lập trình khai báo trong đó bạn xác định kết quả cần thiết và nền tảng sẽ đảm bảo rằng môi trường được duy trì ở trạng thái mong muốn đó. Nó có nghĩa là các triển khai của bạn luôn khớp với trạng thái được xác định trước. Khi bạn triển khai các Container, công cụ điều phối sẽ tự động lên lịch cho các triển khai đó bằng cách chọn máy chủ lưu trữ sẵn có tốt nhất. Nó đơn giản hóa các hoạt động quản lý container, tăng cường khả năng phục hồi và bổ sung bảo mật cho các hoạt động.

Kubernetes, Docker Swarm, Apache Mesos là một số công cụ điều phối Container phổ biến hiện có trên thị trường. Kubernetes đã trở nên phổ biến trong thời gian gần đây đến mức nhiều công cụ quản lý Container được xây dựng trên Kubernetes như Amazon Kubernetes Services (AKS), Google Kubernetes Engine (GKS), Amazon Elastic Container Service cho Kubernetes (EKS), v.v.

Giải pháp điều phối Container số 1: Kubernetes

Kubernetes hoặc K8S là công cụ điều phối Container phổ biến nhất giúp các tổ chức quản lý hiệu quả các Container ở quy mô lớn. Nó được phát hành vào năm 2014 bởi các kỹ sư của Google và hiện được cung cấp như một công cụ mã nguồn mở. Công cụ này được viết bằng Go và sử dụng lập trình khai báo và triển khai dựa trên YAML.

Kubernetes là một công cụ quản lý container và điều phối container toàn diện. Nó cung cấp tính năng cân bằng tải, tự động mở rộng quy mô, quản lý bí mật và quản lý khối lượng ngay lập tức. Nó sử dụng ‘nhóm’ cho phép bạn nhóm các Container và cung cấp tài nguyên dựa trên các giá trị được xác định trước. Nó cũng hỗ trợ giao diện người dùng web để xem và quản lý các cụm Container.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-4 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache Mesos

Kubernetes sử dụng kiến ​​trúc không máy chủ, vendor-agnostic và đi kèm với bảo mật tích hợp. Nó cung cấp hỗ trợ toàn diện cho các Container Docker. Nó cũng hỗ trợ công cụ rkt từ CoreOS. Kubernetes nhận được sự hỗ trợ sôi nổi của cộng đồng. Google Container Engine (GCE) nguyên bản hỗ trợ Kubernetes. Tương tự, Azure và Redhat OpenShift cũng hỗ trợ Kubernetes. Tuy nhiên, Kubernetes không dễ cấu hình và sử dụng.

Giải pháp điều phối Container số 2: Amazon ECS

Amazon Elastic Container Service (ECS) là một công cụ điều phối Container toàn diện được Amazon cung cấp cho các Container Docker. Nó cho phép các tổ chức chạy các cụm máy ảo trên đám mây Amazon một cách hiệu quả đồng thời có thể dễ dàng quản lý các nhóm Container trên các máy ảo này trên cơ sở hạ tầng. Chạy một kiến ​​trúc không máy chủ, ECS triển khai các máy ảo và quản lý các Container, có nghĩa là bạn chỉ cần vận hành các Container mà không cần lo lắng về việc quản lý các máy ảo. Bạn có thể xác định ứng dụng dưới dạng tác vụ bằng JSON. USP lớn nhất của ECS là tính đơn giản và dễ sử dụng. Việc triển khai có thể được thực hiện ngay từ bảng điều khiển quản lý AWS. Nó là miễn phí để sử dụng.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-5 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache Mesos

 

ECS được tích hợp với một bộ công cụ AWS phong phú như CloudWatch, IAM, CloudFormation, ELB, v.v. có nghĩa là bạn không cần phải tìm kiếm các tác vụ quản lý Container. Bạn có thể viết code và quản lý theo chương trình các hoạt động Container, thực hiện kiểm tra sức khỏe hoặc truy cập các dịch vụ AWS khác một cách dễ dàng. Tận dụng tính chất bất biến của Container, bạn có thể sử dụng các bản sao AWS tại chỗ và tiết kiệm chi phí lên đến 90%. Vì tất cả các Container được khởi chạy bên trong một đám mây riêng ảo, bạn có thể tận hưởng tính năng bảo mật bổ sung ngay từ đầu.

Giải pháp điều phối Container số 3: Amazon EKS

Dịch vụ Amazon Elastic Kubernetes là một dịch vụ mạnh mẽ khác từ AWS để quản lý hiệu quả Kubernetes chạy trên đám mây AWS. Nó là một công cụ Kubernetes được chứng nhận, có nghĩa là bạn có thể chạy tất cả các công cụ được sử dụng trong hệ sinh thái Kubernetes. Nó hỗ trợ môi trường lai và đa đám mây. Mặc dù AWS ECS dễ sử dụng, EKS có thể mất một chút thời gian để làm quen vì đây là một tác vụ phức tạp khi triển khai và định cấu hình các mẫu CloudFormation hoặc Kops. Tuy nhiên, nó cho phép nhiều tùy chỉnh và tính di động hơn trên các môi trường đa đám mây và hỗn hợp, đồng thời phù hợp nhất với các triển khai lớn. Amazon EKS thêm $ 144 mỗi cụm mỗi tháng vào hóa đơn AWS của bạn.

Giải pháp điều phối Container số 4: Dịch vụ Azure Kubernetes

Azure Kubernetes Service (AKS) là một dịch vụ Kubernetes được quản lý do Azure cung cấp. Trước đây, nó được gọi là Azure Container Service và hỗ trợ Docker Swarm, Mesos và Kubernetes. Điều tốt nhất với AKS là công cụ được cập nhật nhanh chóng phù hợp với các bản phát hành mới hơn của Kubernetes so với EKS và GKE.

Nếu bạn đã quen sử dụng Microsoft, AKS hoạt động tốt cho bạn vì bạn có thể dễ dàng tích hợp nó với các dịch vụ khác của Microsoft. Ví dụ: bạn có thể tích hợp liền mạch với Azure Active Directory. Azure Monitor và Application Insights giúp bạn theo dõi và ghi nhật ký các vấn đề trong môi trường. Chính sách Azure được tích hợp với AKS. Tự động sửa chữa tình trạng node là một tính năng hữu ích trong công cụ. Có một phần mở rộng Kubernetes trong Visual Studio Code cho phép bạn chỉnh sửa và triển khai Kubernetes từ trình soạn thảo. Cộng đồng nhà phát triển tốt.

AKS chỉ tính phí cho nút và mặt phẳng điều khiển là miễn phí. Mặt khác, AKS chỉ cung cấp 99,9% SLA khi nó phù hợp với Vùng sẵn có của Azure có tính phí. Đối với các cụm miễn phí, SLA thời gian hoạt động là 99,5%.

Giải pháp điều phối Container số 5: Google Kubernetes Engine

Google Kubernetes Engine là dịch vụ Kubernetes được quản lý do Google cung cấp. Khi Kubernetes được phát triển bởi các kỹ sư của Google, Google đã đứng đầu trong việc giới thiệu các dịch vụ Kubernetes được quản lý dưới dạng GKE. Hơn nữa, nó cung cấp các giải pháp tiên tiến nhất so với EKS và AKS. Nó tự động cập nhật máy chủ và máy nút. Hỗ trợ CLI có sẵn. Bạn có thể sử dụng công cụ Stackdriver để giám sát tài nguyên. Tính năng tự động thay đổi tỷ lệ có sẵn ngay lập tức. Nó hỗ trợ các nhóm nút trong đó bạn có thể chọn tài nguyên sẵn có tốt nhất để triển khai từng dịch vụ. Khi nói đến giá cả, quản lý cụm là miễn phí. Bạn sẽ bị tính phí cho các tài nguyên được sử dụng.

EKS vs AKS vs GKE

Thiết kế hệ thống chuyên nghiệp OceanTech-Group anh-6 Các lựa chọn thay thế Docker: 10 lựa chọn thay thế cho ứng dụng SaaS của bạn Thủ thuật serverless microservice docker Cloud Foundry Container Apache Mesos

Đâu là công cụ tốt nhất cho hệ thống điều phối container?

Sử dụng đúng ngăn xếp công nghệ, bạn có thể lên lịch các container một cách hiệu quả, đạt được tính khả dụng cao, thực hiện kiểm tra sức khỏe, thực hiện cân bằng tải và khám phá các dịch vụ.

Khi nói đến công nghệ container, Docker là hệ sinh thái phong phú và toàn diện nhất – không gì sánh kịp. Trên thực tế, Docker là một tiêu chuẩn container. Khi nói về công cụ điều phối container, Kubernetes là lựa chọn tuyệt vời nhất. Nó cung cấp hiệu suất mạnh mẽ để quản lý hiệu quả hàng ngàn cluster đồng thời cho phép bạn di chuyển liền mạch khối lượng công việc giữa các nền tảng khác nhau. Tìm kiếm một giải pháp thay thế Docker có thể gây rủi ro. Như đã đề cập ở trên, các doanh nghiệp sử dụng Cloud Foundry và Rkt phải thiết kế lại các chiến lược container của họ.

Tại sao khuyến khích sử dụng AWS ECS hoặc EKS với Docker?

Đối với các doanh nghiệp thực hiện triển khai ứng dụng đơn giản, AWS ECS với Docker là một lựa chọn hiệu quả cả về chi phí. Nếu tổ chức của bạn xử lý container với một khối lượng lớn, AWS EKS với Docker là một lựa chọn tốt. AWS là nhà cung cấp giải pháp nền tảng đám mây hàng đầu. AWS EKS đi kèm với khả năng tương tác cao, linh hoạt và tiết kiệm chi phí. Vì vậy, AWS ECS hoặc EKS với Docker sẽ đem đến cho bạn lựa chọn tốt nhất!

Kết luận

Khi các doanh nghiệp đang tích cực áp dụng kiến trúc cloud native và chuyển đổi khối lượng công việc lên đám mây, thì quá trình container đã trở thành xu hướng chính trong thời gian gần đây. Với hệ sinh thái độc lập mạnh mẽ, Docker đã trở thành tiêu chuẩn cho các giải pháp container hóa. Mặc dù Docker được triển khai bởi hàng triệu người dùng trên toàn cầu, vẫn có những công cụ container khác trên thị trường phục vụ cho các nhu cầu cụ thể. Tuy nhiên, khi khám phá các lựa chọn Docker thay thế,  điều quan trọng là phải xác định rõ ràng các yêu cầu container,  kiểm tra các lựa chọn thay thế máy chủ Docker và các trường hợp sử dụng trước khi đưa ra quyết định.

 

Những câu hỏi thường gặp

Kubernetes có phải là Docker thay thế không?

Không, Kubernetes không phải là một sự thay thế cho Docker. Thực tế, chúng bổ sung cho nhau. Trong khi Docker là một công nghệ thời gian chạy container, Kubernetes là một công cụ điều phối container. Nó giúp bạn quản lý các cụm container Docker.

Tại sao tôi nên sử dụng CI CD Pipeline?

Để tránh lỗi thủ công, nâng cao chất lượng mã, cải thiện chu kỳ phát hành, bổ sung các giá trị kỹ thuật và kinh doanh, cải thiện sự hài lòng của khách hàng, v.v.

Lý do chính khiến Cloud Foundry không còn được xem như như một giải pháp thay thế Docker là gì?

Trong khi ngành công nghiệp đang áp dụng Docker và tập trung vào Kubernetes, Cloud Foundry khẳng định người dùng của họ sử dụng một công cụ điều phối dành riêng cho nền tảng, Diego. Nó chỉ hỗ trợ các ứng dụng không trạng thái mà không quan tâm đến tính liên tục của các dịch vụ và các tùy chọn chống lại tương lai.

Kops có tốt hơn EKS không?

Kubernetes Operations (Kops) là một công cụ mã nguồn mở giúp bạn quản lý các cụm Kubernetes trên AWS và GCE. EKS và Kops cung cấp chức năng tốt hơn. Tuy nhiên, EKS an toàn hơn và cung cấp một số tính năng nguyên bản. Hãy cân nhắc khả năng tương thích của nền tảng trong khi lựa chọn giữa Kops và EKS.

Ocean Tech Group – “OnlyOne” trong thế giới công nghệ

Trong kỷ nguyên số, doanh nghiệp nào sở hữu hạ tầng công nghệ tối ưu, linh hoạt, và an toàn sẽ là người dẫn đầu. Ocean Tech Group tự khẳng định vị thế là đối tác duy nhất bạn cần, khi chúng tôi kết hợp ba giá trị cốt lõi: tư duy đổi mới, tinh thần phục vụ tận tâm, vận hành hiệu quả cao – để mang lại giải pháp công nghệ thực sự khác biệt.

Fortinet: Hướng dẫn cấu hình HA trên thiết bị firewall FortiGate

Fortinet: Hướng dẫn cấu hình HA trên thiết bị firewall FortiGate


Overview

Bài viết hướng dẫn cách cấu hình HA Active-Passive trên 2 thiết bị tường lửa FortiGate, khi đó 1 thiết bị hoạt động sẽ đóng vai trò là Master và 1 thiết bị là dự phòng. Trong trường hợp Master bị lỗi thì Slave sẽ hoạt động cho đến khi Master được xử lý xong

Bài viết được cấu hình trên version 6.2.5

Yêu cầu cấu hình

  • 2 thiết bị phải chạy cùng phiên bản FortiOS và active license nếu có trước khi thêm vào HA Cluster

Hướng dẫn cấu hình

Cấu hình 1 FortiGate làm Master

  • Trên thiết bị FortiGate Master, vào System -> Settings và thay đổi tên hostname (có thể bỏ qua bước này)
Thiết kế hệ thống chuyên nghiệp OceanTech-Group image-1581-1024x489 Fortinet: Hướng dẫn cấu hình HA trên thiết bị firewall FortiGate Thủ thuật Fortinet FortiGate
  • Vào System -> HA
    • Ở mục Mode: Chọn Active-Passive
    • Ở mục Device priority: Đặt chỉ số Device priority, thiết bị có số Device priority cao nhất sẽ là Master (Primary), thiết bị có chỉ số Device priority thấp hơn sẽ là Slave
    • Ở mục Group name: Đặt tên cho group (2 thiết bị phải đặt giống nhau)
    • Ở mục Password: Đặt password để xác thực các member trong group HA
    • Ở mục Heartbear interfaces: Chọn port mạng mà bạn muốn cấu hình HA để 2 thiết bị đồng bộ với nhau (ở đây tôi chọn port 3)

-> Nhấn Save để lưu lại

Thiết kế hệ thống chuyên nghiệp OceanTech-Group image-1582-1024x487 Fortinet: Hướng dẫn cấu hình HA trên thiết bị firewall FortiGate Thủ thuật Fortinet FortiGate

Cấu hình tương tự cho thiết bị làm Slave với thông số Device priority thấp hơn của thiết bị Master

  • Sau khi đã cấu hình xong HA
Thiết kế hệ thống chuyên nghiệp OceanTech-Group image-1584-1024x486 Fortinet: Hướng dẫn cấu hình HA trên thiết bị firewall FortiGate Thủ thuật Fortinet FortiGate

SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2

SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2


In my previous article, I have explained the process of installing and creating a failover cluster and how to enable the AlwaysOn availability group.

In this article, I am going to explain the step-by-step deployment process of SQL Server AlwaysOn Availability groups using wizards. The deployment configurations look the following way:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group Screenshot_1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

We have installed SQL Server 2017 and SQL Server management studio on all the servers. First, connect to SQL01.DC.Local and open SQL Server management studio. In SSMS, connect to the database engine. In the object explorer window, expand AlwaysOn High Availability, Right-click on Availability groups, and select “New Availability Group Wizard.” See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2nd SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

The first screen is Introduction, which provides the details of the availability group wizard and what tasks we can perform using it. If you do not wish to see this screen again, you can skip it by selecting “Do not show this page again.” Click Next to move on to the next screen. See the following screenshot:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 3rd SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

On the specify availability group screen, enter the desired name of the availability group. In the “Cluster Type” drop-down menu, you can choose any of the following values:

  1. Windows Server Failover Cluster: This option is used when you want to create an availability group using a traditional Windows Server failover cluster.
  2. External: This option is used when you create an availability group on the Linux operating system. It uses the Linux operating system by integrating it with PACEMAKER (Linux Cluster resource manager).
  3. NONE: This option is used when you do not wish to enable high availability option. It can be used for both Windows and Linux.

We are deploying AAG on a Windows cluster hence select “Windows Server Failover Cluster” from the cluster type drop-down box. Click Next to move on to the next screen. See the following screenshot:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 4th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

On the Select databases screen, choose the databases you want to include in your availability group. The databases must fulfill the following prerequisites to be a part of the availability group:

  1. The database must be in the Full Recovery Model.
  2. The Full Backup of the database must be taken.

If the above pre-requisites are met, you can see “Meets Prerequisites” in the Status column of the grid. Choose the name of the database by clicking on the checkbox and click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 5th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

On the Specify replica screen, we will configure the following options:

  1. List of availability replicas.
  2. Endpoints.
  3. Backup preference.
  4. Availability Group Listener.
  5. Read-Only routing.

Let me explain all the options.

First, in the replica tab, you can specify the list of replicas that you want to include in the availability group. We are going to include SQL02.Dc.Local and SQL03.DC.Local as the secondary replicas. To add a replica, click on the “Add Replica” button.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 6th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

When you click on “Add replica”, the Connect to Server dialog box opens. In the Server name text box, enter the name of the server that you want to add in the availability group, then click on Connect. Add SQL02 in the server name text box and click on Connect. Similarly, add SQL03.Dc.Local in availability replicas. As I mentioned at the beginning of the article, SQL02.Dc.Local will be the synchronous replica and SQL03.Dc.Local will be the asynchronous replica; hence, choose Synchronous to commit from the Availability mode column mode for SQL02.Dc.Local and choose Asynchronous commit for SQL03.Dc.Local. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 7th-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

To configure the backup preference, click on the Backup preference tab. In the backup preference screen, you can see four options. The details of each option are provided on the screen, which is self-explanatory. As I mentioned, choose the “Prefer secondary” option. Backup priority will come up when you have configured the availability group with multiple secondary replicas, and the backup preference is secondary. Backup priority will be determined based on the number entered in the backup priority textbox. For example, if the backup priority is 70 for the SQL03.Dc.Local replica, the backup will be generated on the SQL03.Dc.Local replica. If you don’t want to generate a backup on any specific replica, you can exclude a replica by clicking on the “Exclude Replica” checkbox. For now, do not make any changes to the backup priority. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 8th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

To create an availability group listener, click on the Listener tab. On the listener tab, select “create new availability listener.” In the DNS Name text box, provide the desired DNS name. This DNS name will be used to connect to the availability group. Enter the desired port in the Port number dialog box. Make sure the port is open in the windows firewall. Choose Static IP Address from the Network mode drop-down box. Click on the Add button to add IP Address. When you click on Add, the “Add IP Address” dialog box opens. In the dialog box, enter the desired IP Address. Click OK to close the dialog box. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 9th-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

Once all parameters are configured, click on Next. On the “Select initial data synchronization” screen, you can see multiple options. They look the following way:

Automatic Seeding: When you choose this option, the wizard will automatically create an availability database on all secondary replicas. To use this option, we must make sure the data file and the log file paths are the same across all primary and secondary replicas.

Full Database and Log Backup: When you choose this option, Wizard will restore full database and log backups for available databases from shared locations entered in the “File Share Path” text box. To use this option, we must create a shared folder to keep full database and log backups. Your SQL Server service account must have read-write permission on the shared folder.

Join Only: When you choose this option, the wizard will join an availability database created on all secondary replicas. To use this option, we must restore a backup of the availability database on all secondary replicas.

Skip initial synchronization: When you choose this option, the wizard will skip the initial synchronization of primary and secondary replicas. We can perform it manually.

In our demo setup, data file and log file locations are the same; hence, choose the “Automatic Seeding” option from the “data synchronization preference” menu, then click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 10th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

On the validation screen, the wizard will perform validation checks on the entire configuration. It must be passed successfully. If you face any error during the validation test, you must fix it and click on the “re-run the validation” button to revalidate the configuration. Once the validation test passes successfully, click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 11th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

On the Summary screen, review the whole configuration of parameters and click on the Finish button. Once you click on the finish button, the wizard will start the process of creating an availability group. You can also generate a script for it by clicking on the “Script” button. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 12th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

Congratulations. We have successfully created the AlwaysOn availability group. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 13th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

To view details of the availability group, expand AlwaysOn High Availability in object explorer ? Expand availability group. You can see the availability group named “SQL_AAG” has been created. To view the participating node, expand SQL_AAG ? Expand availability replica. To view Availability databases, expand Availability databases. And to view Listener, expand Availability group listener.  See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 14th SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 2 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 2

Summary

In this article, I have explained the step-by-step deployment process of the AlwaysOn availability group using AlwaysOn availability group wizard. In the next article, I will explain different ways to monitor the AlwaysOn Availability group. I will also demonstrate the failover process and explain read-only routing. Although, a nice article covering this topic has been written by Ganapathi Varma Chekuri on Codingsight. You can read the article here.

SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1

SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1


In this article, I will explain the process of installing pre-requisites to deploy the SQL Server AlwaysOn availability group.

For the demonstration, I have prepared a demo set up at my work station. See the following components:

Virtual Machine Host Name Purpose
Domain Controller DC.Local The domain controller is installed on this machine
Primary Replica SQL01.DC.Local This machine acts as a Primary replica in the Availability group
Secondary Replica SQL02.DC.Local This machine acts as a Secondary replica in the Availability group. This replica is in a Synchronous commit mode
Secondary Replica with SQL03.DC.Local This machine acts as a secondary replica in the Availability group. This replica is in an Asynchronous commit mode

I will explain the following actions:

  1. Installing a failover clustering role
  2. Create a failover cluster
  3. Enable AlwaysOn availability group features in SQL Server

Installing a failover clustering role

To deploy AAG, first, we need to install a failover cluster feature on every node. To do that, connect to SQL01.DC.Local and open Server Manager. At the top side of the Server Manager dialog box, click on Manage and select Add Roles and Features. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic1-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1
The add/remove roles and features wizard opens. On the first screen, you can see the information about this wizard. You can skip this screen by clicking on “Skip this page by default”, then click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic2-3 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the next screen, you can perform a role-based or feature-based installation. You can also choose remote desktop service based installation. Since we want to install a failover cluster feature on SQL01.dc.local, select role-based or feature-based installation. Select your option and click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic3-4 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the next screen, select a server on which you want to enable a failover cluster feature. Since we want to install it on SQL01.Dc.Local, choose SQL01.Dc.Local from the server pool and click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic4-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the next screen, you can review the list of server roles. The failover cluster is a feature, hence click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic5-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the Select Features screen, select “Failover Clustering” from the list of features, click on Add features, and click on Next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic6-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the next screen, you can review the summary of the feature installation. Click on Install and see the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic7-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

The failover clustering feature has been installed successfully. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic8-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Similarly, follow the above process to install the failover clustering feature on all the nodes.

Create a Failover Cluster

To create a cluster, open the failover cluster manager and click on Create Cluster. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic9-2 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Once the wizard creates a name, a new cluster opens. On the first screen, you can review the wizard details. Click on Next.

On the Select Servers screen, you need to add a list of nodes that you want to use to form a cluster. We will create a cluster using SQL01.dc.localSQL02.dc.local, and SQL03.dc.local. To do that, first, enter SQL01.dc.local in the enter server name text box and click on Add. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic10-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Similarly, add SQL02.dc.local and SQL03.dc.local, then click on next. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic11-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the Access Point to Administrating Cluster screen, enter Cluster Name and IP address to access it. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic12-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

On the confirmation screen, review all the details and click on Next. The process of building a failover cluster will be started. Once the process completes, you can see the installation summary on the Summary screen. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic13-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Once the cluster is created, you can review its configuration from the failover cluster manager. To view the details, connect to SQL01.dc.local, open Failover Cluster Manager, expand SQL_AAG.dc.Local, and select “Nodes” to view the underlying nodes. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic14-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Enable AlwaysOn availability group feature on all the nodes

Once the cluster is created, we must install SQL Server 2017 on all the nodes.

After SQL Server is installed on the nodes, we need to enable AlwaysOn availability group features on all of them. To do that, connect to SQ01.dc.local –> Open SQL Server 2017 Configuration Manager, double-click on “SQL Server Services”, and right-click on SQL Server (MSSQLSERVER). See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic15-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Now the SQL Server (MSSQLSERVER) dialog box opens. Once you see it, click on “AlwaysOn High Availability” and check the “Enable AlwaysOn Availability group” check-box. Click Ok to close the dialog box and restart SQL Service. See the following image:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group pic16-1 SQL Server AlwaysOn Availability Groups: Installation and configuration, Part 1 Thủ thuật SQL Server AlwaysOn Availability Groups: Installation and configuration - Part 1

Similarly, we must enable these features on all the nodes. To do that, follow the above process for SQL02.dc.local and SQL03.dc.local.

Summary

In this article, I have explained the lab setup to deploy the AlwaysOn availability group. In my next article, I will explain the step-by-step deployment process of the AlwaysOn availability group using AlwaysOn availability group wizard.

Setup and Configure of SQL AlwaysOn

Setup and Configure of SQL AlwaysOn


So this is how to get SQL AlwaysOn up and running. We utilize SQL with solutions we deploy for customers; some customers have SQL and others expect me to install and configure it. I am NOT an SQL expert, but I know from KB’s/Whitepapers/blogs and experience how to stand SQL up as well as get it running. I just don’t do it frequently. So this is a reminder for me on how to do it, and I’m hopeful that this helps someone in the same situation.

Just to put it out there, I don’t go into the design side of things but I did reference the following paper VMware Workspace ONE and VMware Horizon Reference Architecture, this blog is more a “How to”

If something is wrong please let me know, I’m all about learning

Overview

2 VM’s running Windows 2016 with SQL Server 2016 Enterprise and using AlwaysOn

Note: SQL Standard does work but is limited

Availability groups to protect critical DataBases.

Specs

I used 2xVM’s with 2 x vCPU, 8GB Ram, 2 Networks (Production ,SQL-HB) 6 HD’s each.

Prerequisites

  • Create an AD Services account (svc-sql)

  • Create OU and place all SQL servers in it

  • 4 IP’s = 2 for Hosts, 1 for SQL-VIP, 1 per AVG for SQL Listener

  • 2 IP’s = 2 for Hosts non-routable

  • Correct Timezone and NTP

  • Forward and reverse DNS working

  • Witness Fileshare

  • Turn off Firewall or add required ports

  • Configure VMware vSphere® Storage DRS™ anti-affinity rules to separate the VMs on different VMware ESXi hosts

  • SQL-HB Portgroup, just layer-2 and tag with VLAN


 Install and Patch Windows

Mount and create HD’s and name them, these need to be the same on all servers.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_15-40-05 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_15-44-59 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Assign Static IP’s for NIC’s, for the SQL-HB, I used a private 192.168.200.1,2/252

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-10-46 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Unselect everything except TCP/IPv4 for the SQL-HB only. Once all servers are completed, ping other nodes to make sure the SQL-HB works.

Add Service (svc-sql) account to Local Administrators Group

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-02-18 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Installation & Configure – Failover Clustering

On each Server from Server Manager > Manage> Add Roles and Features

Select Failover Clustering and Install

Open Failover Cluster Manager

Right Click

Create Cluster

Enter names of servers to add to cluster > Next

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-24-11 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Yes to Validation > Next

Next > Run all tests > Next

Review report and look for errors and warnings

Resolve issues

                                              Enter Cluster Name & IP

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-27-15 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-30-16 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next once Confirmed

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-32-46 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Finish

Ignore the error “No appropriate disks could be found for the witness disk”

Next, we are going to fix the “Witness Warning”.

The current configuration should look like this:

(Notice the lack of a witness.)

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-36-14 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Add Witness

To add a witness, right click Cluster Name

More Actions > Configure Cluster Quorum Settings

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-43-08 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next > Select the Quorum Witness

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-46-52 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-49-33 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Select Configure a file share witness > Next

I have created a VM for this Witness, if you have a file server I would use that instead

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_16-51-36 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Browser to the server and share

Note: On the share itself I gave Change permissions to the SQL2-AlwaysOn Computer Object

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-00-05 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-04-32 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Finish

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-10-48 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

The Witness share is now created

Cluster Network Setting

Select Cluster Name and select Networks

Check to make sure the 192.168.200.0/30 is for Cluster Use only

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-25-55 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

I also rename the Name of the network to reflect its purpose….i.e SQL HB & Production

Move SQL to other Node

Right Click Cluster > Select More Actions > Move Core Cluster Resources > Select Node…

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-53-31 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Select Node and Click OK

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_17-57-54 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

The Cluster has been moved to the other server

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-04_18-01-10 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Check Cluster Core Resources – Everything Online?

Delegate Control

Open Active Directory Users and Computers select View > Advanced Features

Right click SQL Servers OU select Properties > Security Tab

Select Advanced button

Select Add

Click Select a Principal

Select Objects Types

Thiết kế hệ thống chuyên nghiệp OceanTech-Group Delegate Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Check Create Computers Objects click OK

Change Cluster Subnet Threshold

Open Powershell and enter the following commands:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-03_15-49-42 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

(Get-Cluster).SameSubnetThreshold=10

(Get-Cluster).crossSubnetThreshold=20

get-cluster | fl *subnet*

Installing SQL

1.       Mount ISO and Select New SQL Server stand-alone Installation

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-10-46 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Next > Accept Terms

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-29-55 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Select Database Engine Services > Change Drive letters to reflect correct locations

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-32-23 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Rename the Instance if required

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-36-20 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Change the Account Name to the Service Account that was created and enter password

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-39-25 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Change Authentication Mode to Mixed Mode and Add Current User

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-42-35 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Select Data Directories tab and Change the Drive letters to reflect correct location

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-45-03 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Again change Drive letter for correct location

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-02_16-46-55 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Review summary and Install

Now perform the same install on the second server using the same settings.

Once SQL is installed, install SQL Server Management Tools

Restart both servers make sure all SQL Services start as expected


Enable SQL Always On

Log in to each SQL server and open SQL Server Configuration Manager

Select SQL Server Services and then right Click SQL Server > Properties

Select AlwaysOn High Availability tab and check Enable > OK

Right click SQL Server and restart the SQL Service

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-04-01_10-40-47 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Create SQL Cluster

Open SQL Server Configuration Manager (Do on all servers in cluster)

Select SQL Server Services > SQL Server

Right Click > Properties

Select AlwaysOn High Availability tab

Check Enable AlwaysOn Availability Groups

Restart SQL Server

Open Microsoft SQL Management Studio

Create a Database and take a Backup

Select Always On High Availability from menu

Right click and select New Availability Group and follow wizard

Name the Group > Next

Select Database > Next

Select Add Replica and enter the other server

Change Availability Mode to Synchronous commit

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-03_15-14-21 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Select Listener Tab

Select Create an availability group

Enter Listener DNS Name

Enter port 1433

Select Add.. to assign Static IP

Select public IP Subnet

Enter IPv4 Address > click OK

Next

Leave data synchronization as Automatic seeding > Next

Check Validation results and correct issues if any

Right Click new AV Group and select Show Dashboard  check for issues.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group 2020-03-03_15-21-21 Setup and Configure of SQL AlwaysOn Thủ thuật Setup and Configure of SQL AlwaysOn

Sync Accounts

Open Powershell and enter the following

install-module -Name dbatools

Set-DbatoolsInsecureConnection -SessionOnly

Use the format

Copy-DbaLogin -source lab2-sql01 -Destination lab2-sql02

sync-DbaLoginPermission -source lab2-sql01 -Destination lab2-sql02

Install HAProxy on RHEL 9 or CentOS 9

Install HAProxy on RHEL 9 or CentOS 9


Learn how to install HAProxy on RHEL 9 or CentOS 9 with our step-by-step guide. Enhance your web services’ performance and reliability using advanced load balancing techniques. Includes examples, configuration tips, and troubleshooting advice.

Introduction

HAProxy (High Availability Proxy) is a reliable and versatile solution for load balancing and proxying. It is widely used to improve the performance and reliability of websites by distributing workloads across multiple servers. In this guide, we will walk you through the process of installing and configuring HAProxy on RHEL 9 or CentOS 9. By the end, you will have a fully functional HAProxy setup tailored to your needs.

Prerequisites

Before diving into the installation process, ensure that you have the following prerequisites in place:

  • A server running RHEL 9 or CentOS 9
  • Root or sudo access to the server
  • Basic knowledge of command-line operations

Lab Settings

For demonstration purposes, we’ve configured our Linux nodes as follows:

Hostnames RAM (GB) Cores Operating System (OS)
haproxy.dev.naijalabs.net 4 2 Red Hat Enterprise Linux release 9.4 (Plow)
webserver1.dev.naijalabs.net 4 2 Red Hat Enterprise Linux release 9.4 (Plow)
webserver2.dev.naijalabs.net 4 2 CentOS Stream release 9
webserver3.dev.naijalabs.net 4 2 CentOS Stream release 9

Copy and paste the following entries in the /etc/hosts file on each node (replace IP addresses and hostnames with your actual settings):

# HAProxy Nodes
192.168.1.18	haproxy.dev.naijalabs.net    haproxy
192.168.1.223	webserver1.dev.naijalabs.net webserver1
192.168.1.225	webserver2.dev.naijalabs.net webserver2
192.168.1.228	webserver3.dev.naijalabs.net webserver3
Thiết kế hệ thống chuyên nghiệp OceanTech-Group ping_haproxy_nodes Install HAProxy on RHEL 9 or CentOS 9 Thủ thuật Install HAProxy on RHEL 9 or CentOS 9


Install HAProxy on RHEL 9 or CentOS 9: A Step-by-Step Guide


Step 1: Update Your System

The first step in setting up HAProxy is to ensure your system is up-to-date. This helps in avoiding compatibility issues and ensures you have the latest security patches.

sudo dnf update -y

Updating your system guarantees that all installed packages are current and your system is secure.

Step 2: Install HAProxy

With your system updated, the next step is to install HAProxy on your load balancer (haproxy node). Fortunately, HAProxy is available in the default repositories of RHEL 9 and CentOS 9.

sudo dnf install haproxy -y

The -y flag automatically confirms the installation process.

Step 3: Configure HAProxy

Once HAProxy is installed, it’s time to configure it. The primary configuration file for HAProxy is located at /etc/haproxy/haproxy.cfg.

Backup the Default Configuration

Before making any changes, it’s good practice to create a backup of the default configuration file.

sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak

Basic Configuration

Open the configuration file with your preferred text editor. Here, we will use vim.

sudo vim /etc/haproxy/haproxy.cfg

Below is an example of a basic HAProxy configuration (given our lab settings):

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

    # utilize system-wide crypto-policies
    ssl-default-bind-ciphers PROFILE=SYSTEM
    ssl-default-server-ciphers PROFILE=SYSTEM

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend http_front
    bind *:80
    stats uri /haproxy?stats
    default_backend http_back

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------

backend http_back
    balance roundrobin
    server webserver1 192.168.1.223:80 check
    server webserver2 192.168.1.225:80 check
    server webserver3 192.168.1.228:80 check

Explanation of Configuration

Let’s break down the provided HAProxy configuration file step by step to explain its components and settings (to skip this section and continue with the install, click here).

Global Settings

The global section defines settings that apply to the entire HAProxy instance. Here’s what each directive does:

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
Logging Configuration
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events.  This is done
#    by adding the '-r' option to the SYSLOGD_OPTIONS in
#    /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
#   file. A line like the following can be added to
#   /etc/sysconfig/syslog
#
#    local2.*                       /var/log/haproxy.log
#
log         127.0.0.1 local2
  • This line configures HAProxy to log messages to the syslog server running on the localhost (127.0.0.1) using the local2 facility. This facility can be directed to specific log files, such as /var/log/haproxy.log, by adjusting syslog settings.
  • The comments above suggest steps to ensure that HAProxy logs are properly recorded:
    1. Modify the syslog daemon’s options to accept remote logs by adding -r to SYSLOGD_OPTIONS in /etc/sysconfig/syslog.
    2. Add a line to route local2 logs to the specified log file:
local2.*                       /var/log/haproxy.log
Chroot Directory
chroot      /var/lib/haproxy
  • This command restricts HAProxy to the specified directory (/var/lib/haproxy). This enhances security by limiting the filesystem access HAProxy has.
PID File
pidfile     /var/run/haproxy.pid
  • This sets the file where the process ID (PID) of the HAProxy process will be stored. This file can be useful for managing the HAProxy process (e.g., for restarting).
Maximum Connections
maxconn     4000
  • This specifies the maximum number of simultaneous connections that HAProxy can handle. In this case, it is set to 4000.
User and Group
user        haproxy
group       haproxy
  • These directives specify that HAProxy should run as the haproxy user and group, providing a layer of security by preventing HAProxy from running with root privileges.
Daemon Mode
daemon
  • This tells HAProxy to run in the background as a daemon, allowing it to run independently of the terminal.
Stats Socket
stats socket /var/lib/haproxy/stats
  • This line enables a Unix socket for HAProxy statistics. This socket can be used to get real-time metrics about HAProxy’s performance.
SSL Default Ciphers
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-server-ciphers PROFILE=SYSTEM
  • These directives configure the default SSL/TLS ciphers used for binding to clients and for server connections. The PROFILE=SYSTEM option indicates that it should use the system-wide crypto policies for cipher selection.

Defaults Section

The defaults section provides a way to set common parameters that can be used in all other sections unless overridden. This helps maintain consistency across different configurations.

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
Mode
mode                    http
  • This specifies that the default mode for all connections will be HTTP. HAProxy supports both HTTP and TCP modes.
Logging
log                     global
  • This uses the logging configuration defined in the global section.
HTTP Logging Options
option                  httplog
option                  dontlognull
  • httplog enables detailed logging for HTTP requests.
  • dontlognull prevents logging of connection attempts that are closed without any HTTP data.
HTTP Server Close Option
option http-server-close
  • This option instructs HAProxy to close the server connection after the response is sent, which can help manage resource utilization.
Forwarding Options
option forwardfor       except 127.0.0.0/8
  • This directive adds the X-Forwarded-For header to the requests, allowing the backend servers to see the original client IP address. The exception except 127.0.0.0/8 ensures that this header is not added for localhost connections.
Redispatch
option                  redispatch
  • This option allows HAProxy to retry requests on another server if the first server is not available.
Retries
retries                 3
  • This sets the number of times HAProxy will retry a failed connection to a backend server before considering it down.
Timeouts
  • The various timeout settings control how long HAProxy will wait for different stages of the request/response lifecycle:
timeout http-request    10s
timeout queue           1m
timeout connect         10s
timeout client          1m
timeout server          1m
timeout http-keep-alive 10s
timeout check           10s
  • http-request: Maximum time to wait for an HTTP request from the client.
  • queue: Maximum time a request can wait in the queue if all backends are busy.
  • connect: Maximum time to wait for a connection to a backend server.
  • client: Maximum inactivity time for the client connection.
  • server: Maximum inactivity time for the server connection.
  • http-keep-alive: Maximum time to keep an HTTP connection alive.
  • check: Timeout for health checks on backend servers.
Maximum Connections
maxconn                 3000
  • This sets the maximum number of simultaneous connections that can be handled by the HAProxy instance, limiting it to 3000 connections.

Frontend Section

The frontend section defines how incoming traffic is handled and routed to the backend servers.

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------

frontend http_front
    bind *:80
    stats uri /haproxy?stats
    default_backend http_back
Bind Directive
bind *:80
  • This line binds the frontend to listen on all available network interfaces on port 80 for incoming HTTP requests.
Stats URI
stats uri /haproxy?stats
  • This allows access to the HAProxy statistics page at the specified URI (/haproxy?stats), providing real-time insights into the HAProxy’s performance.
Default Backend
default_backend http_back
  • This specifies that incoming requests should be routed to the http_back backend section unless specified otherwise.

Backend Section

The backend section defines how requests are distributed among the servers listed.

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------

backend http_back
    balance roundrobin
    server webserver1 192.168.1.223:80 check
    server webserver2 192.168.1.225:80 check
    server webserver3 192.168.1.228:80 check
Load Balancing Method
balance roundrobin
  • This sets the load balancing algorithm to round-robin, which distributes requests evenly across the backend servers.
Server Definitions
server webserver1 192.168.1.223:80 check
server webserver2 192.168.1.225:80 check
server webserver3 192.168.1.228:80 check
  • Each line defines a backend server:
    • webserver1webserver2, and webserver3 are given names for easy reference.
    • Each server’s IP address and port (80) are specified, allowing HAProxy to forward requests to these servers.
    • The check parameter enables health checks on these servers, ensuring HAProxy only sends traffic to healthy servers.
Summary

This HAProxy configuration file sets up a robust load balancing system with extensive logging and monitoring capabilities. It defines global settings that affect all aspects of HAProxy’s behavior, establishes common defaults for connections, and specifies how incoming requests should be routed to multiple backend servers using a round-robin approach. The configuration prioritizes security, reliability, and ease of monitoring, making it suitable for handling web traffic effectively.

Step 4: SELinux Settings

Now, let’s set a rule that enables HAProxy to establish outbound connections to any remote server by setting the SELinux boolean haproxy_connect_any to true. The -P flag ensures that this change is persistent across system reboots.

sudo setsebool -P haproxy_connect_any 1

Step 5: Start and Enable HAProxy

After configuring HAProxy, start the service and enable it to run at boot.

sudo systemctl enable --now haproxy
Created symlink /etc/systemd/system/multi-user.target.wants/haproxy.service → /usr/lib/systemd/system/haproxy.service.

Verify the status of HAProxy to ensure it’s running correctly.

sudo systemctl status haproxy
● haproxy.service - HAProxy Load Balancer
     Loaded: loaded (/usr/lib/systemd/system/haproxy.service; enabled; preset: disabled)
     Active: active (running) since Sat 2024-07-20 18:57:40 EDT; 1h 36min ago
    Process: 1793 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -f $CFGDIR -c -q $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 1795 (haproxy)
      Tasks: 3 (limit: 23170)
     Memory: 4.1M
        CPU: 2.816s
     CGroup: /system.slice/haproxy.service
             ├─1795 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf.d -p /run/haproxy.pid
             └─1797 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -f /etc/haproxy/conf.d -p /run/haproxy.pid

Jul 20 18:57:40 haproxy.dev.naijalabs.net systemd[1]: Started HAProxy Load Balancer.
Jul 20 18:57:40 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver1 is DOWN, reason: Layer4 connection problem, info: "No route to host",>
Jul 20 18:57:41 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver2 is DOWN, reason: Layer4 connection problem, info: "No route to host",>
Jul 20 18:57:42 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver3 is DOWN, reason: Layer4 connection problem, info: "No route to host",>
...omitted for brevity...

Notice the WARNING message: This is to be expected since we have not set up our web server instances yet.

Step 6: Open Firewall Ports

If your server has a firewall enabled, you’ll need to open the necessary ports for HAProxy. By default, HAProxy listens on port 80 for HTTP traffic.

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload

Install HAProxy on RHEL 9 or CentOS 9: Setting up Webservers

So far, we have configured HAProxy to function as a load balancer, distributing the workload across the web servers using the round-robin algorithm. The next step is to set up the web servers.

Step 1: Install Apache

First, let’s install Apache on each server (in our scenario, webservers1, 2, and 3):

sudo dnf install httpd -y

Next, start and enable httpd on each server:

sudo systemctl enable --now httpd

Then, open port 80 to allow HTTP traffic on each server:

sudo firewall-cmd --permanent --add-port=80/tcp && sudo firewall-cmd --reload

Step 2: Configure the Webservers

With Apache installed and running on our webservers, we can proceed to the next step and configure each instance by creating an index.html file.

sudo vim /var/www/html/index.html

Copy and paste following entries into the file (on webserver1):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>

</head>
<body>
    <div class="container">
        <h2>Webserver1 Login</h2>
        <form action="login.php" method="POST">
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
            <input type="submit" value="Login">
        </form>
    </div>
</body>
</html>

Repeat on webserver2:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>

</head>
<body>
    <div class="container">
        <h2>Webserver2 Login</h2>
        <form action="login.php" method="POST">
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
            <input type="submit" value="Login">
        </form>
    </div>
</body>
</html>

Then, repeat once more on webserver3:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Page</title>

</head>
<body>
    <div class="container">
        <h2>Webserver3 Login</h2>
        <form action="login.php" method="POST">
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" required>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" required>
            <input type="submit" value="Login">
        </form>
    </div>
</body>
</html>

This html code will display a basic non-functioning login page. Restart httpd on each server:

sudo systemctl restart httpd

Now, let’s revisit our haproxy server and run a status check:

sudo systemctl status haproxy
...
Jul 21 05:27:59 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver1 is UP, reason: Layer4 check passed, check duration: 0ms. 1 active and>
Jul 21 05:30:05 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver2 is UP, reason: Layer4 check passed, check duration: 0ms. 2 active and>
Jul 21 05:34:03 haproxy.dev.naijalabs.net haproxy[1797]: [WARNING]  (1797) : Server http_back/webserver3 is UP, reason: Layer4 check passed, check duration: 0ms. 3 active and

You’ll notice that all backend webservers are UP or online.

Step 3: Test HAProxy

The final step is to test if the load balancer is functioning correctly. To do this, visit the load balancer’s IP address or http://192.168.1.18 in our example:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group webserver_login_page_1 Install HAProxy on RHEL 9 or CentOS 9 Thủ thuật Install HAProxy on RHEL 9 or CentOS 9

Initially, you should see the login page for webserver1.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group webserver_login_page_2 Install HAProxy on RHEL 9 or CentOS 9 Thủ thuật Install HAProxy on RHEL 9 or CentOS 9

Each time you refresh the page, you will be redirected to anyone of the backend web servers.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group webserver_login_page_3 Install HAProxy on RHEL 9 or CentOS 9 Thủ thuật Install HAProxy on RHEL 9 or CentOS 9

Advanced Configuration

Now that you have a basic HAProxy setup, you might want to explore more advanced configurations. Here are a few examples:

Load Balancing Algorithms

HAProxy supports various load balancing algorithms such as roundrobin, leastconn, and source. Modify your backend configuration to use the desired algorithm.

backend http_back
balance leastconn
server webserver1 192.168.1.223:80 check
server webserver2 192.168.1.225:80 check
server webserver3 192.168.1.228:80 check

SSL Termination

To handle HTTPS traffic, you need to configure SSL termination. First, install the necessary SSL package.

sudo dnf install haproxy-ssl -y

Then, update your configuration to include SSL termination.

frontend https_front
    bind *:443 ssl crt /etc/haproxy/ssl/haproxy.pem
    default_backend https_back

backend https_back
    balance roundrobin
    server webserver1 192.168.1.223:443 check ssl verify none
    server webserver2 192.168.1.225:443 check ssl verify none
    server webserver3 192.168.1.228:443 check ssl verify none

Make sure you have your SSL certificate and key combined in the /etc/haproxy/ssl/haproxy.pem file.

Monitoring and Management

HAProxy provides a built-in statistics page that can be very useful for monitoring and managing your load balancer. To enable the stats page, ensure you have the following lines in your frontend configuration.

frontend http_front
bind *:80
stats enable
stats uri /haproxy?stats
stats auth admin:password
default_backend http_back

You can access the stats page by navigating to http://haproxy-server-ip-address/haproxy?stats or http://192.168.1.18/haproxy?stats in our example:

Thiết kế hệ thống chuyên nghiệp OceanTech-Group haproxy_stats Install HAProxy on RHEL 9 or CentOS 9 Thủ thuật Install HAProxy on RHEL 9 or CentOS 9

Troubleshooting

If you encounter issues with your HAProxy setup, here are a few troubleshooting tips:

  • Check Logs: HAProxy logs are invaluable for diagnosing problems. You can find them in /var/log/haproxy.log.
  • Configuration Test: Before restarting HAProxy, always test your configuration with the following command:
sudo haproxy -c -f /etc/haproxy/haproxy.cfg
  • Service Status: Use systemctl status haproxy to check the status of the HAProxy service.

Conclusion

Setting up HAProxy on RHEL 9 or CentOS 9 is a straightforward process that significantly enhances the performance and reliability of your web services. By following this guide, you have learned how to install HAProxy, configure it for basic and advanced scenarios, and monitor its performance. As you become more familiar with HAProxy, you can explore additional features and customizations to further optimize your load balancing setup. Whether you are managing a small website or a large enterprise application, HAProxy provides the scalability and reliability needed to ensure smooth operation.

How to Install and Use Nginx Proxy Manager with Docker

How to Install and Use Nginx Proxy Manager with Docker


A reverse proxy is a web server that can sit in front of another web server or a web service. It can encrypt outgoing traffic, act as a load balancer, redirect traffic, and offer protection. Nginx web server can be used as a proxy server in front of traditional servers, but sometimes setting it up can be tedious and cause issues if not done properly.

Nginx Proxy Manager is an application that makes setting up Nginx as a proxy server easier by providing a graphical user interface (GUI) with features like in-built SSL support using Let’s Encrypt, support for multiple hosts, HTTP authentication, access lists, and user management.

This tutorial will teach you how to install the Nginx proxy manager on a Linux server using Docker. We will cover all popular Linux distributions in a single tutorial.

Prerequisites

  • A Linux server running Ubuntu/Debian/CentOS/Alma Linux/Rocky Linux with a minimum of 1 GB of RAM.
  • A non-root user with sudo privileges.
  • A fully qualified domain name (FQDN) like npm.example.com pointing to the server.

Step 1 – Configure Firewall

Cent OS/Rocky Linux/Alma Linux

You should have the Firewalld firewall installed. Check the firewall’s status.

$ sudo firewall-cmd --state
running

Open ports 80, 81 and 443.

$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
$ sudo firewall-cmd --permanent --add-port=81/tcp

Reload the firewall to enable the changes.

$ sudo firewall-cmd --reload

Ubuntu/Debian

Ubuntu and Debian systems use ufw (Uncomplicated Firewall) by default.

Check if the firewall is running.

$ sudo ufw status

If it is running, then open ports 80, 81 and 443.

$ sudo ufw allow 80
$ sudo ufw allow 81
$ sudo ufw allow 443

Open the SSH port if the firewall isn’t running.

$ sudo ufw allow "OpenSSH"

Enable the firewall if it is not running.

$ sudo ufw enable

If it is running, reload it to apply the changes.

$ sudo ufw reload

Step 2 – Install Docker

Cent OS/Rocky Linux/Alma Linux

Run the following command to install Docker.

$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
$ sudo yum install docker-ce docker-ce-cli containerd.io

Ubuntu

$ sudo apt install ca-certificates curl gnupg lsb-release
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io

Debian

$ sudo apt install ca-certificates curl gnupg lsb-release
$ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io

Enable and Start the Docker service.

$ sudo systemctl start docker --now

Add your username to the Docker group.

$ sudo usermod -aG docker $USER

Log out of the system and log back in to apply the change.

Step 3 – Install Docker Compose

Download and install Docker compose binary.

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Apply executable permission to the binary.

$ sudo chmod +x /usr/local/bin/docker-compose

Step 4 – Create Docker Compose File

Create a directory for the Nginx proxy manager.

$ mkdir ~/nginx-proxy

Switch to the directory.

$ cd ~/nginx-proxy

Create directories for user data and SSL certificates.

$ mkdir {data,letsencrypt}

Create and open the docker-compose.yml file for editing.

$ nano docker-compose.yml

Paste the following code in it.

version: "3"
services:
  npm-app:
    image: 'jc21/nginx-proxy-manager:latest'
    container_name: npm-app
    restart: unless-stopped
    ports:
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      DB_MYSQL_HOST: "npm-db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment the line below if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - npm-db
    networks:
      - npm-nw
      - npm-internal

  npm-db:
    image: 'mariadb:latest'
    container_name: npm-db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql
    networks:
      - npm-internal

networks:
  npm-internal:
  npm-nw:
    external: true

Save the file by pressing Ctrl + X and entering Y when prompted.

Let us go through the file. The first part of the file is where we import Nginx proxy manager’s image and set some environment variables in the form of database credentials. We also expose ports 80, 81 and 443 to the server for access. You can expose more ports, such as 21, for FTP access. You can disable IPV6 support by uncommenting the line DISABLE_IPV6: 'true'. We have mapped several directories from our host to the Docker for data and SQL storage.

We are using two networks here. One is the internal network npm-internal to connect the proxy manager and the database. This one is optional since it is automatically created. But here, we are doing it manually by giving it a name of our choice.

We have added an external network to the proxy manager container called npm-nw. This network is essential because you can use it to connect the proxy manager to any other docker containers you install. Using a network will allow you to connect any container directly without the need to expose its ports to the server.

Step 5 – Run Nginx Proxy Manager

Before launching the Docker container, we need to create the external network npm-nw. Internal networks are automatically created. Run the following command to create the external network.

$ docker network create npm-nw

Launch the Docker Container using the following command.

$ docker-compose up -d

Check the status of the containers.

$ docker ps
CONTAINER ID   IMAGE                             COMMAND                  CREATED              STATUS              PORTS                                                                                  NAMES
c91ca0ddca97   jc21/nginx-proxy-manager:latest   "/init"                  About a minute ago   Up About a minute   0.0.0.0:80-81->80-81/tcp, :::80-81->80-81/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   npm-app
1738d71b95da   mariadb:latest                    "docker-entrypoint.s…"   About a minute ago   Up About a minute   3306/tcp                                                                               npm-db

Step 6 – Access Nginx Proxy Manager

You can now access your Nginx proxy manager via the URL http://yourserverIP:81. You should get the following login screen.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Enter the following default credentials to sign in.

Email address: admin@exampl.com Password: changeme

Next, you will be immediately asked to set a name and an email address.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Click the Save button, and you will be asked to set a new password.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Click the Save button again, and you can now start using the application.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

If you open the URL http://yourserverIP in your browser, you will be taken to a default page that the proxy manager has set.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Step 7 – Setting up Domain Name and SSL for Nginx Proxy Manager

Let us set a domain name for accessing Nginx Proxy Manager. This step is optional but is useful if you want to put the application behind SSL.

Click on Hosts >> Proxy Hosts from the dashboard menu to open the Proxy Hosts page. From there, click on the Add Proxy Host button to proceed.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Add the FQDN name (npm.example.com) and click on it. Enter your Server’s IP address and 81 as the Forward Port.

Switch to the SSL tab.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Select Request a new SSL Certificate from the dropdown menu. Select the options Force SSL and HTTP/2 support. If you want to enable HSTS, you can enable that as well. If you have your domain configured via Cloudflare, don’t enable the option Force SSL otherwise, you will be stuck in a redirection loop.

Enter your email address, agree to the Let’s Encrypt Terms of Service (TOS) and click the Save button to finish.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Your domain should be live and working. Try opening https://npm.example.com in your browser, and you should get Nginx Proxy Manager’s login screen.

You can similarly do it for the default landing page and assign it to a domain name like https://example.com. Just change the port from 81 to 81 while setting up the proxy host.

Step 8 – Use Nginx Proxy Manager with another Docker web application

Now that we have installed the proxy manager, it is time to put it to some use. The first thing we will do is to use it to host another Docker web application. For this, we will be installing the Ghost blog. If you want to learn more, check our tutorial on installing Ghost using Docker on a Ubuntu server.

Create another directory for your Ghost blog.

$ mkdir ~/ghost

Switch to the Ghost directory.

$ cd ~/ghost

Create two directories for the content and the database.

$ mkdir {content,mysql}

Even if you are using the same MySQL image, you should keep the data and their containers separate from the Proxy manager’s. This will help isolate any issues you might run into and allow you to move stuff around in case you need to.

Create and open the Docker compose file for editing.

$ nano docker-compose.yml

Paste the following code. Replace example.com with your actual domain name for your Ghost blog. Enter SMTP details if you want to receive emails. You can remove them if you don’t need them.

version: '3.3'
services:

  ghost-app:
    image: ghost:latest
    container_name: ghost-app
    restart: always
    depends_on:
      - ghost-db
    environment:
      url: https://ghost.example.com
      database__client: mysql
      database__connection__host: ghost-db
      database__connection__user: ghost
      database__connection__password: ghostdbpass
      database__connection__database: ghostdb
      mail__transport: SMTP
      mail__options__host: {Your Mail Service host}
      mail__options__port: {Your Mail Service port}
      mail__options__secureConnection: {true/false}
      mail__options__service: {Your Mail Service}
      mail__options__auth__user: {Your User Name}
      mail__options__auth__pass: {Your Password}
    volumes:
      - /home/<username>/ghost/content:/var/lib/ghost/content
    networks:
      - npm-nw
      - ghost-network

  ghost-db:
    image: mariadb:latest
    container_name: ghost-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_mysql_root_password
      MYSQL_USER: ghost
      MYSQL_PASSWORD: ghostdbpass
      MYSQL_DATABASE: ghostdb
    volumes:
      - /home/<username>/ghost/mysql:/var/lib/mysql
    networks:
      - ghost-network

networks:
  ghost-network:
  npm-nw: 
    external: true

Save the file by pressing Ctrl + X and entering Y when prompted.

As you can see, we have connected the Ghost container with the Nginx proxy manager using the external network npm-nw. This way, we are not exposing the Ghost’s ports to the system. We have also used an internal network ghost-network to connect our Ghost app and the corresponding database container.

Start the container.

$ docker-compose up -d

Configure Ghost in Nginx Proxy Manager

Now, we need to set the reverse proxy for our Ghost install. Open Nginx Proxy manager in your browser, go to Dashboard >> Hosts >> Proxy Host, and add a new Proxy Host.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Add the domain name you chose for your Ghost blog. For the Hostname/IP value, enter the name of your container. In this case, it would be ghost-app. We cannot add the IP address here because we have not exposed Ghost’s port to the server, and the Nginx proxy won’t be able to reach Ghost via the IP. Hence, we use the container name, which NPM can access using Docker’s network npm-nw, which we created. Use 2368 as the port, the default port used by the Ghost Blog. Check the other options as shown in the screenshot above.

Next, switch to the SSL tab and create a new SSL certificate following step 6. Since you will be uploading content to your Ghost blog, setting a maximum upload size for your uploads would be good.

Fortunately, NPM allows you to add custom configurations. Switch to the Advanced tab and enter client_max_body_size 50m; in the box.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Click the Save button to finish adding the proxy host. You should be able to access your Ghost blog via the URL https://ghost.exampl.com

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Step 9 – Use Nginx Proxy Manager as a redirect service

Let’s see how you can use NPM to redirect one domain to another easily. To do so, visit Dashboard >> Hosts >> Redirection Hosts. From there, click on the Add Redirection Host button to get started.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Enter the domain name you want to forward. And enter the forwarding domain. The forwarding domain should already be configured. Leave the scheme as auto. Depending upon your requirement, you can choose http or https. Select the correct HTTP Code and check Preserve Path and Block Common Exploits options. If you are using an auto or https scheme, ensure you have selected or created an SSL certificate using NPM. Click Save to finish adding your redirection host.

Your domain example.com should start redirecting to blog.example.com.

Other uses of Nginx Proxy Manager

There are other two ways in which you can use Nginx Proxy Manager. You can use it as a 404 host, which means you can use a domain as a landing page to show the search engines that the domain pages don’t exist. The step includes just entering a domain and setup SSL for it. You can also use this as an opportunity to track the logs for the domain name and view the referrer traffic.

The other feature is to use NPM as a stream host. You can use this feature to forward TCP/UDP ports to another computer on the network. This is useful if you are hosting game servers. The only thing it requires is for you to enter the incoming port, forwarding domain or IP address, the forwarding port, and select the type of port.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Use Nginx Proxy Manager to host a static website

Nginx Proxy Manager can host simple static or dynamic websites as well. To do so, add a new proxy host and choose 127.0.0.1 as the Forward domain and 80 as the port.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Under the Advanced tab, enter the configuration specifying the root directory. Make sure the root directory for the site is mounted in the initial Docker compose configuration. Here we are using the /data/static directory to host our static website.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Click Save to finish, and your site should be accessible. You can similarly host any type of site using the proxy manager.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Step 10 – Miscellaneous Features

Use Nginx Proxy Manager’s Access Control Feature

You can use NPM’s Access Lists feature to enable HTTP authentication or block IP ranges. Open NPM and visit the Dashboard >> Access Lists page.

Click the Add Access List button to get started.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

You can name your Access List(ACL) configuration. The Satisfy Any tab, if checked, will allow access if the client fulfills any one of the conditions specified. If a client passes the HTTP authentication but may fail the IP-based access, it will be allowed. But if the Satisfy Any option is unchecked, the client will need to fulfill all the conditions.

The Pass Auth to Host feature will forward the authentication feature to the host server.

Next, switch to the Authorization tab. Here you can create a username and password for the HTTP authentication method. To add more than one user, click the Add button. You can only add up to 5 users. And there is a bug with the Add button so use the button first and then fill in the details. If you fill in the detail and click the button later to add another user, it clears the previous user data.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Switch to the Access tab. Here you can set which IP addresses are to be given or denied access.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Click Save to finish.

To use this Access list, you need to select it when adding your proxy host. Like in the example for Ghost Blog below, we have selected our access List.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Enable Support for more domain names

As the number of hosts and domains grows, your Nginx may run out of hash space or can run into memory problems. We can add a custom configuration that will apply to all the hosts to solve this issue.

To do this, create the directory custom inside ~/nginx-proxy/data/nginx.

$ sudo mkdir ~/nginx-proxy/data/nginx/custom

Create and open the file http.conf inside this directory.

$ sudo nano ~/nginx-proxy/data/nginx/custom/http.conf

Paste the following lines in it.

proxy_headers_hash_max_size 1024;
proxy_headers_hash_bucket_size 128;

Save the file by pressing Ctrl + X and entering Y when prompted.

Nginx should automatically accept these values. If it doesn’t happen, you can restart the NPM container using the following command.

$ docker restart npm-app

Redirect Default Landing Page

In step 6, you see the default page when you type the URL http://<yourserverIP>. If you want to change that, it is possible to do that. To do that, visit the Settings Page. Click the three dots on the right-hand side and click the Edit button.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

You can set the landing page to act as a 404 page, redirect page, or add custom HTML to it by using the option Custom Page. If you select Redirect, you will need to specify the target URL.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

This is the custom HTML we used for our purpose.

<!doctype html>
<html>
  <head>
    <title>Nothing Here</title>
    <meta charset="utf-8"/>
    <meta name="robots" content="noindex"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
      body { 
          text-align: center; 
          padding: 20px; 
          font: 20px Helvetica, sans-serif; 
          color: #333; 
        }
      @media (min-width: 768px){
          body{ padding-top: 150px; 
        }
      }
      h1 { 
          font-size: 50px; 
        }
      article { 
          display: block; 
          text-align: left; 
          max-width: 650px; 
          margin: 0 auto; 
        }
    </style>
  </head>
  <body>
    <article>
        <h1>Oops!</h1>
        <div>
            <p>Sorry for the inconvenience but you are not supposed to be here. You won't get anything here. This page was set for HowtoForge Nginx Proxy Manager Guide.  Maybe, someday it will show something.</p>
        </div>
    </article>
  </body>
</html>

Click Save to finish. Your landing page should be changed to something like the below.

Thiết kế hệ thống chuyên nghiệp OceanTech-Group ngcb9 How to Install and Use Nginx Proxy Manager with Docker Thủ thuật Nginx Proxy Manager

Step 11 – Update Nginx Proxy Manager

To update NPM, first, stop the containers.

$ cd ~/nginx-proxy
$ docker-compose down --remove-orphans

Pull the latest images.

$ docker-compose pull

Start the containers again.

$ docker-compose up -d


Conclusion


This concludes our tutorial where you installed Nginx Proxy Manager and learned how to use it to add a proxy host for another docker container, use it as a redirection service, and control access using it. If you have any questions, post them in the comments below.

wpChatIcon
wpChatIcon