<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rapepat Pengsart on Medium]]></title>
        <description><![CDATA[Stories by Rapepat Pengsart on Medium]]></description>
        <link>https://medium.com/@rapepatpengsart?source=rss-d64be138bac7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*q55KH8-4byK6pTvGqc6KoA.png</url>
            <title>Stories by Rapepat Pengsart on Medium</title>
            <link>https://medium.com/@rapepatpengsart?source=rss-d64be138bac7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 10:14:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rapepatpengsart/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[การใช้งาน Ansible Automation Platform]]></title>
            <link>https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-ansible-automation-platform-cdc2c15901ca?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdc2c15901ca</guid>
            <category><![CDATA[ansible-automation]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 22:19:44 GMT</pubDate>
            <atom:updated>2026-08-26T22:22:55.485Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BL_B3JAWKWfZ7xCf2jcJw.png" /></figure><p>การใช้งานเบื้องต้นของ Ansible Automation Platform โดยใน Demo นี้เราจะทำการจำลองการใช้งานด้วยการใช้ Playbook บน github ของ <a href="https://github.com/ansible-lockdown/UBUNTU24-CIS">https://github.com/ansible-lockdown/UBUNTU24-CIS</a> ในการทำ Audit และ Remidation ตัว Ubuntu server 24 ให้เป็นไปตาม Security Configuration Guidelines ของ CIS Benmark</p><p>Step 1: Create Project <br>สร้าง Project เพื่อกำหนด Playbook Ansible ที่จะนำมาใช้งาน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9mj1lvEYHGnKG0MTj7IlqQ.png" /></figure><ul><li>เริ่มสร้าง Project โดยกดที่ Project ทางลิสด้านขวา จากนั้นกด Create Project จากนั้นทำการใส่ข้อมูลดังนี้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etZmCnHRSCH4YRVagiNlwg.png" /></figure><pre>Name: ตั้งชื่อของ Project ที่จะสร้าง<br>Organization:  เลือกเป็น Default<br>Execution environment:  เลือก Default execution environment<br>Source control type: เลือกเป็น Git<br>Source control URL: ใส่เป็น link ของ playbook ที่อยู่บน Github ตัวอย่างเช่น https://github.com/ansible-lockdown/UBUNTU24-CIS.git<br>Source control branch/tag/commit: ใส่เป็น branch ของ repo git ที่เราต้องการ โดยในที่นี้ใช้ branch devel<br>Source control credential: ถ้าเราใช้ repo ที่เป็น public เราไม่จำเป็นต้องใส่ credential ของ repo นั้นลงไป แต่ถ้าเราใช้ github หรือ gitlab ที่เป็น private repo เราต้องใส่ โดยเราจะต้องไปสร้างที่เมนู credential ก่อนโดยเลือก credential type เป็น source control ตามรูปด้านล่าง<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sa0sBzzKgxBPUkqpiR8Eug.png" /></figure><ul><li>เมื่อเสร็จเรียบร้อย Project ของเราก็จะขึ้นมา โดยรอระยะเวลาสักนิดนึง ให้ตัว Ansible Automation Platform ทำการดึง playbook จาก git นำมาใช้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-jOO3ML6NkMsxGZJsb_-jw.png" /></figure><p>Step 2: Create Inventory<br>สร้าง Inventory ไว้สำหรับเก็บ hosts ปลายทางที่จะทำการ remote configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7iQXzp6VyZfGaSemNvYD1g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E3Lz8eL4qofaYJEv0bR5mA.png" /></figure><pre>Name: ตั้งชื่อ Inventory <br>Organization: ตั้งเป็น Default</pre><p>Step 3: Create hosts<br>เพิ่ม hosts ปลายทางที่จะทำการ remote configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*689WmMki1f-oskH2jFe0dA.png" /></figure><ul><li>กดสร้างแบบ create host ธรรมดา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rko1L7ihNHA7Ca4aRzPChw.png" /></figure><pre>Name: ใส่เป็น IP หรือกำหนดชื่อ hosts ที่ต้องการเองได้เลย<br>Inventory: เลือก inventory ที่เราสร้างไว้ใน step ก่อนหน้า<br>Variables: ใส่ ansible_host: IP เครื่องที่เราจะ remote config ถ้าเราไม่ได้ตั้งชื่อ Name เป็น IP หรือ domain ที่เครื่องนี้รู้จัก</pre><p>Step 4: Create Credentials <br>สร้าง Credentials ของ hosts ปลายทาง เพื่อให้ Ansible สามารถทำการ access เข้าเครื่องที่ต้องการ remote configuration ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AHrG1jnEZNPUm-xqNo2xg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HmkLKfz0mWxrFxmh02FbXg.png" /></figure><pre>Name: ตั้งชื่อของ credential ที่จะสร้าง<br>Organization: ตั้งเป็น Default<br>Credential type: พิมพ์ Machine แล้วกดเลือก<br>Username: username ของเครื่อง remote host ปลายทาง<br>Password: password ของเครื่อง remote host ปลายทาง<br>Privilege Escalation Method: เลือกเป็น sudo<br>Privilege Escalation Username: sudo username ของเครื่อง remote host ปลายทาง<br>Privilege Escalation Password: sudo password ของเครื่อง remote host ปลายทาง  </pre><p>Step 5: Create Template <br>ส่วนประกอบทั้ง Ansible Playbook, Inventory, Hosts, Credential ครบแล้ว เราจะนำทั้งหมดมาประกอบร่างกันที่ Template</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlvNmGdiRtyilskDYBCqeQ.png" /></figure><ul><li>กดสร้างแบบ create job template</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67eEBDCLi3Wp5h4O35Y0Ww.png" /></figure><pre>Name: ตั้งชื่อของ template job ที่จะสร้าง<br>Job type: run<br>Inventory: เลือก inventory ที่เราสร้าง<br>Project: เลือก project ที่เราสร้าง<br>Playbook: เลือก playbook ansible ที่เราจะ run โดยใน repo นี้เราจะเลือก site.yml<br>Execution environment: default execution environment<br>Credentials: เลือก credential ที่เราสร้างของ hosts ที่เราจะทำการ remote config ไป<br><br>Extra variables:  ansible_become: true<br>                  ansible_become_method: sudo<br>                  ansible_become_user: root<br><br>Options: Privilege escalation</pre><p>Step 6: ทำการกด Launch Template<br>เพื่อสั่งให้ Ansible ไปทำการ remote config ตามที่เราตั้งค่าไว้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4vknY45fRs80ze29grWt1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8YHoEPkeGtXX42vcUU7oQ.png" /></figure><ul><li>เมื่อ run เสร็จสิ้น remote hosts ปลายทางของเรา ก็จะได้รับการตั้งค่าตาม config ที่เขียนใน playbook cis benchmark ubuntu24</li></ul><p>เสร็จเรียบร้อยกับการตั้งค่าและใช้งานเบื้องต้นของ Ansible Automation Platform<br>นี้เป็นแค่ demo คร่าวๆ เท่านั้น ตัว Ansible Automation Platform + gitlab ที่ใช้สำหรับทำ Version Control ตัว playbook สามารถประยุกต์ใช้งานได้หลากหลาย usecase มากๆ ทั้งการ patch, maintain, deploy ได้หลายๆ remote hosts เป็นทำให้สะดวกอย่างมากในการใช้ทำงานแบบ full Automation ในการดูแลระบบ server, network, อุปกรณ์ IOT ต่างๆ เพียงแค่เครื่อง remote มีแค่ python ลงไว้ก็สามารถสั่งงานได้</p><p>ถ้าใครมีจุดที่สงสัยหรือติดปัญหาอ่ะไรสามารถสอบถามเพิ่มเติมได้เลยนะครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdc2c15901ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การติดตั้ง Ansible Automation Platform]]></title>
            <link>https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-ansible-automation-platform-8a432f05f18a?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a432f05f18a</guid>
            <category><![CDATA[ansible-automation]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 19:32:44 GMT</pubDate>
            <atom:updated>2026-08-26T22:25:10.957Z</atom:updated>
            <content:encoded><![CDATA[<p>Ansible Automation Platform เป็น platfrom สำหรับการบริหารจัดการระบบ Automation ในระดับองค์กร (ซึ่งจริงๆ เราที่เป็น indiviual หรือผู้ใช้งานทั่วไปสามารถใช้งานได้ฟรีผ่าน Red Hat Developer Subscription for Individuals โดยสามารถสั่งการงานหรือควบคุมเครื่อง remote สูงสุดได้ 16 node และสามารถลบ node เก่าที่สั่งไปแล้วเพื่อเพิ่ม node ใหม่แทนได้)</p><p>ข้อดีของ Ansible Automation Platform คือช่วยเสริมความสามารถให้กับ Ansible ได้ใช้งานสะดวกและมีประสิทธิภาพสูงขึ้นดังนี้ <br>1. สามารถ integration ร่วมกับ Gitlab, Github เพื่อช่วยเก็บและทำ version control ของ Ansible Configuration ทำให้สามารถ update config, hosts, variable หรือ parameter อื่นๆ ได้สะดวก <br>เราสามารถแก้ไข config -&gt; อัพขึ้น git -&gt; แล้วสั่งการใน Ansible Automation Platform ได้ทันที โดยก่อนที่จะสั่งงานไปที่เครื่องปลายทางมันจะทำการ syc และอัพเดท config ใหม่ตามบน git ให้เราอัตโนมัติ</p><p>2. สามารถแก้ไข config, hosts, variable หรือ parameter บน Ansible Automation Platform ได้ โดยค่าที่เราตั้งบนนี้ จะไปทับค่า default เดิมที่มาจาก git ทำให้เราสามารถดึง git repo ที่น่าสนใจจากภายนอกมาใช้งานได้เลยโดยที่เราไม่ต้อง fork มาเป็นของเราเอง <br>[ ตัวอย่าง git repo ที่น่าสนใจเช่น <a href="https://github.com/ansible-lockdown/UBUNTU24-CIS">https://github.com/ansible-lockdown/UBUNTU24-CIS</a> ]</p><p>3. มีหน้า Dashboard GUI และ function ที่สามารถใช้งานได้ครบถ้วน โดยที่เราไม่ต้องใช้ shell command หรือพิมพ์มือสั่ง เราสามารถบริหารจัดการ Ansible ได้ผ่านเมนู GUI ทั้งหมด</p><p>Step 0: สมัคร Red Hat Developer Subscription for Individuals สำหรับโหลดตัวติดตั้ง Ansible Automation Platform</p><ul><li>สามารถกดสมัครได้ที่ <a href="https://developers.redhat.com/">https://developers.redhat.com/</a></li><li>สามารถทำการ renew subscriptions สิทธิ์ developer ได้ที่ <a href="https://developers.redhat.com/d4i-renewal">https://developers.redhat.com/d4i-renewal</a></li></ul><p>Step 1: ทำการ download ตัว Download Ansible Automation Platform โดยการ download จะมีอยู่สามแบบด้วยกันคือ</p><ul><li>Download แบบเฉพาะตัว Ansible Automation Platform เพื่อนำไปติดตั้งบน Redhat Enterprise Linux ที่เราเตรียมไว้ (โดยในที่นี้เราจะใช้วิธีการนี้ ซึ่งตัว Redhat Enterprise Linux เราก็สามารถใช้สิทธิ์ Red Hat Developer Subscription for Individuals ดาวน์โหลดมาใช้ได้ฟรีเช่นเดียวกัน)</li><li>Download แบบ Ansible Automation Platform พร้อมระบบปฏิบัติการ โดยเราจะได้ไฟล์ของ OS ที่ติดตั้ง Ansible Automation Platform พร้อมมาเลยข้างใน</li></ul><p>Step 2: เมื่อดาวน์โหลดไฟล์มาเรียบร้อยแล้วให้ทำการโยนไฟล์ไปที่เครื่อง Redhat Enterprise Linux</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*c6aDgRRvhCVJnA0Aokj51g.png" /></figure><p>จากนั้นทำการแตกไฟล์ออกมาเราจะได้ directory สำหรับตัวติดตั้งมาโดยภายใน directory นั้น จะมีไฟล์ดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*XUZbOpX9PRf8YjBHZrW1mA.png" /></figure><p>Step 3: เข้าไปที่ไฟล์ inventory-growth เพื่อทำการแก้ไข parameter ภายในไฟล์ config เพื่อติดตั้ง</p><pre>cd ansible-automation-platform-containerized-setup-2.7-3<br>vi inventory-growth</pre><pre># This is the AAP installer inventory file intended for the Container growth deployment topology.<br># This inventory file expects to be run from the host where AAP will be installed.<br># Please consult the Ansible Automation Platform product documentation about this topology&#39;s tested hardware configuration.<br># https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.7/plan-ref_installation_deployment_models<br>#<br># Please consult the docs if you&#39;re unsure what to add<br># For all optional variables please consult the included README.md<br># or the Ansible Automation Platform documentation:<br># https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.7/install-con_aap_containerized_installation_intro<br><br># This section is for your AAP Gateway host(s)<br># -----------------------------------------------------<br>[automationgateway]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br># This section is for your AAP Controller host(s)<br># -----------------------------------------------------<br>[automationcontroller]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br># This section is for your AAP Automation Hub host(s)<br># -----------------------------------------------------<br>[automationhub]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br># This section is for your AAP EDA Controller host(s)<br># -----------------------------------------------------<br>[automationeda]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br># This section is for your AAP Automation Metrics Service host(s)<br># -----------------------------------------------------<br>[automationmetrics]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br># This section is for your AAP Lightspeed host(s)<br># -----------------------------------------------------<br># [ansiblelightspeed]<br># aap.example.org<br><br># This section is for your Ansible MCP Server host(s)<br># -----------------------------------------------------<br># [ansiblemcp]<br># aap.example.org<br><br># This section is for the AAP database<br># -----------------------------------------------------<br>[database]<br>aap.internal.xxxx.cloud                        #ใส่ domain name ที่จะให้ AAP ใช้<br><br>[all:vars]<br># Ansible<br>ansible_connection=local<br><br># For a comprehensive list of all inventory file variables, see:<br># https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.7/install-assembly_appendix_inventory_file_vars<br><br># Common variables<br># -----------------------------------------------------<br>postgresql_admin_username=postgres<br>postgresql_admin_password=                #กำหนด pass ของ database ให้ AAP ใช้<br><br>registry_username=                        #ใส่ user redhat ของเราที่สมัคร<br>registry_password=                        #ใส่ pass redhat ของเราที่สมัคร<br><br>redis_mode=standalone<br><br># AAP Gateway<br># -----------------------------------------------------<br>gateway_admin_password=         #กำหนด pass สำหรับ login เข้าหน้า webapp ของ AAP<br>gateway_pg_host=aap.internal.xxxx.cloud          #ใส่ domain name ที่จะให้ AAP ใช้<br>gateway_pg_password=            #กำหนด pass ของ database gateway ที่จะให้ AAP ใช้<br><br># AAP Controller<br># -----------------------------------------------------<br>controller_admin_password=      #กำหนด pass ของ controller ที่จะให้ AAP ใช้<br>controller_pg_host=aap.internal.xxxx.cloud      #ใส่ domain name ที่จะให้ AAP ใช้<br>controller_pg_password=         #กำหนด pass ของ controller_pg ที่จะให้ AAP ใช้<br>controller_percent_memory_capacity=0.5<br><br># AAP Automation Hub<br># -----------------------------------------------------<br>hub_admin_password=             #กำหนด pass ของ hub ที่จะให้ AAP ใช้<br>hub_pg_host=aap.internal.xxxx.cloud            #ใส่ domain name ที่จะให้ AAP ใช้<br>hub_pg_password=                #กำหนด pass ของ hub_pg ให้ AAP ใช้<br>hub_seed_collections=false<br><br># AAP EDA Controller<br># -----------------------------------------------------<br>eda_admin_password=             #กำหนด pass ของ eda ให้ AAP ใช้<br>eda_pg_host=aap.internal.xxxx.cloud            #ใส่ domain name ที่จะให้ AAP ใช้<br>eda_pg_password=                #กำหนด pass ของ eda_pg ให้ AAP ใช้<br><br># AAP Automation Metrics Service<br># -----------------------------------------------------<br>automationmetrics_pg_host=aap.internal.xxxx.cloud      #ใส่ domain name ที่จะให้ AAP ใช้<br>automationmetrics_pg_password=     #กำหนด pass ของ metric_pg ที่จะให้ AAP ใช้ <br>automationmetrics_controller_read_pg_host=aap.internal.xxxx.cloud      #ใส่ domain name ที่จะให้ AAP ใช้<br>automationmetrics_controller_read_pg_password=     #กำหนด pass ของ metric_controler ที่จะให้ AAP ใช้</pre><p>Step 4: ติดตั้ง Ansible Automation Platform</p><pre>sudo dnf update<br>sudo dnf upgrade<br>sudo dnf install -y ansible-core<br>cd ansible-automation-platform-containerized-setup-2.7-3<br>ansible-playbook -i inventory-growth -K -v ansible.containerized_installer.install</pre><p>Step 5: เมื่อทำการติดตั้งเสร็จสิ้นให้ทำการแก้ไขไฟล์ hosts ของเครื่อง ทั้งเครื่องบน server ที่เราติดตั้ง Ansible Automation Platform และเครื่อง labtop ของเราที่จะใช้เข้าหน้าเว็บของ Ansible Automation Platform (เนื่องจากผมไม่ได้ทำการจดโดเมน ใช้ทำ Lab ทดสอบเอง ถ้าใครจด domain ไว้และผูกกับ ip เครื่องอยู่แล้วสามารถข้ามผ่านไปได้เลย)</p><ul><li>เครื่อง server RHEL</li></ul><pre>vi /etc/hosts</pre><pre>127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4<br>10.0.0.1   aap.internal.xxxx.cloud #เพิ่ม ip ของเครื่อง และ domain ที่เราให้ AAP ใช้ในตอนตั้งค่า config ที่ไฟล์ inventory-growth<br>::1         localhost localhost.localdomain localhost6 localhost6.localdomain6</pre><ul><li>เครื่อง labtop ของเรา</li></ul><p>เข้าไฟล์ hosts ของ windows ได้ที่ C:\Windows\System32\drivers\etc\hosts</p><pre># Copyright (c) 1993-2009 Microsoft Corp.<br>#<br># This is a sample HOSTS file used by Microsoft TCP/IP for Windows.<br>#<br># This file contains the mappings of IP addresses to host names. Each<br># entry should be kept on an individual line. The IP address should<br># be placed in the first column followed by the corresponding host name.<br># The IP address and the host name should be separated by at least one<br># space.<br>#<br># Additionally, comments (such as these) may be inserted on individual<br># lines or following the machine name denoted by a &#39;#&#39; symbol.<br>#<br># For example:<br>#<br>#      102.54.94.97     rhino.acme.com          # source server<br>#       38.25.63.10     x.acme.com              # x client host<br><br># localhost name resolution is handled within DNS itself.<br># 127.0.0.1       localhost<br># ::1             localhost<br>10.0.0.1   aap.internal.xxxx.cloud<br># End of section</pre><p>Step 6: เข้าหน้าเว็บของ Ansible Automation Platform เพื่อตั้งค่า Subscription ในการใช้งาน Ansible Automation Platform</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ezLqzEh0JV0yFS0Yn3WyAA.png" /></figure><p>เมื่อทำการตั้งค่าทุกอย่างเรียบร้อย เราก็จะสามารถใช้ Ansible Automation Platform ได้แล้ว โดยเนื้อหาถัดไปจะเป็น<a href="https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-ansible-automation-platform-cdc2c15901ca?sharedUserId=rapepatpengsart"> demo การใช้งาน Ansible Automation Platform</a> ครับ</p><p><a href="https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-ansible-automation-platform-cdc2c15901ca">การใช้งาน Ansible Automation Platform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a432f05f18a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การติดตั้ง SQL Server on-premises พร้อมกับทำ SQL Server AlwaysON บน Windows Server 2019]]></title>
            <link>https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-sql-server-on-premises-%E0%B8%9E%E0%B8%A3%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%81%E0%B8%B1%E0%B8%9A%E0%B8%97%E0%B8%B3-sql-server-alwayson-%E0%B8%9A%E0%B8%99-windows-server-2019-c681d95e0151?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c681d95e0151</guid>
            <category><![CDATA[microsoft-sql-server]]></category>
            <category><![CDATA[windows-server]]></category>
            <category><![CDATA[failover-cluster]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Tue, 25 Aug 2026 10:12:09 GMT</pubDate>
            <atom:updated>2026-08-25T10:14:51.352Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>SQL Server </strong>คือระบบ Database Management System ที่ทำงานอยู่บน Windows Server</p><p><strong>AlwaysON</strong> คือ Service ของ SQL Server ที่มีการใช้งานระบบ Failover Clustering ของ Windows Server เพื่อทำ High Availability ในรูปแบบของ Master-Backup ระหว่าง SQL Server ด้วยกัน</p><p>โดยการติดตั้งแบบ SQL Server แบบ AlwaysOn จำเป็นต้องมีเครื่อง VM หรือ Server เบี้ยงต้นดังต่อไปนี้</p><ul><li>Active Directory Node 1 เครื่อง</li><li>SQL Server Node 2 เครื่อง</li></ul><p>และการติดตั้งจะมีขั้นตอนหลักๆ จะมีอยู่ 4 ขั้นตอนใหญ่</p><ul><li>การจัดการ Firewall Port</li><li>การตั้งค่า Active Directory</li><li>การตั้งค่า Failover Clustering</li><li>การติดตั้งและตั้งค่า SQL Server on-premises พร้อมกับทำ AlwaysON</li></ul><h3><strong>Resource</strong></h3><ul><li>Active Directory Node 1 เครื่อง<br>OS: Windows Server 2019<br>CPU: 4<br>Memory: 8 GB<br>Disk: 100</li><li>SQL Server Node 2 เครื่อง<br>OS: Windows Server 2019<br>CPU: 4<br>Memory: 8 GB<br>Disk: 200</li></ul><h3>IP Address</h3><ul><li>Active Directory (IP)<br>- 10.0.0.100 เครื่อง Active Directory node</li><li>SQL Server (IP)<br>- 10.0.0.1 เครื่อง SQL Server node 1 (Master)<br>- 10.0.0.2 เครื่อง SQL Server node 2 (Backup)</li><li>Failover Cluster (Virtual IP) <br>- 10.0.0.10</li><li>AlwaysON (Virtual IP)<br>- 10.0.0.11</li></ul><h3><strong>Installation</strong></h3><h3><strong>Step 1: การตั้งค่า Firewall ของ Windows Server</strong></h3><p>Port ที่ต้องทำการเพิ่มในแต่ละ Node</p><ol><li>Active Directory Node<br>- TCP : 21, 53, 80, 135, 139, 389, 443, 445, 636, 1433, 1434, 3268, 3269, 3343, 4022, 5022, 5000–5099, 7022, 8011–8031 <br>- UDP: 53, 135, 137, 138, 389, 500, 1434, 3343, 4500, 5000–5099, 8011–8031</li><li>SQL Server Node (Master)<br>- TCP : 21, 53, 80, 135, 139, 389, 443, 445, 636, 1433, 1434, 3268, 3269, 3343, 4022, 5022, 5000–5099, 7022, 8011–8031<br>- UDP: 53, 135, 137, 138, 389, 500, 1434, 3343, 4500, 5000–5099, 8011–8031</li><li>SQL Server Node (Backup)<br>- TCP : 21, 53, 80, 135, 139, 389, 443, 445, 636, 1433, 1434, 3268, 3269, 3343, 4022, 5022, 5000–5099, 7022, 8011–8031<br>- UDP: 53, 135, 137, 138, 389, 500, 1434, 3343, 4500, 5000–5099, 8011–8031</li></ol><p>รายละเอียดของ Port สามารถอ่านได้ตามใน ref ด้านล่างนี้</p><ul><li><a href="https://learn.microsoft.com/en-us/sql/sql-server/install/configure-the-windows-firewall-to-allow-sql-server-access?view=sql-server-ver16">Configure the Windows Firewall to allow SQL Server access - SQL Server</a></li><li><a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc728293(v=ws.10)">Enable a network for cluster use: Server Clusters (MSCS)</a></li></ul><ul><li>พิมพ์ในช่อง search ของ Windows Server ว่า “Windows Defender Firewall with Advanced Security” แล้วคลิกเข้าไป</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*zbQVu-0thWHhJCeq" /></figure><ul><li>กดคลิกขวาที่ Inbound Rules แล้วเลือก New Rule</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*YTqDONJWO4CWTVwH" /></figure><ul><li>กดเลือก Port แล้วกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ZjPaWSSeqSzRqxn_" /></figure><ul><li>กดเลือกประเภท Port และพิมพ์เลข Port ที่ต้องการกำหนดกฎใน Firewall เมื่อเสร็จเรียบร้อยแล้วกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*I3cTqxbHXg-3ddZi" /></figure><ul><li>ตั้งค่ากฎของ Port ที่ทำการใส่ลงไป โดยเลือก Allow the connection เพื่อให้ Service สามารถติดต่อกับภายนอกได้ เมื่อตั้งค่าเรียบร้อย Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*OY2m3TRQoRJbT4v3" /></figure><ul><li>กำหนดว่ากฎนี้ให้ใช้กับ computer ที่เชื่อมต่อจากกลุ่ม network ไหนได้บ้าง เสร็จแล้วกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*uXedHcVkFHSKKSvd" /></figure><ul><li>ตั้งชื่อกฎที่สร้างขึ้น เสร็จเรียบร้อยกด Finish</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*doVQ6kCIBOMtTGFr" /></figure><ul><li>เมื่อทำการเพิ่มเสร็จสิ้นจะมีกฎที่เราสร้างเพิ่มขึ้นมา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7dd_yJaMS7V30snC" /></figure><h3>Step 2: ตั้งค่า Active Directory ของ Windows Server</h3><h4><strong>2.1 การติดตั้ง Active Directory</strong></h4><ul><li>ตอนเริ่มต้น Windows Server จะยังไม่ได้ติดตั้ง Service Active Directory มาให้เราจึงต้องทำการติดตั้งก่อน โดยการกด “Add roles and features” ที่หน้า Server Manager Dashboard ของ Windows Server</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*TkT6P_J0usFPj4ok" /></figure><ul><li>อ่านรายละเอียดหน้าต่างที่เด่งขึ้นมาแล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*L9NAhxTqXEqCadir" /></figure><ul><li>เลือก “Role-based or feature-based installation” แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*-4WyfxUghYA9qY2J" /></figure><ul><li>กด “Select a server from the server pool” จากนั้นเลือก Server (โดยในรูปคือตัว local เอง) ที่ต้องการติดตั้ง Active Directory Service เมื่อเลือกเรียบร้อยก็กด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cdh-HyObwrp9H_EhxYu2OQ.png" /></figure><ul><li>เลือก Server Role เป็น “Active Directory Domain Service” เพื่อติดตั้ง service Active Directory จากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*QYCrkXQrkqdSAUHO" /></figure><ul><li>ต่อมาจะเป็นเลือก Features ที่จะเพิ่มลงบน Windows Server ไม่จำเป็นต้องกดอ่ะไรเพิ่มเติม สามารถกด “Next” ไปต่อได้เลย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*76My-gpcXn3cijeY" /></figure><ul><li>กดเลือก “Restart the destination server automatically if require” เพื่อให้ service หลังจากติดตั้งเสร็จทำการ Restart ด้วยตัวเอง จากนั้นกด “install”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*_PPWHw1DZqdLyHf-" /></figure><ul><li>เมื่อติดตั้งเสร็จเรียบร้อยจะมีประโยคสีฟ้า “Promote this server to a domain controller” ขึ้นมา ให้ทำการกดเข้าไป</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZdA7gLbCCJt89JHC3EGRIA.png" /></figure><ul><li>ทำการเลือก deployment operation แบบ “Add a new forest” และตั้งชื่อ Root domain name ของ Active Directory Domain Service หลังจากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GFeLuGVIJl4csRllm-_5zw.png" /></figure><ul><li>ตั้ง password สำหรับ Directory Service Restore Mode หลังจากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*x-iK90vRMuQOvjxR" /></figure><ul><li>ข้ามการสร้าง DNS delegation กด “Next” ต่อไปได้เลย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*BNHTBg2k6YAEoVsX" /></figure><ul><li>รอ Verify the NetBIOS name สักครู่ เมื่อเสร็จเรียบร้อย The NetBIOS domain name จะขึ้นมาแสดงที่ช่องเอง หลังจากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZrsP_cUdyt3DES0FfJTBw.png" /></figure><ul><li>ตั้งค่าตำแหน่ง folder ที่เก็บ database, log file, SYSVOL ของ Active Directory Domain Service หลังจากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*OUOlO74D-mikLkhe" /></figure><ul><li>ตรวจสอบหน้าสรุปการตั้งค่าหลังจากนั้นกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvXTVbKeHXVKENqgm0mb0Q.png" /></figure><ul><li>ตรวจสอบ alert ว่าไม่มีผลกระทบต่อการติดตั้ง Active Directory แล้วกด “Install” ได้เลย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZqpEfKFxQ3_PxVIgntDxg.png" /></figure><ul><li>เมื่อทำการติดตั้งเสร็จสิ้น เครื่องที่ทำการติดตั้งจะทำการ Restart อัตโนมัติ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*I7zIaLMjUPK9Sk96" /></figure><ul><li>เมื่อติดตั้งและ restart เสร็จเรียบร้อยจะมี Service AD DS และ DNS เพิ่มขึ้นมา</li></ul><h4>2.2 การตั้งค่า Active Directory (ทำที่เครื่อง Active Directory)</h4><ul><li>เข้าหน้า Server Manager Dashboard จากนั้นไปที่ Tab manu ทางด้านบนขวาเลือก “Tools” จะมี drop down ลงมา หลังจากนั้นก็เลือก “Active Directory Users and Computers”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-as8diLxqM6mVXUK60mcdQ.png" /></figure><ul><li>กดคลิกขวาที่ชื่อของ root domain ที่เราทำการตั้งไว้เมื่อตอนติดตั้ง Active Directory Domain Service จะมี drop down ลงมาให้ทำการเลือก “New” จากนั้นเลือกไปที่ “Organization Unit”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kb-Og29W5U_L3HGbQB27Kw.png" /></figure><ul><li>ตั้งชื่อ Organization Unit โดยเราจะใช้ Organization Unit ตัวนี้ในการเก็บรวม Host ของ Database และ User ที่เกี่ยวข้องทั้งกับระบบที่จำเป็นต้องใช้งานทั้งหมดเพื่อให้สามารถดูแลจัดการได้ง่าย</li><li>เอา “Protect container from accidental deletion” ออก ถ้าต้องการให้สามารถลบ Organization Unit นี้ได้เลยโดยไม่ติดการป้องกันการเผลอลบ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Qot1zfULp4Ws_RjTZJB1w.png" /></figure><ul><li>กดคลิกขวาที่ Organization Unit ที่เราสร้าง จะมี drop down ให้เลือก “New” จากนั้นไปที่ “User” เพื่อสร้าง User</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmO6Rz6OhsE8RmEwU0AvDA.png" /></figure><ul><li>ตั้งชื่อของ User แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxVwPPZdDH8x_Ytv6BplRw.png" /></figure><ul><li>ตั้ง Password แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rY2n2EOFQMa2n3R6eCxvLA.png" /></figure><ul><li>เมื่อเสร็จเรียบร้อยแล้วตรวจสอบข้อมูลแล้วกด “finish”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p38hECirLxUeJu8zhHZVhQ.png" /></figure><ul><li>เมื่อได้ User มาแล้ว กดคลิกขวาที่ User เลือก Properties เพื่อตั้งค่าสิทธิ์ของ User นี้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IACJCAOPSY75_gsA-f7k8Q.png" /></figure><ul><li>คลิกเลือก “Member Of”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmfZSbMiwOaM6STsdboYFA.png" /></figure><ul><li>กด “Add…”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qOcwcIHeU1G7sMOuLAjCPg.png" /></figure><ul><li>พิมพ์ Domain Admins ลงในช่องว่างแล้วกด “Check Names” เมื่อกดเสร็จเรียบร้อย ให้กด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cj9LNkpo6qGaAAKYV696UA.png" /></figure><ul><li>จะมีสิทธิเพิ่มขึ้นมา กด Apply หลังจากนั้นก็กด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1mCLlTJOBuIkYm7Fxhq0sg.png" /></figure><h4>2.3 การ Join Domain ของ SQL Server Node เข้าเป็นสมาชิคของ Active Directory</h4><ul><li>เข้าไปที่เครื่อง SQL Server Node ไปที่ “Network &amp; Internet Settings” แล้วกดเลือก “Change adaptor options”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FV8kK-ZwNkkVab4iam29AA.png" /></figure><ul><li>กดเข้า Network หลักที่เครื่องนี้ใช้งานอยู่</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5EWXM7fNvXj9qSLdkt9uw.png" /></figure><ul><li>กด “Properties”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N1jiF6g8VYUPeE0rvMCwhw.png" /></figure><ul><li>เลือก Internet Protocol Version 4 (TCP/IPv4)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W2bW8-WjkwuU4aTD3hxYgg.png" /></figure><ul><li>เปลี่ยน Preferred DNS server เป็น IP ของ Active Directory Server ที่เราสร้างไว้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HyBSagou7Gd1C7bGdX2NeQ.png" /></figure><ul><li>เข้าช่อง “search” ค้นหา “This PC” เจอแล้วกดคลิกขวาแล้วเลือก “Properties”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Njnl8ecPouJtg2P" /></figure><ul><li>กด “Change settings”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fawepm4PsBQFyY1k" /></figure><ul><li>กด “Change…”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ssr6JDU8PD4Pi6UN" /></figure><ul><li>พิมพ์ชื่อของ Active Directory domain ของเครื่อง Active Directory Node ที่เราสร้างไว้จากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AUwWeCQ-EKp4kiv5oSqGpg.png" /></figure><ul><li>พิมพ์ User และ Password ของ User ที่เราสร้างไว้บน Active Directory แล้วกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OU4go2IVAoEA9EBN" /></figure><ul><li>เมื่อถูกต้องเรียบร้อยจะสามารถ Join Domain ของเครื่อง Database server เข้า Active Directory server ได้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DTLomLPZK1glpNLZ" /></figure><ul><li>Restart เครื่อง SQL Server Node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dMm4iHbS0DqEUeal7ZkqGQ.png" /></figure><ul><li>สามารถเช็คเครื่องที่ join domain ได้ที่เครื่อง Active Directory Node ที่ “Active Directory Users and Computer” โดยเครื่อง SQL Server ที่ทำการ join จะแสดงขึ้นที่หน้า “[ชื่อ Domain Name ของ Active Directory]” ในส่วนของ “Computers”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tr9LsmPkDO7CDZD-yycgBw.png" /></figure><ul><li>กดคลิกขวาที่เครื่อง SQL Server ที่เราทำการ join เข้ามา เลือก “Move…” แล้วเลือกย้ายไปที่ “Organization Unit” ชื่อ “MSSQL” ที่ทำการสร้างไว้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLUqhbrUYHFtrQwek1GF5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h818bWwqEawBfU7qeEZFaw.png" /></figure><h3>Step 3: ตั้งค่า Failover Clustering Feature ของ Windows Server</h3><h4>3.1 การติดตั้ง Failover Clustering (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><ul><li>เข้าไปที่เครื่อง SQL Server Node กดเข้าไปที่ Server manager เลือก Add roles and features</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xbfE5P7zqGVuQzey" /></figure><ul><li>กด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yGUTP12dm-XajOxznMzDmw.png" /></figure><ul><li>กดเลือก “Role-based or feature-based installation” แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2d_Xd8IMjNC02KHhbzHwg.png" /></figure><ul><li>กดเลือก server จาก server pool ที่ต้องการติดตั้ง failover clustering แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSE7PydgGfARerJ7_bilMA.png" /></figure><ul><li>กด “Next” ข้ามการตั้งค่า “Select server roles” ไป</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gku4D7t6iYygzB-ujqOpuA.png" /></figure><ul><li>เมื่อถึงหน้า “Select features” ให้กดเลือก “Failover Clustering” แล้วจะมีหน้าต่าง “Add Roles and Features Wizard” ให้กด “Add Features” แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ihuTeR-vrLs6_uuDIhdFXw.png" /></figure><ul><li>กด check box “Restart the destination server automatically if require” ถ้าต้องการ restart เครื่องหลังทำการติดตั้งเสร็จ</li><li>หน้าต่าง “Add Roles and Features Wizard” ขึ้นมาแจ้งเตือนให้กดตกลง แล้วกด Install หลังจาก Install เรียบร้อย Server จะ restart อัตโนมัติ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*babJcdBG7QPFSXPeTStHTQ.png" /></figure><ul><li>เมื่อทำการติดตั้งเสร็จสิ้นเราจะสามารถใช้ Service Failover Clustering ได้</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HkeSO_PvWJ0p4Uf7jYUOpw.png" /></figure><h4>3.2 การตั้งค่า Failover clustering ระหว่าง SQL Server Node 2 เครื่อง (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><ul><li>เข้าไปที่เครื่อง SQL Server Node ค้นหา “failover cluster manager” ที่ช่องค้นหา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B1_AlVjvs4iI8a_5" /></figure><ul><li>คลิกขวาที่ “Failover Cluster Manager” แล้วเลือก “Validate Configuration…”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KvC83HRzclCK3pac" /></figure><ul><li>กด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7ahmRVUZBJAHHvr0" /></figure><ul><li>กด Browse เพื่อค้นหาชื่อ Server เพื่อทำการเพิ่ม Server ที่จะทำเป็น Failover Clustering</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A_juhQTEqtzlMcCQ" /></figure><ul><li>กดที่ location เพื่อเข้าไปเลือกเครื่องที่จะเอามาเพิ่มลง cluster ของ Failover Clustering โดยเราจะไปเลือกเครื่องจากที่ Active Directory ที่ทำการเพิ่ม Domain ของ SQL Server ไว้แล้ว</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r6j8ucRoICUlAWRZ9SShRw.png" /></figure><ul><li>หน้าต่าง Login จะเด่งขึ้นมาเพิ่อ access เข้าไป Active Directory ให้ทำการกรอกด้วย User, Pass ที่สร้างบน Active Directory Domain Service</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bk7bjKARCj37PAit4EB0OQ.png" /></figure><ul><li>กดเลือก Organization Unit ชื่อ MSSQL ที่เราได้ทำสร้างและย้ายเครื่องที่เชื่อมกับ Active Directory ไว้อยู่แล้ว จากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8jFe-ZeAkhD0h7c2XJwow.png" /></figure><ul><li>กรอกชื่อหรือบางส่วนของชื่อ Domain ของ SQL Server Node ที่จะทำการใส่ลงใน cluster ของ Failover Cluster ลงไปจากนั้นกด Check Names</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VtA3Keb20K33BDi6s3QrTg.png" /></figure><ul><li>กดเลือกเครื่อง SQL Server Node ที่จะเอามาใส่ใน Cluster เพื่อสร้างเป็น Failover Cluster เมื่อเสร็จเรียบร้อยกดปุ่ม OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjrqIXfD9LrYrBgUzlpVZQ.png" /></figure><ul><li>ตรวจเช็คเครื่องที่เพิ่มให้ครบจากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbwpjND49z0B1WFKCwe7_g.png" /></figure><ul><li>เครื่องที่จะทำการเอาเข้า Failover Cluster ก็จะแสดงขึ้นมา จากนั้นกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTlDrsXuDV6rakVx__-4XQ.png" /></figure><ul><li>กดเลือก “Run All Test” แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIpwo82yVkSAcmn2vPhyzw.png" /></figure><ul><li>ตรวจสอบ Test Case แล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcZJNYF3mx8VdrjxCq2n5Q.png" /></figure><ul><li>รอตัว Validator ทำการ test ให้เสร็จเรียบร้อย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MuuTG6pz3I0rREH_EDoEgA.png" /></figure><ul><li>ตรวจสอบ Warnings ว่ามีผลต่อการทำงานไหม ถ้าไม่มีก็สามารถกดเลือกที่ checkbox “Create the cluster now using the validated nodes” แล้วกด “Finish” ได้เลย</li><li>ในที่นี้ warning เรื่อง network interface ของ Server ทั้งสองที่มีเพียง network interface เดียว ทำให้ High Availability ของ cluster ลดลง</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kk4yRQt4KHBSvx5Ltjd6Dw.png" /></figure><ul><li>หน้าต่าง Create Cluster Wizard จะขึ้นมาให้กด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qle7tbA5dP8MQ5AD2NjfPQ.png" /></figure><ul><li>ตั้งชื่อ Cluster Name และ VIP Address ของ Failover Cluster Failover Cluster (Virtual IP) (เช่น 10.0.0.10)</li><li>เมื่อเสร็จเรียบร้อยกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibrdVrUildEhByk7mo1WDA.png" /></figure><ul><li>ตรวจเช็คความเรียบร้อยแล้วกด “Next”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UvMlpYsHpSEd1qwxMOehaQ.png" /></figure><ul><li>รอดำเนินการสร้าง Failover Cluster</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYAyNSChKTY6A7HpE2HunQ.png" /></figure><ul><li>เมื่อเสร็จเรียบร้อยตรวจสอบผลลัพธ์และกด “Finish”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ip7CTQ9k6l-JGnut3SAw0A.png" /></figure><ul><li>ตรวจเช็ค Failover Cluster ที่ทำการสร้างได้ที่ Dropdown ตามนี้ Failover Cluster Manager &gt; ชื่อ Failover Cluster &gt; Nodes</li><li>ถ้า Node ที่แสดงมีเครื่องที่เราทำการเพิ่มเข้าไปครบทั้งหมด แสดงว่าสร้างเสร็จเรียบร้อยแล้ว</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h0vx5GdVndxy2ynWK8g07Q.png" /></figure><ul><li>สามารถตรวจสอบอีก Node ว่ามัน join เข้าได้จริงๆ ไหมจากการเข้าไปที่อีก SQL Server Node อีกตัวนึงที่ทำการเชื่อมด้วย โดยการเปิด “Failover Cluster Manager” ขึ้นมา จากนั้นคลิกขวาที่ “Failover Cluster Manager” แล้วกดเลือก “Connect to Cluster…”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*egRk9dbtVK6RPMjgfTaTsw.png" /></figure><ul><li>นำชื่อของ Failover Cluster ที่เราสร้างไว้มาใส่ที่ช่อง Connection Node จากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTmlby4UCVHhzCJ_xzpr1w.png" /></figure><ul><li>เมื่อขึ้นเหมือนกันทั้งสอง Node แสดงว่า Failover Cluster สามารถทำงานได้อย่างปกติ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2-33w6swWgvWOeaHUciHQ.png" /></figure><h4>3.3 การตั้งค่าสิทธิของ Failover clustering (ทำที่เครื่อง Active Directory)</h4><ul><li>หลังสร้างเสร็จให้ไปเพิ่มสิทธิของ MSSQLCluster01 เพื่อให้มีสิทธิ์ในการควมคุมการทำงานของ Node ที่อยู่ใน Cluster ได้ทุกอย่าง โดยเข้าไปที่เครื่อง Active Directory กดเข้า Active Directory Users and Computers</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrXgqyNvv-QIlMLTAcMPFg.jpeg" /></figure><ul><li>เข้า Organization Unit ชื่อ MSSQL แล้วกดคลิกขวาที่ MSSQLCluster01 เลือก properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nFw71HLEp5viQSh-WLq0_A.jpeg" /></figure><ul><li>กดเข้ามาที่ tab Member Of แล้วกด Add</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-s0nOPeemb5OlHp8TMSGZQ.jpeg" /></figure><ul><li>พิมพ์ role สิทธิ์ domain admin แล้วกด Check Names เมื่อเสร็จเรียบร้อยกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGfTgH_6OeuQNn_zbxpmGQ.jpeg" /></figure><ul><li>เมื่อสิทธิ์แสดงเพิ่มขึ้นมาแล้วก็กด apply แล้วก็ OK</li></ul><h3>Step 4: การติดตั้ง SQL Server 2019</h3><h4>4.1 ติดตั้ง SQL Server 2019 (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0EoouDGCEFLGBvm83xngrg.png" /></figure><ul><li>เลือกการติดตั้งแบบ Custom</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hq4LMw3VTtaiML0BTfQYdg.png" /></figure><ul><li>เลือก folder Media Location สำหรับ download file ติดตั้ง MSSQL</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bS2xwUFB9yqjeldVRfO42A.png" /></figure><ul><li>รอการติดตั้งเสร็จสิ้น</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kt2KgidNSoSWmEER0HuT5A.png" /></figure><ul><li>กดเลือก Installation ที่ Tab ด้านซ้าย</li><li>เลือก New SQL Server stand-alone installation or add features to an existing installation ที่ด้านบนสุดฝั่งขวา</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*ug6F1YFMGm2en5CAVg1Qhg.png" /></figure><ul><li>กดเลือก SQL edition ที่ต้องการลง หรือใส่ Product key ด้านช่องล่าง</li><li>กด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*YcA-5UUZV10sEWpYVusXsA.png" /></figure><ul><li>กด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*xqV54h-fZ6bZPPHNpPqPuw.png" /></figure><ul><li>รอการติดตั้ง Setup Files</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*J0ikUUXduwo0QkGsBSHn5g.png" /></figure><ul><li>รอตรวจเช็คหลังจากการติดตั้ง Rule</li><li>เมื่อเสร็จเรียบร้อยกด Next (Warning นี้แจ้งเตือนเนื่องจากเครื่องได้ทำการเปิด Firewall เอาไว้จึงแจ้งเตือนเรื่อง Port ของ Service บางตัวของ MSSQL ที่จะมีปัญหาถ้าไม่ได้ Add Port นั้นเอาไว้)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*b4Aq4Z5nZHqI652S73SYbw.png" /></figure><ul><li>กดเลือก Feature ที่จะทำการติดตั้ง โดยพื้นฐานจำเป็นต้องเลือก Database Engine Service</li><li>จากนั้นเลือก default directory ของที่ติดตั้ง feature ต่างๆ เมื่อเสร็จเรียบร้อยกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*f9HcXFaS8NX4TAeGfJedfA.png" /></figure><ul><li>ตั้ง Instance Name และ Instance ID เมื่อสร้างเสร็จเรียบร้อยกด Next ( ระหว่าง SQL Server Node 1 และ Node 2 สามารถตั้ง Instance Name ต่างกันได้ แต่แนะนำให้ตั้ง Instance ID เหมือนกัน เนื่องจาก Instance ID มีผลต่อการสร้าง SQL Server Directory ทำให้ระหว่างการสร้าง Always on อาจเกิดปัญหาเรื่องชื่อ Directory ระหว่าง Node 1 และ Node 2 ไม่เหมือนกัน ทำให้ไม่สามารถขึ้น Always on ระหว่าง Node 1 และ Node 2 ได้ )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*y86gWLVGTZAtKHI4tJ_Oag.png" /></figure><ul><li>กดเลือก Grant Perform Volume Maintenance Task privilege to SQL Server Database Engine Service จากนั้นกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*ZrVEY8aTbEtnjKwVs6WTyw.png" /></figure><ul><li>กดเลือก Windows authentication mode และกด Add Current User สำหรับเป็น User เข้าใช้งาน MSSQL ครั้งแรก</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*JJlwi9D0qRdLHUlQ7eTY6w.png" /></figure><ul><li>เข้ามาที่ Data Directories ที่อยู่บน Tab ด้านบน โดยเลือกตามการออกแบบตามพื้นที่การเก็บข้อมูลหรือใช้เป็นค่า default ก็ได้ เมื่อตั้งค่าเสร็จเรียบร้อย กด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*_7PVviuO-dPuStoX-In0oQ.png" /></figure><ul><li>ตรวจสอบการตั้งค่า SQL Server เมื่อตรวจสอบเสร็จเรียบร้อยแล้วกด Install</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*45pbZG30yFXEyY8NaVq0cA.png" /></figure><ul><li>รอการติดตั้งให้เสร็จเรียบร้อย</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*RK2lMfUvn2UJdf_Dr6I63w.png" /></figure><ul><li>ทำการติดตั้งเสร็จเรียบร้อย โดยติดตั้งทั้ง SQL Server ทั้ง 2 Node</li></ul><h4>4.2 การแก้ไข Port Default การทำงานของ SQL Server (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*iY72ab1DXpURz-yfrdAGFg.png" /></figure><ul><li>ค้นหา Sql Server Configuration Manager ที่ช่องค้นหาแล้วกดเลือก</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*SIEOCGE-cI6MWgyeh9Dp4Q.png" /></figure><ul><li>กดคลิกเลือก SQL Server Network Configuration จากนั้นกดเลือก TCP/IP ฝั่งขวา แล้วเลือก IP Address</li><li>ทำการปรับการตั้งค่า โดยการลบค่าใน TCP Dynamic Ports</li><li>เพิ่มค่าใน TCP Port ให้เป็นค่าตามที่เราต้องการจะให้ SQL Server ทำงาน เมื่อเรียบร้อยแล้วกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*Ia-US7ZpTQ9ssNBDURaE6Q.png" /></figure><ul><li>กด Enable Named Pipes</li></ul><h4>4.3 การเปิดระบบ Always On Available Groups ของ SQL Server (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*KQJbpB2VC6doHCpNd9wdWg.png" /></figure><ul><li>กดเลือก SQL Server Services จากนั้นไปกดที่ SQL Server ทางด้านขวา แล้วกดเลือก Properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cr_f4i-3NW1C7Rsc8nUM7g.png" /></figure><ul><li>กดเลือกหัวข้อ Always On Availability Group</li><li>ตรวจเช็ค Failover Cluster ที่สร้าง</li><li>เลือก Enable Always On Availability Groups เมื่อเสร็จเรียบร้อยกด Apply และ OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*SsNUGifnnUKloe9dwHmHcQ.png" /></figure><ul><li>เมื่อเสร็จเรียบร้อยแล้วให้ทำการ Restart SQL Server</li></ul><h4>4.4 นำ User จาก Active Directory มาเป็น User หลักของ SQL Server (ทำที่เครื่อง SQL server primary node และ secondary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*gykh6gSLS4kIVbI2PIRa8g.png" /></figure><ul><li>กดเลือก SQL Server Services จากนั้นกดคลิกขวาที่ SQL Server ทางด้านขวา จากนั้นเลือก Properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*eM6Azk4hSllVfQO_ihxUlw.png" /></figure><ul><li>เข้ามาที่หัวข้อ Log On จากนั้น กด Browse</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SyPgBmGBllt9nelpQEELTQ.png" /></figure><ul><li>กดเลือก Locations…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5VgtM6vunq_IvMz18NTa0Q.png" /></figure><ul><li>กรอก User, Pass ของ Active Directory เพื่อเข้าไปหา User ที่ต้องการจะใช้งาน ที่ถูกสร้างขึ้นที่ Active Directory</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*p4if6YbZeqeyr3vBfSN_Ug.png" /></figure><ul><li>กดเลือก Organization Unit ชื่อ MSSQL ที่สร้างไว้</li><li>กด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTFrUlvjNebx0UQcVADrJQ.png" /></figure><ul><li>พิมพ์ชื่อ User ที่ต้องการจะเพิ่ม</li><li>กด Check Names จากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*frhfcm0LJGzbPskWulXt5g.png" /></figure><ul><li>กรอก Password ของ User ที่ ADD เข้ามาจาก Active Directory โดยต้องเป็นชื่อ User และ Pass เดียวกับที่สร้างบน Active Directory</li><li>กด Apply และ OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*3_7Smt70VYxKuOhufBXA-Q.png" /></figure><ul><li>เมื่อเสร็จเรียบร้อยแล้วให้ทำการ Restart SQL Server</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*vkUMP5N0mdxq3uh88pGcXw.png" /></figure><ul><li>ทำการเชื่อมต่อกับ SQL Database ด้วย Local User เพื่อเข้าไปสร้าง User ของ Active Directory ในระบบ Database</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*w1N80qqtSP69yHw506JVig.png" /></figure><ul><li>กดเลือก Security แล้วกดคลิกขวาที่หัวข้อ Login จากนั้นกด New Login เพื่อสร้าง User ใหม่</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*mnsev2pvfC5kWn6wBnzPWg.png" /></figure><ul><li>กด search เพื่อค้นหาชื่อ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*kAXoDhqMdW-CGXjk3KZgTA.png" /></figure><ul><li>กด Locations เพื่อไปดึง User จากที่ Active Directory</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*ZdUMu8BRDyst5VXnxjVluw.png" /></figure><ul><li>กรอก User, Pass ของ Active Directory เพื่อ Login เข้าไปดึง User</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*tHGS14vE486qqG4oDGA5Hw.png" /></figure><ul><li>กดเลือก Organization Unit ที่สร้างไว้ชื่อ MSSQL</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DTy3k_hH8aN0p0KGds0wfw.png" /></figure><ul><li>กรอกชื่อ User ที่จะดึงมาแล้วกด Check Names จากนั้นกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWvkIwqBnxF46MLr0-ffYA.png" /></figure><ul><li>จากนั้นกดเข้ามาที่ Server Roles เพื่อกำหนดสิทธิ์ของ User ที่มาจาก Active Directory ให้สามารถใช้งาน Database</li><li>กด OK</li></ul><h4>4.5 ทำการสร้าง Always On High Availability (ทำที่เครื่อง SQL server primary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*jh1QUuj1T8NNY5UhqxhMNw.png" /></figure><ul><li>กดเลือกที่ Always On High Availability จากนั้นกดคลิกขวาที่ Availability Group แล้วเลือก New Availability Group Wizard…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*GgyJSZGwtXOcl8Hg3zHr3Q.png" /></figure><ul><li>กด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*PkmAp8PrcgoZzoOeSLGv-Q.png" /></figure><ul><li>ตั้งชื่อ Availability group name จากนั้นกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swxYtkT01UxZvkQdeX-gHg.png" /></figure><ul><li>ตรวจสอบ Database ที่จะนำมาทำ Availability Group โดยสังเกตจาก Status ซึ่งในที่นี้ Status แจ้งให้เราทำการ Backup Database ก่อน</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*wEHuMdfw2hE7J9OR5hI6Dg.png" /></figure><ul><li>ทำการ Back Up โดยการกดคลิกขวาที่ Database ที่ต้องการ</li><li>เลือกกด Tasks เข้าไปกด Back Up ต่อ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdZJIygIwDj0NIqPrC-wBw.png" /></figure><ul><li>ตราจเช็ครายละเอียดเรียบร้อยกด OK</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*dSeGeeZEbbcjWEpS2WEAFQ.png" /></figure><ul><li>เมื่อ Back Up เสร็จสิ้น พอกด refresh ตัว Status ของ Database ทีต้องการจะทำ Availability Group ก็จะเปลี่ยนไปเป็น Meet prerequire คือพร้อมใช้งาน</li><li>กด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*kyadumcoCKMvxnkRVkmxbA.png" /></figure><ul><li>กด Add Replica.. เพื่อเพิ่ม Secondary Node ลงไปสำหรับทำ Availability Group ร่วมกับ Primary Node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*VDZhQ4C0REKCm2d7pBGS1w.png" /></figure><ul><li>เข้าหน้า Login ของ Secondary Node</li><li>กด Browse for more</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxfFe0Z_u-ZDM_e3A1ufpA.png" /></figure><ul><li>เลือกหัวข้อ Network Servers แล้วกดเลือกตัว Server ที่จะ ADD เป็น Secondary Node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4upqrt81yJYOIB4nUP1dPw.png" /></figure><ul><li>เมื่อ ADD เรียบร้อย ให้ทำการตั้งค่าให้ Node ทั้งสองนี้นั้น Automatic Failover (Up to 5) และ Readable Secondary เป็น Yes ทั้งหมด</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YauCeoi3yPCWvcDUh5HX9w.png" /></figure><ul><li>กดเลือกมาที่หัวข้อ Listener กดเลือก Create an availability group listener</li><li>ตั้งชื่อ Listener DNS Name หมายเลข Port</li><li>กด Add IP ที่ต้องการส่งออกเป็น Listener สำหรับเป็น VIP กลางในการเชื่อมต่อที่เป็น Primary SQL Server Node อยู่บน Available Group หรือก็คือ AlwaysON Virtual IP (เช่น 10.0.0.11)</li><li>เมื่อเสร็จเรียบร้อยกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*7HJs-t53dm8eNUlUjz6ACw.png" /></figure><ul><li>กดเลือก full database and log backup</li><li>กด Browse ค้นหา Folder ที่ Primary SQL Server node และ Secondary SQL Server node สามารถเข้าถึงร่วมกันได้ โดยในที่นี้ก็คือ Folder ที่เปิด network sharing อยู่บน Active Directory ที่ควบคุมทั้งสองเครื่องนี้อยู่</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fjt08vQRnPqXsDJLenrWBw.png" /></figure><ul><li>ตรวจสอบผลลัพท์ของการเตรียมพร้อมในการทำ Availability Group เรียบร้อยกด Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*5gVvMpTClRiGG5n6TDbKyw.png" /></figure><ul><li>ตรวจสอบรายละเอียดการ Implement Availability Group อีกครั้ง เมื่อตรวจสอบเสร็จเรียบร้อยกด Finish</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*V7wl_qFGBSf0BgUttCfz7Q.png" /></figure><ul><li>รอการสร้าง Availability</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*l3_SruUUYbX84Xr_ttzn0w.png" /></figure><ul><li>เมื่อสร้างเสร็จเรียบร้อย จะมี Availability Group ที่เราสร้างปรากฎขึ้นมา</li></ul><h4>5. การตั้งค่า Failover clustering ให้รองรับการตั้งค่า MSSQL AlwayOn (ทำที่เครื่อง SQL server primary node)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XLC-WcZ7B8LICKUsjr7ttg.png" /></figure><ul><li>คลิกขวาที่ failover Cluster Manager</li><li>กดเลือก Connect to Cluster…</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*s3__kFVBH9ZwuJ2XmDBTRw.png" /></figure><ul><li>เลือก cluster ที่สร้างไว้</li><li>กด ok</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*t8WBP02U5Z7WcXe5x1OFPg.png" /></figure><ul><li>กดที่ชื่อของ fail over cluster ที่ทำการเชื่อมต่อแล้วที่อยู่ทางด้านซ้าย โดยในตัวอย่างนี้คือ MSSQLCluster01.xxx.local</li><li>คลิกเลือก Roles</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*-sAG8Xkn631q63CvLgHRFw.png" /></figure><ul><li>คลิกขวาที่ Roles ที่ถูกสร้างขึ้นโดย SQL Always On High Availability ซึ่งชื่อของ roles จะเป็นชื่อเดียวกับ SQL Always On ที่เราตั้งขึ้นตอนสร้าง SQL Always On<br> (ถ้าเราไม่ไป set SQL Always On ก่อน roles นี้จะไม่ถูกสร้าง ดังนั้นให้ข้ามไปตั้งค่า Always On ที่ SQL server ก่อนถึงจะสามารถมาตั้งค่าที่นี้ได้)</li><li>คลิกเลือกที่ Properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IG9G4AcLBURIvMQhRvNiHw.png" /></figure><ul><li>กดเลือก failover ที่แทบด้านบน</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fA9VfpnixzjO51xlS6jd_w.png" /></figure><ul><li>ตั้งค่า Maximum failures in specified โดยค่านี้คืออนุญาตให้ Service ภายในเครื่องที่ถูกตั้งค่า failover cluster นั้น down ได้กี่ครั้ง ถ้า down ครบจำนวนครั้งที่กำหนดไม่ว่าจะมาจากเหตุผลใดก็ตาม ตัวเครื่อง VM ที่มี service down ตัวนั้นจะขึ้นเป็น state fail ทันทีและตัวservice ก็จะไม่สามารถสลับ SQL Server ระหว่าง primary node และ secondary node ได้ถ้ามีการเกิด down service สลับกันไปมา 2 node โดยแนะนำให้ตั้งค่าให้สูงๆ ไว้ SQL Always On จะทำงานสลับ state up/down ได้ถี่มากขึ้นภายในเวลาที่กำหนด</li><li>ตั้ง Period โดยค่านี้คือช่วงระยะเวลาหนึ่งที่จะทำการ reset ค่าจำนวนครั้งที่ service นั้น failover ไป โดยจะตั้งว่าทุกๆ x ชั่วโมงจะทำการ reset ค่าจำนวนนับครั้งที่ service failover ใหม่โดยแนะนำให้ตั้งค่าน้อยๆ จะได้ reset จำนวนครั้ง failover บ่อยๆ ค่าจำนวนครั้งที่ failover จะได้ไม่เกิน Maximum failures in specified ที่ตั้งไว้</li><li>ตั้งค่าเรียบร้อยกด ok</li></ul><p>เสร็จเรียบร้อย สำหรับการติดตั้ง SQL Server on-premises พร้อมกับทำ SQL Server AlwaysON บน Windows Server 2019 <br>เมื่อทำการติดตั้งครบถ้วนเรียบร้อยแล้วสามารถทำการทดสอบ AlwaysON ระหว่างเครื่อง Primary และ Secondary ได้เลย โดยเราจะทำการเชื่อมต่อ Database ด้วย Virtual IP ของ MSSQL Server AlwayOn (เช่นตามตัวอย่าง 10.0.0.11)</p><p>ถ้ามีจุดไหนสงสัยเพิ่มเติม สามารถถามได้เลยด้านล่างนะครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c681d95e0151" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การใช้งาน Keepalived เพื่อทำ High Availability บน Virtual Machine]]></title>
            <link>https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99-keepalived-%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%97%E0%B8%B3-high-availability-%E0%B8%9A%E0%B8%99-virtual-machine-a50c26edca26?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a50c26edca26</guid>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[keepalived]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 10:23:48 GMT</pubDate>
            <atom:updated>2023-01-17T10:35:54.111Z</atom:updated>
            <content:encoded><![CDATA[<p>ในกรณีที่ต้องการทำ High Availability ให้สูงขึ้นโดยการเพิ่ม VM สำรองจาก VM ที่ใช้งานในปัจจุบันขึ้นมาอีกตัว เพื่อใช้สำหรับเวลาที่ Service ที่อยู่บน VM นั้นเกิดการ Down จน Service ใช้งานไม่ได้ จะได้สามารถสลับการเชื่อมต่อไปที่ VM ตัวที่สำรองขึ้นมาได้ทันทีโดยที่ไม่มี Downtime เราสามารถใช้ keepalived ในการช่วยตรงนี้ได้</p><p>keepalived เป็นโปรแกรมที่ใช้ในการทำ High Availability ในรูปแบบ MASTER-BACKUP เมื่อ Service บน VM ที่เป็นตัว MASTER เกิด Down มันก็จะทำการสลับการเชื่อมต่อไปที่ VM ที่เป็นตัว BACKUP อยู่โดยอัตโนมัติโดยใช้สิ่งที่เรียกว่า VIP</p><p>VIP (Virtual IP) คือ IP ตัวปล่าวๆ ที่เรากำหนดขึ้นเพื่อใช้เป็น IP กลางในการเชื่อมต่อกลุ่ม VM ที่เราทำ Keepalived ไว้</p><figure><img alt="https://docs.oracle.com/en/operating-systems/oracle-linux/6/admin/section_uxg_lzh_nr.html" src="https://cdn-images-1.medium.com/max/553/1*bv4_IRoOr6Kb1FlujXVUdA.png" /></figure><h4>Resource</h4><ul><li><strong>Demo node 2 เครื่อง</strong><br>OS: Ubuntu 22.04<br>CPU: 2<br>Memory: 2 GB<br>Disk: 40 GB</li></ul><h4>IP Node</h4><ul><li><strong>IP</strong><br>- 10.0.0.1 เครื่อง MASTER node 1<br>- 10.0.0.2 เครื่อง BACKUP node 2</li><li><strong>VIP<br></strong>- 10.0.0.100 ตัว IP ปล่าวๆ สำหรับ Keepalived</li></ul><h4>Installation</h4><p><strong>Step 1 : การติดตั้ง keepalived</strong></p><pre>sudo apt-get install keepalived</pre><p><strong>Step 2: การเข้าถึงไฟล์การตั้งค่าของ keepalived</strong></p><pre>sudo vim /etc/keepalived/keepalived.conf</pre><p><strong>Step 3: การเขียนการตั้งค่า keepalived</strong></p><ul><li>การตั้งค่าที่เครื่อง MASTER node (10.0.0.1)</li></ul><pre>global_defs {<br> router_id service_check       # service_check คือชื่อของ service ที่จะ check<br>}<br>vrrp_script service_check {    # ระบุ script ของ service_check<br> script &quot;pidof service&quot;        # ตัว script ของ service_check โดยเป็น script เช็คว่า service นั้นยังทำงานอยู่หรือปล่าว อาจเขียนได้หลายรูปแบบเช่น &quot;pidof service&quot; หรือ &quot;/usr/bin/killall -0 service&quot; หรือ &quot;killall -0 service&quot; หรืออื่นๆ นอกจากนี้ยังสามารถระบุเป็นไฟล์ script จากภายนอกได้ด้วยดังนี้ &quot;/check_alive.sh&quot;<br> interval 2                    # จำนวนการ run script check <br> weight 2                      # priority ในการ run script ตัวนี้<br>}<br>vrrp_instance VI01 {    # สร้าง vrrp_instance สำหรับตั้งค่า keepalived cluster<br> virtual_router_id 50   # กำหนด id ของ cluster ที่ทำการตั้งค่า โดยเป็น unique ของตามแต่ละ cluster <br> advert_int 1           # กำหนดจำนวนที่ BACKUP node ไม่ได้รับสัญญาณจาก MASTER node ภายในระยะเวลาที่กำหนด  <br> priority 100           # กำหนดตัวเลข Priority ยิ่งตัวเลขมีค่าสูง ก็จะยิ่งมีความสำคัญให้เป็น MASTER ก่อน (มีผลต่อการสลับ MASTER กับ BACKUP เมื่อเกิด fallover หรือ restore กลับมาเมื่อ service กลับมาใช้งานได้)<br> state MASTER           # กำหนด state เริ่มต้นว่าตัวไหนเป็น MASTER หรือ BACKUP <br> interface ens160       # network interface ของ VM ที่ทำการติดตั้ง keepalived<br> unicast_src_ip 10.0.0.1   # ip address ของเครื่อง VM ปัจจุบัน <br> unicast_peer {            # ip address ของเครื่อง VM ตัวอื่นๆ ที่อยู่ใน cluster ของ keepalived<br> 10.0.0.2<br> }<br> virtual_ipaddress {    # vip ที่เรากำหนดขึ้นมาใช้เป็นตัวกลางในการเชื่อมต่อกับเครื่องภายใน cluster<br> 10.0.0.100<br> }<br> track_script {         # กำหนด script ที่ใช้ในการ trigger เพื่อสับเปลี่ยนไปมาระหว่าง MASTER และ BACKUP<br> service_check<br> }<br>}</pre><ul><li>การตั้งค่าที่เครื่อง BACKUP node (10.0.0.2)</li></ul><pre>global_defs {<br> router_id service_check       # service_check คือชื่อของ service ที่จะเช็ค<br>}<br>vrrp_script service_check {    # ระบุ script ของ service_check<br>script &quot;pidof service&quot;         # ตัว script ของ service_check โดยเป็น script เช็คว่า service นั้นยังทำงานอยู่หรือปล่าว อาจเขียนได้หลายรูปแบบเช่น &quot;pidof service&quot; หรือ &quot;/usr/bin/killall -0 service&quot; หรือ &quot;killall -0 service&quot; หรืออื่นๆ นอกจากนี้ยังสามารถระบุเป็นไฟล์ script จากภายนอกได้ด้วยดังนี้ &quot;/check_alive.sh&quot;<br> interval 2                    # จำนวนการ run script check <br> weight 2                      # priority ในการ run script ตัวนี้<br>}<br>vrrp_instance VI01 {    # สร้าง vrrp_instance สำหรับตั้งค่า keepalived cluster<br> virtual_router_id 50   # กำหนด id ของ cluster ที่ทำการตั้งค่า โดยเป็น unique ของตามแต่ละ cluster <br> advert_int 1           # กำหนดจำนวนที่ stanby node ไม่ได้รับสัญญาณจาก MASTER node ภายในระยะเวลาที่กำหนด  <br> priority 99            # กำหนดตัวเลข Priority ยิ่งตัวเลขมีค่าสูง ก็จะยิ่งมีความสำคัญให้เป็น MASTER ก่อน (มีผลต่อการสลับ MASTER กับ BACKUP เมื่อเกิด fallover หรือ restore กลับมาเมื่อ service กลับมาใช้งานได้)<br> state BACKUP           # กำหนด state เริ่มต้นว่าตัวไหนเป็น MASTER หรือ BACKUP <br> interface ens160       # network interface ของ VM ที่ทำการติดตั้ง keepalived<br> unicast_src_ip 10.0.0.2   # ip address ของเครื่อง VM ปัจจุบัน<br> unicast_peer {            # ip address ของเครื่อง VM ตัวอื่นๆ ที่อยู่ใน cluster ของ keepalived<br> 10.0.0.1<br> }<br> virtual_ipaddress {    # vip ที่เรากำหนดขึ้นมาใช้เป็นตัวกลางในการเชื่อมต่อกับเครื่องภายใน cluster<br> 10.0.0.100<br> }<br> track_script {         # กำหนด script ที่ใช้ในการ trigger เพื่อสับเปลี่ยนไปมาระหว่าง MASTER และ BACKUP<br> service_check<br> }<br>}</pre><p>parameter เพิ่มเติมสำหรับ config keepalived</p><p><a href="https://manpages.ubuntu.com/manpages/bionic/man5/keepalived.conf.5.html">Ubuntu Manpage: keepalived.conf - configuration file for Keepalived</a></p><p><strong>Step 4: restart keepalived service ทุกเครื่องที่เราได้ตั้งค่า keepalived ไว้</strong></p><pre>sudo systemctl enable keepalived<br>sudo systemctl start keepalived<br>sudo systemctl restart keepalived</pre><p><strong>Step 5: ทดสอบ VIP ของ keepalived ที่เราทำการตั้งค่าไว้</strong></p><pre>ping 10.0.0.100<br>curl 10.0.0.100</pre><p><strong>เพิ่มเติม</strong></p><ul><li><strong>Keepalived Log</strong></li></ul><p>ตัว log ของ keepalived สามารถตรวจเช็คได้ที่ /var/log/syslog โดยใช้คำสั่ง</p><pre>sudo cat /var/log/syslog | grep &quot;Keepalived_vrrp&quot;<br>sudo cat /var/log/syslog | grep &quot;Keepalived&quot;</pre><ul><li><strong>Reference</strong></li></ul><ul><li><a href="https://docs.oracle.com/en/operating-systems/oracle-linux/6/admin/section_uxg_lzh_nr.html">17.6 Configuring Simple Virtual IP Address Failover Using Keepalived</a></li><li><a href="https://manpages.ubuntu.com/manpages/bionic/man5/keepalived.conf.5.html">Ubuntu Manpage: keepalived.conf - configuration file for Keepalived</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a50c26edca26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การติดตั้ง Load Balance สำหรับ MySQL Cluster]]></title>
            <link>https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-load-balance-%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A-mysql-cluster-ed5fca2d2708?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed5fca2d2708</guid>
            <category><![CDATA[haproxy]]></category>
            <category><![CDATA[high-availability]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Mon, 28 Feb 2022 08:18:39 GMT</pubDate>
            <atom:updated>2022-05-07T08:34:36.842Z</atom:updated>
            <content:encoded><![CDATA[<p>โดยปกติ MySQL Cluster จะแนะนำว่าให้มี API node และ Management node เพียงตัวเดียว เนื่องจากจะมีข้อควรระวังและข้อจำกัดบางอย่างเพิ่มขึ้น ตามรายละเอียด reference ด้านล่าง</p><ul><li><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-limitations-multiple-nodes.html">MySQL :: MySQL 8.0 Reference Manual :: 23.2.7.10 Limitations Relating to Multiple NDB Cluster Nodes</a></li><li><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-security-mysql-privileges.html">MySQL :: MySQL 8.0 Reference Manual :: 23.6.17.2 NDB Cluster and MySQL Privileges</a></li></ul><p>ดังนั้นถ้าเราขึ้น API node เพียงตัวเดียวก็ไม่จำเป็นต้องทำ Load Balance เพื่อเกลี่ย transaction ระหว่าง 2 API node ก็ได้</p><p>Load Balance ที่จะใช้สำหรับกระจาย transaction ไปที่ API Node จะใช้ software สำหรับทำ Proxy และ Loadbalance ที่มีชื่อว่า HAProxy</p><p><a href="http://www.haproxy.org/">HAProxy</a></p><h3>Resource</h3><p>HAProxy ที่ทำการติดตั้งคือ version 2.0.13 ที่เป็น version ที่สามารถสั่งติดตั้งได้เลยบน ubuntu</p><ul><li><strong>HAProxy node 1เครื่อง</strong><br>OS: Ubuntu 21.04<br>CPU: 4<br>Memory: 8 GB<br>Disk: 50 GB</li></ul><h3>IP Node</h3><ul><li><strong>Load Balance node</strong><br>- 10.0.0.7 เครื่อง Load Balance node 1</li><li><strong>API/MySQL node</strong><br>- 10.0.0.5 เครื่อง API/MySQL node 1<br>- 10.0.0.6 เครื่อง API/MySQL node 2</li></ul><h3>Installation</h3><h3>Step 1: การติดตั้ง H</h3><ul><li><strong>ติดตั้ง HAProxy</strong></li></ul><pre>$ sudo apt install -y haproxy</pre><ul><li><strong>เขียน config ภายใน file </strong>/etc/haproxy/haproxy.cfg โดยเพิ่มจากบรรทัดล่างสุด</li></ul><pre># ส่วนของ HA ที่รับ กระจายและส่งต่อ Transaction ที่เชื่อมต่อกับ API Node<br>listen mysql-cluster<br>bind *:3306<br>mode tcp<br>option tcplog<br>option clitcpka<br>timeout client 3600s<br>option srvtcpka</pre><pre># ถ้า api node ทำการเปิด secure transaction จะไม่สามารถใช้ option mysql-check ของ haproxy ได้<br>option mysql-check user haproxy</pre><pre>timeout server 3600s<br>balance leastconn</pre><pre># ส่วนเชื่อมต่อกับ api node<br>server mysql-1 10.0.0.5:3306 check inter 2000 rise 2 fall 5<br>server mysql-2 10.0.0.6:3306 check inter 2000 rise 2 fall 5</pre><pre># ส่วน Dashboard แสดงสถานะ HAProxy ผ่าน Web GUI<br>frontend stats<br>bind *:9200<br>stats enable<br>stats uri /stats<br>stats refresh 10s<br>stats admin if TRUE</pre><p>Ref สำหรับรายละเอียดการตั้งค่าแต่ละส่วนของ HAProxy</p><ul><li><a href="https://www.haproxy.com/blog/the-four-essential-sections-of-an-haproxy-configuration/">The Four Essential Sections of an HAProxy Configuration</a></li><li><a href="https://cbonte.github.io/haproxy-dconv/2.0/configuration.html">HAProxy version 2.0.27 - Configuration Manual</a></li></ul><ul><li><strong>สั่ง restart และ enable HAProxy</strong></li></ul><pre>$ sudo systemctl restart haproxy<br>$ sudo systemctl enable haproxy</pre><ul><li><strong>Check การทำงานของ HAProxy</strong></li></ul><p>เข้า URL นี้ ผ่าน web browser</p><pre><a href="http://10.80.20.146:9200/stats">http://10.0.0.7:9200/stats</a></pre><h3>Step 2: แก้ไข Firewall ของ API/MySQL Node</h3><p>เพื่อให้ API/MySQL Node สามารถติดต่อกับ HAProxy ได้</p><ul><li><strong>เปิด Firewall แบบ Fix Port</strong></li></ul><pre>$ sudo ufw allow 3306</pre><ul><li><strong>เปิด Firewall แบบ Fix IP<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้ามีหรือเปิดอยู่ แนะนำให้ทำการเปิด IP ก่อน</li></ul><pre>$ sudo ufw allow from 10.0.0.7</pre><h3>Step 3: ทดสอบการทำงานของ Load balance</h3><ul><li>ใช้คำสั่งของ MySQL ผ่าน Load Balance</li></ul><p>การ Login เข้า database</p><pre>$ mysql -u username -h 10.0.0.7 -p </pre><p>เสร็จเรียบร้อยแล้ว สำหรับการตั้งค่า Load Balance แบบง่ายๆ สำหรับ MySQL Cluster ที่มี API/MySQL Node 2 ตัวขึ้นไป ถ้ามีข้อสงสัยหรือติดปัญหาอ่ะไรเกี่ยวกับบทนี้สามารถ comment ถามคำถามด้านล่างได้เลยนะครับผม</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed5fca2d2708" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ติดตั้ง MySQL Cluster บน Ubuntu Server 21.04 ด้วย Binary Package (deb)]]></title>
            <link>https://medium.com/@rapepatpengsart/mysql-cluster-2a095bc2a724?source=rss-d64be138bac7------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a095bc2a724</guid>
            <category><![CDATA[mysql-8]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[mysql-cluster]]></category>
            <dc:creator><![CDATA[Rapepat Pengsart]]></dc:creator>
            <pubDate>Wed, 08 Sep 2021 17:02:44 GMT</pubDate>
            <atom:updated>2022-05-07T08:38:17.590Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>MySQL</strong> คือ database management system ที่มีทำงานในลักษณะ Stand Alone รวมการทำงานทั้งหมดอยู่ใน node เดียวทั้งการจัดการฐานข้อมูล, ที่เก็บข้อมูล, และการเชื่อมต่อฐานข้อมูลทำให้เมื่อ VM ที่ MySQL Server นั้นทำงานมีปัญหา ก็อาจทำให้ส่งผลกระทบต่อการใช้งาน Database ได้</p><p><strong>Mysql Cluster</strong> คือ MySQL ที่รองรับการทำงานในลักษณะ distributed database โดยแยก node ตามการทำงานของ database management system คือ</p><ul><li><strong>Management node</strong> คือ node ที่ทำหน้าที่ควบคุมการทำงานภายในระบบ MySQL Cluster ทั้งหมด ตั้งแต่การควบคุมและกระจายของข้อมูลภายใน Data node, รวมถึงการดูรายละเอียดและความคุมสั่งการ node ต่างๆ ให้ทำงานเป็นไปตามที่กำหนด</li></ul><ul><li><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-programs-ndb-mgm.html">MySQL :: MySQL 8.0 Reference Manual :: 23.5.5 ndb_mgm - The NDB Cluster Management Client</a></li><li><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-mgm-client-commands.html">MySQL :: MySQL 8.0 Reference Manual :: 23.6.1 Commands in the NDB Cluster Management Client</a></li></ul><ul><li><strong>Data node</strong> คือ node ที่ทำหน้าที่ในการเก็บข้อมูลอย่างเดียว โดยการทำงาน Data node จะมีการทำงานเป็น Group โดยใน 1 Group จะมี Data node อยู่ 2 ตัว ซึ่งทั้งสองตัวนี้จะมีการเขียนข้อมูลแบบ mirror หรือเขียนข้อมูลซ้ำกันทั้ง 2 data node เมื่อ data node ตัวใดตัวหนึ่งใน Group นั้นเสียข้อมูลก็ยังสามารถใช้งานได้อยู่<br>** ใน 1 Gruop มีได้ 2 Data Node เท่านั้น ไม่สามารถมากหรือน้อยไปกว่านี้ได้<br>** ใน 1 MySQL Cluster มีได้หลาย Group</li></ul><p><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-programs-ndbd.html">MySQL :: MySQL 8.0 Reference Manual :: 23.5.1 ndbd - The NDB Cluster Data Node Daemon</a></p><ul><li><strong>API/MySQL node</strong> คือ node ที่ทำหน้าที่ในการเชื่อมต่อกับ database บน MySQL Cluster กับผู้ใช้งานโดยสามารถใช้คำสั่งเหมือนกับ MySQL server แบบปกติ โดยจะมีสิ่งที่ต้องปรับอย่างเดียวคือปรับ Storage Engine เวลาสร้าง Table ให้ไปใช้ Storage Engine ของ MySQL Cluster คือ NDBCLUSTER ด้วยไม่เช่นนั้นข้อมูลจะไม่ถูกเขียนบน Data node ของ MySQL Cluster แต่จะไปเขียนบน database server ของ API/MySQL node บนตัวมันเอง</li></ul><p><a href="https://dev.mysql.com/doc/refman/8.0/en/mysql-cluster-install-example-data.html">MySQL :: MySQL 8.0 Reference Manual :: 23.3.5 NDB Cluster Example with Tables and Data</a></p><h3>Resource</h3><p>MySQL Cluster ที่ทำการติดตั้งคือ version 8.0.26 ที่เป็น version ล่าสุด ณ วันที่ 8 กันยายน 2564</p><ul><li><strong>Management node 2 เครื่อง</strong><br>OS: Ubuntu 21.04 <br>CPU: 4<br>Memory: 8 GB<br>Disk: 150 GB</li><li><strong>Data node 2 เครื่อง</strong><br>OS: Ubuntu 21.04<br>CPU: 4<br>Memory: 8 GB<br>Disk: 300 GB</li><li><strong>API/MySQL node 2 เครื่อง</strong><br>OS: Ubuntu 21.04<br>CPU: 4<br>Memory: 8 GB<br>Disk: 50 GB</li></ul><h3>IP Node</h3><ul><li><strong>Management node </strong><br>- 10.0.0.1 เครื่อง management node 1<br>- 10.0.0.2 เครื่อง management node 2</li><li><strong>Data node</strong><br>- 10.0.0.3 เครื่อง data node 1<br>- 10.0.0.4 เครื่อง data node 2</li><li><strong>API/MySQL node</strong><br>- 10.0.0.5 เครื่อง API/MySQL node 1<br>- 10.0.0.6 เครื่อง API/MySQL node 2</li></ul><h3>Installation</h3><p>การติดตั้ง MySQL Cluster จะต้องไล่ติดตั้งจากลำดับดังต่อไปนี้ <br><strong>Management node → Data node → API/MySQL node </strong><br>โดยแต่ละ step ห้ามทำข้ามขั้นกันและ แต่ละ node ต้องมั่นใจว่าได้ทำงานเรียบร้อยแล้ว ต้องไม่มีสถานะ starting หรือ not connect ในตัว node ที่ทำขณะนั้นๆ โดยสามารถเช็คได้ใน management node โดยใช้คำสั่ง ndb_mgm -e “show”</p><h4><strong>Step 1 : การติดตั้ง Management node</strong></h4><ul><li><strong>ปิด selinux <br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง selinux แต่ถ้ามีแนะนำให้ทำการปิดก่อน</li></ul><pre>$ sudo vim /etc/selinux/config</pre><ul><li><strong>แก้ไขภายในไฟล์ /etc/selinux/config</strong></li></ul><pre>SELINUX=disabled</pre><ul><li><strong>reload config</strong></li></ul><pre>$ sudo reboot</pre><ul><li><strong>เปิด Firewall แบบ Fix Port<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้ามีหรือเปิดอยู่ แนะนำให้ทำการเปิด port ก่อน</li></ul><pre>$ sudo ufw allow 1186</pre><ul><li><strong>เปิด Firewall แบบ Fix IP<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้ามีหรือเปิดอยู่ แนะนำให้ทำการเปิด IP ก่อน</li></ul><pre>$ sudo ufw allow from 10.0.0.1<br>$ sudo ufw allow from 10.0.0.2<br>$ sudo ufw allow from 10.0.0.3<br>$ sudo ufw allow from 10.0.0.4<br>$ sudo ufw allow from 10.0.0.5<br>$ sudo ufw allow from 10.0.0.6</pre><ul><li><strong>Download Package ที่จำเป็นสำหรับ MySQL Cluster Management node</strong> โดยถ้าต้องการติดตั้ง OS อื่นนอกจาก Ubuntu 21.04 ก็สามารถ Download Package ได้ที่ link นี้</li></ul><p><a href="https://dev.mysql.com/downloads/cluster/">MySQL :: Download MySQL Cluster</a></p><p>โดยส่วนที่จำเป็นสำหรับ Management node มีดังต่อไปนี้<br> - mysql-common<br> - mysql-cluster-community-client-plugins<br> - mysql-cluster-community-client-core<br> - mysql-cluster-community-client<br> - mysql-cluster-community-management-server</p><p>จริง ๆ แล้ว สามารถลงเพียงแค่ mysql-cluster-community-management-server ก็ได้ แต่ถ้าลงเพียงตัวนี้ตัวเดียวก็จะไม่สามารถใช้งาน ndb_mgm เพื่อใช้คำสั่งหรือเรียกดูสถานะของ node ต่างๆ ผ่าน ndb_mgm ได้</p><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-common_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client-plugins_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-management-server_8.0.26-1ubuntu21.04_amd64.deb</pre><ul><li><strong>ติดตั้ง Package ที่จำเป็นสำหรับ MySQL Cluster Management node</strong></li></ul><pre>$ sudo dpkg -i mysql-common_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client-plugins_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-management-server_8.0.26-1ubuntu21.04_amd64.deb</pre><ul><li><strong>สร้าง directory ให้ management node ใช้งานและเก็บ file config ต่างๆ</strong></li></ul><pre>$ sudo mkdir /var/lib/mysql-cluster</pre><ul><li><strong>สร้าง file config สำหรับ MySQL Cluster ตัว Management Node</strong></li></ul><pre>$ sudo vim /var/lib/mysql-cluster/config.ini</pre><ul><li><strong>เขียน config ภายใน file /var/lib/mysql-cluster/config.ini</strong></li></ul><pre># global default data nodes configuration<br>[ndbd default]<br>NoOfReplicas=2                  # Number of replication</pre><pre># Management Node<br>[ndb_mgmd]<br>NodeId=11<br>hostname=10.0.0.1               # Hostname/IP of management node 11<br>datadir=/var/lib/mysql-cluster  # Directory for the log files</pre><pre># Management Node<br>[ndb_mgmd]<br>NodeId=12<br>hostname=10.0.0.2               # Hostname/IP of management node 12<br>datadir=/var/lib/mysql-cluster  # Directory for the log files</pre><pre># Data Node<br>[ndbd]<br>NodeId=1                        # Node ID for this data node 1<br>hostname=10.0.0.3               # Hostname/IP of data node 1<br>datadir=/usr/local/mysql/data   # directory for the data files</pre><pre># Data Node<br>[ndbd]<br>NodeId=2                        # Node ID for this data node 2<br>hostname=10.0.0.4               # Hostname/IP of data node 2<br>datadir=/usr/local/mysql/data   # directory for the data files</pre><pre># API/MySQL node<br>[mysqld]<br>NodeId=21                       # Node ID for this API/MySQL node<br>hostname=10.0.0.5               # Hostname/IP of API/MySQL node 21 </pre><pre># API/MySQL node<br>[mysqld]<br>NodeId=22                       # Node ID for this API/MySQL node<br>hostname=10.0.0.6               # Hostname/IP of API/MySQL node 22</pre><p>Parameter สำหรับการตั้งค่า ndbcluster ส่วน Management node ใน file <br><strong>/var/lib/mysql-cluster/config.ini</strong></p><p><a href="https://dev.mysql.com/doc/mysql-cluster-excerpt/8.0/en/mysql-cluster-mgm-definition.html">MySQL :: MySQL NDB Cluster 8.0 :: 4.3.5 Defining an NDB Cluster Management Server</a></p><p>Parameter สำหรับการตั้งค่า ndbcluster ส่วน Data node ใน file <br><strong>/var/lib/mysql-cluster/config.ini</strong></p><p><a href="https://dev.mysql.com/doc/mysql-cluster-excerpt/8.0/en/mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentoperations">MySQL :: MySQL NDB Cluster 8.0 :: 4.3.6 Defining NDB Cluster Data Nodes</a></p><p>Parameter สำหรับการตั้งค่า ndbcluster ส่วน API node ใน file <br><strong>/var/lib/mysql-cluster/config.ini</strong></p><p><a href="https://dev.mysql.com/doc/mysql-cluster-excerpt/8.0/en/mysql-cluster-api-definition.html">MySQL :: MySQL NDB Cluster 8.0 :: 4.3.7 Defining SQL and Other API Nodes in an NDB Cluster</a></p><ul><li><strong>สร้างไฟล์สำหรับใช้ร่วมกับ systemctl</strong> เพื่อสั่ง status/start/stop/enable ตัว ndb_mgmd ได้เลยโดยไม่ต้อง kill และสั่ง <em>“ ndb_mgmd — config-file=/var/lib/mysql-cluster/config.ini ”</em> ทุกครั้งเองเวลาเปลี่ยน config หรือเมื่อเครื่อง VM ทำการ Down และ Up ขึ้นมาใหม่</li></ul><pre>$ sudo vim /etc/systemd/system/ndb_mgmd.service</pre><ul><li><strong>เขียน config ภายใน file ndb_mgmd.service</strong></li></ul><pre>[Unit]<br>Description=MySQL NDB Cluster Management Server<br>After=network.target auditd.service</pre><pre>[Service]<br>Type=forking<br>ExecStart=/usr/sbin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini<br>ExecReload=/bin/kill -HUP $MAINPID<br>KillMode=process<br>Restart=on-failure</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><ul><li><strong>สั่ง reload</strong> <strong>ndb_mgmd.service config</strong></li></ul><pre>$ sudo systemctl daemon-reload</pre><ul><li><strong>สั่ง start และ enable ndb_mgmd</strong></li></ul><pre>$ sudo systemctl start ndb_mgmd<br>$ sudo systemctl enable ndb_mgmd</pre><ul><li><strong>Check การทำงานของ management node</strong></li></ul><pre>$ ndb_mgm -e &quot;show&quot;</pre><p>โดยนำการตั้งค่าจาก step 1 นี้ไปตั้งค่าทุกเครื่องที่เป็น management node เหมือนกันด้วยทุก step</p><h3><strong>Step 2: การติดตั้ง Data node</strong></h3><ul><li><strong>ปิด selinux <br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง selinux แต่ถ้ามีแนะนำให้ทำการปิดก่อน</li></ul><pre>$ sudo vim /etc/selinux/config</pre><ul><li><strong>แก้ไขภายในไฟล์ /etc/selinux/config</strong></li></ul><pre>SELINUX=disabled</pre><ul><li><strong>reload config</strong></li></ul><pre>$ sudo reboot</pre><ul><li><strong>เปิด Firewall แบบ Fix Port<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้าจะใช้เปิด firewall แนะนำให้เปิดแบบ Fix IP ดีกว่าเนื่องจาก data node จะมีการ random port เพื่อใช้ในการติดต่อระหว่าง data node ด้วยกันเองทำให้ไม่สามารถ fix เปิด port ได้</li></ul><p><a href="https://blogs.oracle.com/mysql/connection-failures-between-nodes-in-mysql-cluster-v2">Connection Failures Between Nodes in MySQL Cluster</a></p><ul><li><strong>เปิด Firewall แบบ Fix IP<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้ามีหรือเปิดอยู่ แนะนำให้ทำการเปิด IP ก่อน</li></ul><pre>$ sudo ufw allow from 10.0.0.1<br>$ sudo ufw allow from 10.0.0.2<br>$ sudo ufw allow from 10.0.0.3<br>$ sudo ufw allow from 10.0.0.4<br>$ sudo ufw allow from 10.0.0.5<br>$ sudo ufw allow from 10.0.0.6</pre><ul><li><strong>Download Package ที่จำเป็นสำหรับ MySQL Cluster Data node</strong> โดยถ้าต้องการติดตั้ง OS อื่นนอกจาก Ubuntu 21.04 ก็สามารถ Download Package ได้ที่ link นี้</li></ul><p><a href="https://dev.mysql.com/downloads/cluster/">MySQL :: Download MySQL Cluster</a></p><p>ส่วน libclass-methodmaker-perl เลือกสามารถดาวน์โหลดตาม OS ได้ที่ link นี้ <a href="https://pkgs.org/download/libclass-methodmaker-perl">https://pkgs.org/download/libclass-methodmaker-perl</a></p><p>ส่วนที่จำเป็นสำหรับ data node มีดังต่อไปนี้<br> - libclass-methodmaker-perl<br> - mysql-cluster-community-data-node</p><p>จริง ๆ แล้วถ้าติดตั้ง perl อยู่ภายในเครื่องแล้วก็ไม่จำเป็นต้องลง “<em>libclass-methodmaker-perl” </em>ก็ได้เพราะปกติภายใน perl จะมี package นี้อยู่ด้วยแต่ถ้าไม่มีก็สามารถ download เพิ่มได้ หรือสามารถใช้ <em>sudo apt-get install libclass-methodmaker-perl -y</em> แทนการลงแบบ Binary Package ได้</p><pre>$ wget http://archive.ubuntu.com/ubuntu/pool/universe/libc/libclass-methodmaker-perl/libclass-methodmaker-perl_2.24-2build1_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-data-node_8.0.26-1ubuntu21.04_amd64.deb</pre><ul><li><strong>ติดตั้ง Package ที่จำเป็นสำหรับ MySQL Cluster Data node</strong></li></ul><pre>$ sudo dpkg -i libclass-methodmaker-perl_2.24-2build1_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-data-node_8.0.26-1ubuntu21.04_amd64.deb</pre><p><strong>สร้าง directory ให้ data node ใช้งานและเก็บ file ต่างๆ </strong><em>โดยต้องสร้างให้ตรงกับ datadir ที่ตั้งค่าที่ [ndbd] ใน file config ของเครื่อง Manage node ที่ set ไปตาม step1</em></p><pre>$ sudo mkdir /usr/local/mysql/data/</pre><ul><li><strong>สร้าง file config สำหรับ MySQL Cluster ตัว Data Node</strong></li></ul><pre>$ sudo vim /etc/my.cnf</pre><ul><li><strong>เขียน config ภายใน file /etc/my.cnf</strong></li></ul><pre># Data node Config<br>[mysql_cluster]<br>ndb-connectstring=10.0.0.1,10.0.0.2 # location of management node</pre><ul><li><strong>สร้างไฟล์สำหรับใช้ร่วมกับ systemctl</strong> เพื่อสั่ง status/start/stop/enable ตัว ndb ได้เลยโดยไม่ต้อง kill และสั่ง <em>“</em>ndbd<em>”</em> ทุกครั้งเองเวลาเปลี่ยน config หรือเมื่อเครื่อง VM ทำการ Down และ Up ขึ้นมาใหม่</li></ul><pre>$ sudo vim /etc/systemd/system/ndbd.service</pre><ul><li><strong>เขียน config ภายใน file /etc/systemd/system/ndbd.service</strong></li></ul><pre>[Unit]<br>Description=MySQL NDB Data Node Daemon<br>After=network.target auditd.service</pre><pre>[Service]<br>Type=forking<br>ExecStart=/usr/sbin/ndbd<br>ExecReload=/bin/kill -HUP $MAINPID<br>KillMode=process<br>Restart=on-failure</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><ul><li><strong>สั่ง reload ndbd.service config</strong></li></ul><pre>$ sudo systemctl daemon-reload</pre><ul><li><strong>สั่ง start และ enable ndbd</strong></li></ul><pre>$ sudo systemctl start ndbd<br>$ sudo systemctl enable ndbd</pre><ul><li><strong>Check การทำงานของ data node ที่เครื่อง management nod</strong>e</li></ul><pre>$ ndb_mgm -e &quot;show&quot;</pre><p>โดยนำการตั้งค่าจาก step 2 นี้ไปตั้งค่าทุกเครื่องที่เป็น data node เหมือนกันด้วยทุก step</p><h3><strong>Step 3: การติดตั้ง API/MySQL node</strong></h3><ul><li><strong>ปิด selinux <br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง selinux แต่ถ้ามีแนะนำให้ทำการปิดก่อน</li></ul><pre>$ sudo vim /etc/selinux/config</pre><ul><li><strong>แก้ไขภายในไฟล์ /etc/selinux/config</strong></li></ul><pre>SELINUX=disabled</pre><ul><li><strong>reload config</strong></li></ul><pre>$ sudo reboot</pre><ul><li><strong>เปิด Firewall แบบ Fix Port</strong></li></ul><pre>$ sudo ufw allow 1186<br>$ sudo ufw allow 3306</pre><ul><li><strong>เปิด Firewall แบบ Fix IP<br></strong>โดย default Ubuntu จะไม่ได้ติดตั้ง firewall หรือ ปิดการทำงานไว้ แต่ถ้ามีหรือเปิดอยู่ แนะนำให้ทำการเปิด IP ก่อน</li></ul><pre>$ sudo ufw allow from 10.0.0.1<br>$ sudo ufw allow from 10.0.0.2<br>$ sudo ufw allow from 10.0.0.3<br>$ sudo ufw allow from 10.0.0.4<br>$ sudo ufw allow from 10.0.0.5<br>$ sudo ufw allow from 10.0.0.6</pre><ul><li><strong>Download Package ที่จำเป็นสำหรับ MySQL Cluster API/MySQL node</strong> โดยถ้าต้องการติดตั้ง OS อื่นนอกจาก Ubuntu 21.04 ก็สามารถ Download Package ได้ที่ link นี้</li></ul><p><a href="https://dev.mysql.com/downloads/cluster/">MySQL :: Download MySQL Cluster</a></p><p>ส่วน libaio1 และ libmecab2 เลือกสามารถดาวน์โหลดตาม OS ได้ที่ link นี้<br><a href="https://pkgs.org/download/libaio1">https://pkgs.org/download/libaio1</a><br><a href="https://pkgs.org/download/libmecab2">https://pkgs.org/download/libmecab2</a></p><p>จริงๆ แล้วสามารถใช้ <em>sudo apt-get install libaio1 libmecab2 -y </em>แทนการลงแบบ<br>Binary Package ได้</p><p>ส่วนที่จำเป็นสำหรับ data node มีดังต่อไปนี้<br> - libaio1<br> - libmecab2<br> - mysql-common<br> - mysql-cluster-community-client-plugins<br> - mysql-cluster-community-client-core<br> - mysql-cluster-community-client <br> - mysql-client<br> - mysql-cluster-community-server-core<br> - mysql-cluster-community-server<br> - mysql-server</p><pre>$ wget <br>http://archive.ubuntu.com/ubuntu/pool/main/liba/libaio/libaio1_0.3.112-9ubuntu1_amd64.deb</pre><pre>$ wget http://archive.ubuntu.com/ubuntu/pool/main/m/mecab/libmecab2_0.996-14build3_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-common_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client-plugins_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-server-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-cluster-community-server_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-8.0/mysql-server_8.0.26-1ubuntu21.04_amd64.deb</pre><ul><li><strong>ติดตั้ง Package ที่จำเป็นสำหรับ MySQL Cluster API/MySQL node</strong></li></ul><pre>$ sudo dpkg -i libaio1_0.3.112-9ubuntu1_amd64.deb</pre><pre>$ sudo dpkg -i libmecab2_0.996-14build3_amd64.deb</pre><pre>$ sudo dpkg -i mysql-common_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client-plugins_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-client_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-server-core_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-cluster-community-server_8.0.26-1ubuntu21.04_amd64.deb</pre><pre>$ sudo dpkg -i mysql-server_8.0.26-1ubuntu21.04_amd64.deb</pre><ul><li><strong>แก้ไข file config สำหรับ MySQL Cluster ตัว API/MySQL Node</strong></li></ul><pre>$ sudo vim /etc/mysql/my.cnf</pre><ul><li><strong>เขียน config ภายใน file /etc/mysql/my.cnf</strong></li></ul><pre>!includedir /etc/mysql/conf.d/<br>!includedir /etc/mysql/mysql.conf.d/</pre><pre># API/MySQL Node Config<br>[mysqld]<br>ndbcluster                             # run NDB storage engine</pre><pre>[mysql_cluster]<br>ndb-connectstring=10.0.0.1,10.0.0.2    # location of management node</pre><p>Parameter สำหรับการตั้งค่า MySQL Server ใน file <strong>/etc/mysql/my.cnf</strong></p><p><a href="https://dev.mysql.com/doc/refman/8.0/en/server-option-variable-reference.html">MySQL :: MySQL 8.0 Reference Manual :: 5.1.4 Server Option, System Variable, and Status Variable Reference</a></p><ul><li><strong>สั่ง restart และ enable mysql</strong></li></ul><pre>$ sudo systemctl restart mysql<br>$ sudo systemctl enable mysql</pre><ul><li><strong>Check การทำงานของ API/MySQL node ที่เครื่อง management node</strong></li></ul><pre>$ ndb_mgm -e &quot;show&quot;</pre><p>โดยนำการตั้งค่าจาก step 3 นี้ไปตั้งค่าทุกเครื่องที่เป็น API/MySQL node เหมือนกันด้วยทุก step</p><h3>ข้อแนะนำเพิ่มเติม</h3><ul><li>เมื่อทำการขึ้นเรียบร้อยแล้วสามารถทดสอบการใช้งาน MySQL Cluster ได้ผ่านการใช้คำส่ง mysql -uroot -p ทดสอบ login ได้ที่ API/MySQL node <br>ถ้าไม่รู้ว่า Password คืออ่ะไรสามารถเข้าตามลิงค์ด้านล่างนี้เพื่อ reset password ของ MySQL Database ได้</li></ul><p><a href="https://www.a2hosting.com/kb/developer-corner/mysql/reset-mysql-root-password">How to reset the MySQL root password</a></p><ul><li>การสร้าง User ทั่วไปที่ไม่ใช่ root และ administrator บน MySQL Server <br>เมื่อจะสร้าง User ทั่วไปของ MySQL จะต้อง Grant สิทธิ์ NDB_STORED_USER ด้วย ข้อมูลของ User ระหว่าง API/MySQL Node ทั้งสองตัวถึงจะ Replicate กัน (ยกเว้นถ้าจะตั้งสิทธิ์ Administrator ก็ไม่ต้อง grant เพิ่มก็ได้เพราะมัน grant all privileges on *.* คือได้ทุกสิทธิ์ทุกที่หมดอยู่แล้ว)</li></ul><pre>CREATE USER &#39;newuser&#39;@&#39;%&#39; IDENTIFIED BY &#39;password&#39;;</pre><pre>GRANT NDB_STORED_USER ON *.* TO &#39;user&#39;@&#39;%&#39;;</pre><pre>GRANT ALL PRIVILEGES ON  DB.* TO &#39;user&#39;@&#39;%&#39;;  </pre><ul><li>การสร้าง Table จะต้องใช้ Storage Engine เป็น ndbcluster ด้วย ตัวโครงสร้างและข้อมูลของ Table นี้จึงจะสามารถใช้งานระบบ MySQL Cluster และทำการ Replicate ข้อมูลบน API/MySQL node ทั้งสองตัวได้</li></ul><pre>CREATE TABLE `test` (</pre><pre>`id` bigint NOT NULL,</pre><pre>`name` varchar(255) DEFAULT NULL,</pre><pre>) ENGINE=ndbcluster;</pre><p>ซึ่งหลังจากการตั้งค่าทั้งหมดและ MySQL Cluster สามารถทำงานได้อย่างถูกต้อง เราก็สามารถใช้ Load Balance เช่น Nginx หรือ HAproxy ขึ้นด้านหน้า API/MySQL Node เพื่อทำการแชร์ transaction ที่เข้ามาและเพิ่ม High Availability โดย วิธีการตั้งค่าสามารถทำตามได้ตามลิงค์ด้านล่างเลยครับ</p><p><a href="https://medium.com/@rapepatpengsart/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87-load-balance-%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A-mysql-cluster-ed5fca2d2708">การติดตั้ง Load Balance สำหรับ MySQL Cluster</a></p><p>สุดท้ายถ้าบทความนี้มีส่วนไหนไม่ถูกต้อง หรือติดปัญหาจากการติดตั้งสามารถพิมพ์สอบถามได้ที่ช่อง comment ด้านล่างได้เลยนะครับ</p><p>Reference เพิ่มเติม</p><ul><li><a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-multi-node-mysql-cluster-on-ubuntu-18-04">How To Create a Multi-Node MySQL Cluster on Ubuntu 18.04 | DigitalOcean</a></li><li><a href="https://www.howtoforge.com/tutorial/how-to-install-and-configure-mysql-cluster-on-centos-7/">How to Install and Configure MySQL Cluster on CentOS 7</a></li><li><a href="http://www.clusterdb.com/mysql-cluster/mysql-cluster-fault-tolerance-impact-of-deployment-decisions">Andrew Morgan on Databases</a></li><li><a href="https://sites.google.com/site/kittirak/mysql-cluster?authuser=0">kittirak - MySQL Cluster</a></li><li><a href="https://clustertesting.blogspot.com/2021/01/mysql-ndb-cluster-backup-restore-in.html">MySQL NDB Cluster Backup &amp; Restore In An Easy Way</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a095bc2a724" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>