แชร์ผ่าน


เพิ่ม CDC ฐานข้อมูล PostgreSQL เป็นแหล่งข้อมูลในฮับเวลาจริง

บทความนี้อธิบายวิธีการเพิ่มการเก็บข้อมูลการเปลี่ยนแปลงฐานข้อมูล PostgreSQL (CDC) เป็นแหล่งเหตุการณ์ใน Fabric Real-Time hub

ตัวเชื่อมต่อแหล่งข้อมูล PostgreSQL Change Data Capture (CDC) สําหรับเหตุการณ์สตรีมของ Microsoft Fabric ช่วยให้คุณสามารถจับภาพสแนปช็อตของข้อมูลปัจจุบันในฐานข้อมูล PostgreSQL ได้ ตัวเชื่อมต่อจะตรวจสอบและบันทึกการเปลี่ยนแปลงระดับแถวในอนาคตใดก็ตามในข้อมูลนี้

Prerequisites

Note

ไม่รองรับ CDC หลายตาราง

เปิดใช้งาน CDC ในฐานข้อมูล Azure ของคุณสําหรับ PostgreSQL

เมื่อต้องการเปิดใช้งาน CDC ในฐานข้อมูล Azure สําหรับ PostgreSQL ของคุณ ให้ทําตามขั้นตอนเหล่านี้ตามชนิดการปรับใช้ของคุณ

ฐานข้อมูล Azure สําหรับเซิร์ฟเวอร์เดี่ยว PostgreSQL

  1. Go to the Replication page on the Azure portal.

  2. Change the replication rule to Logical.

    สกรีนช็อตของการเปิดใช้งาน CDC สําหรับการปรับใช้เซิร์ฟเวอร์เดียว

ฐานข้อมูล Azure สําหรับเซิร์ฟเวอร์ที่ยืดหยุ่น PostgreSQL

  1. On your Azure Database for PostgreSQL flexible server page in the Azure portal, select Server parameters in the navigation menu.

  2. On the Server parameters page:

    • Set wal_level to logical.

    • Update the max_worker_processes to at least 16.

      สกรีนช็อตของการเปิดใช้งาน CDC สําหรับการปรับใช้เซิร์ฟเวอร์ที่ยืดหยุ่น

  3. บันทึกการเปลี่ยนแปลงและเริ่มเซิร์ฟเวอร์ใหม่

  4. ยืนยันว่าฐานข้อมูล Azure ของคุณสําหรับอินสแตนซ์เซิร์ฟเวอร์ที่ยืดหยุ่น PostgreSQL อนุญาตปริมาณการใช้งานเครือข่ายสาธารณะ

  5. ให้สิทธิ์การจําลองแบบแก่ผู้ใช้ที่เป็นผู้ดูแลระบบ โดยการเรียกใช้คําสั่ง SQL ต่อไปนี้

    ALTER ROLE <admin user> WITH REPLICATION;
    

รับเหตุการณ์จากฐานข้อมูล Azure สําหรับ PostgreSQL CDC

คุณสามารถรับเหตุการณ์จากฐานข้อมูล Azure สําหรับ PostgreSQL CDC ลงในฮับเรียลไทม์ ด้วยหนึ่งในวิธีต่อไปนี้:

หน้าแหล่งข้อมูล

  1. Sign in to Microsoft Fabric.

  2. If you see Power BI at the bottom-left of the page, switch to the Fabric workload by selecting Power BI and then by selecting Fabric.

    สกรีนช็อตที่แสดงวิธีการสลับไปยังปริมาณงาน Fabric

  3. Select Real-Time on the left navigation bar.

    สกรีนช็อตที่แสดงวิธีการเปิดใช้งานการเชื่อมต่อกับแหล่งข้อมูล

  4. On the Real-Time hub page, select + Data sources under Connect to on the left navigation menu.

    สกรีนช็อตที่แสดงหน้าแหล่งข้อมูลในฮับ Real-Time

    You can also get to the Data sources page from the Real-Time hub page by selecting the + Add data button in the top-right corner.

    สกรีนช็อตที่แสดงปุ่มเชื่อมต่อแหล่งข้อมูล

  1. On the Data sources page, select Microsoft sources category at the top, and then select Connect on the Azure DB for PostgreSQL (CDC) tile.

    สกรีนช็อตที่แสดงการเลือกฐานข้อมูล Azure (DB) สําหรับ PostgreSQL (CDC) เป็นชนิดแหล่งข้อมูลในหน้าแหล่งข้อมูล

    ใช้คําแนะนําจากเพิ่มฐานข้อมูล PostgreSQL CDC เป็นส่วนแหล่งที่มา

หน้าแหล่งที่มาของ Microsoft

  1. In Real-Time hub, select Microsoft sources.

  2. In the Source drop-down list, select PostgreSQL (CDC).

  3. For Subscription, select an Azure subscription that has the resource group with your PostgreSQL Database account.

  4. For Resource group, select a resource group that has the database.

  5. For Region, select a location where your database is located.

  6. Now, move the mouse over the name of the PostgreSQL Database CDC source that you want to connect to Real-Time hub in the list of databases, and select the Connect button, or select ... (ellipsis), and then select the Connect button.

    สกรีนช็อตที่แสดงหน้าแหล่งที่มาของ Microsoft พร้อมตัวกรองเพื่อแสดง Azure PostgreSQL CDC และปุ่มเชื่อมต่อ

    หากต้องการกําหนดค่าข้อมูลการเชื่อมต่อ ให้ใช้ขั้นตอนจากเพิ่มฐานข้อมูล Azure สําหรับ PostgreSQL CDC เป็นส่วนต้นทาง

เพิ่มฐานข้อมูล Azure สําหรับ PostgreSQL CDC เป็นแหล่งข้อมูล

  1. On the Connect page, select New connection.

    สกรีนช็อตที่แสดงหน้าเชื่อมต่อสําหรับฐานข้อมูล Azure PostgreSQL ที่มีลิงก์การเชื่อมต่อใหม่ที่เน้น

    If you have an existing connection to your Azure Database for PostgreSQL CDC source, you can select it from the Connection drop-down list, and move on to configuring port and tables.

    สกรีนช็อตที่แสดงหน้าเชื่อมต่อด้วยการเชื่อมต่อที่มีอยู่ที่เลือก

  2. In the Connection settings section, enter the following information.

    • Server: The server address of your PostgreSQL database, for example my-pgsql-server.postgres.database.azure.com.

    • Database: The database name, for example my_database.

      สกรีนช็อตที่แสดงส่วนการตั้งค่าการเชื่อมต่อสําหรับตัวเชื่อมต่อฐานข้อมูล Azure PostgreSQL

  3. Scroll down, and in the Connection credentials section, follow these steps.

    1. For Connection name, enter a name for the connection.

    2. For Authentication kind, select Basic.

      Note

      Currently, Fabric eventstreams supports only Basic authentication.

    3. Enter Username and Password for the database.

    4. Select Connect.

      สกรีนช็อตที่แสดงส่วนข้อมูลประจําตัวการเชื่อมต่อสําหรับตัวเชื่อมต่อฐานข้อมูล Azure PostgreSQL

  4. Now, on the Connect page, do these steps:

    1. For table, Enter a table name.

    2. For Port, enter the port number or leave the default value: 5432.

    3. For eventstream name, enter a name for the eventstream. ตัวช่วยสร้างจะสร้างเหตุการณ์สตรีมด้วย CDC ฐานข้อมูล PostgreSQL ที่เลือกเป็นแหล่งข้อมูล

    4. The Stream name is automatically generated for you by appending -stream to the name of the eventstream. คุณเห็นสตรีมนี้บนหน้า สตรีม ข้อมูลทั้งหมดเมื่อตัวช่วยสร้างเสร็จสิ้น

    5. Select Next at the bottom of the page.

      สกรีนช็อตที่แสดงหน้าเชื่อมต่อที่เติมสําหรับตัวเชื่อมต่อฐานข้อมูล Azure PostgreSQL

  5. บนหน้า ตรวจสอบ + เชื่อมต่อ ให้ตรวจสอบสรุป จากนั้นเลือก เชื่อมต่อ

    สกรีนช็อตที่แสดงหน้าตรวจสอบ + เชื่อมต่อที่เติมสําหรับตัวเชื่อมต่อฐานข้อมูล Azure PostgreSQL

ดูรายละเอียดสตรีมข้อมูล

  1. บนหน้า ตรวจสอบ + เชื่อมต่อ ถ้าคุณเลือก เปิดเหตุการณ์ สตรีมตัวช่วยสร้างจะเปิดเหตุการณ์ที่สร้างขึ้นให้คุณด้วย CDC ฐานข้อมูล PostgreSQL ที่เลือกเป็นแหล่งข้อมูล To close the wizard, select Finish at the bottom of the page.

    สกรีนช็อตที่แสดงหน้าตรวจสอบ + เชื่อมต่อความสําเร็จ

  2. คุณควรเห็นสตรีมในส่วนข้อมูลการสตรีมล่าสุดของโฮมเพจฮับReal-Time สําหรับขั้นตอนโดยละเอียด ดูรายละเอียดของสตรีมข้อมูลใน Fabric Real-Time hub

หากต้องการเรียนรู้เกี่ยวกับการใช้สตรีมข้อมูล โปรดดูบทความต่อไปนี้: