{"id":29136,"date":"2019-12-03T10:00:46","date_gmt":"2019-12-03T18:00:46","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/?p=29136"},"modified":"2024-01-22T22:51:23","modified_gmt":"2024-01-23T06:51:23","slug":"how-to-configure-persistent-memory-for-sql-server-on-linux","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/sql-server\/blog\/2019\/12\/03\/how-to-configure-persistent-memory-for-sql-server-on-linux\/","title":{"rendered":"How to configure persistent memory for SQL Server on Linux"},"content":{"rendered":"
With the release of SQL Server 2019 on Linux, Microsoft introduced persistent memory (PMEM) support on Linux. This is an exciting development, as previous versions of SQL Server on Linux didn\u2019t support PMEM. Let\u2019s look at how to configure the PMEM for SQL Server on Linux.<\/p>\n
SQL Server 2016 introduced support for non-volatile DIMMs and an optimization called Tail of the Log Caching on NVDIMM<\/a>.\u00a0These leveraged Windows Server direct access to a persistent memory device in DAX mode to reduce the number of operations needed to harden a log buffer to persistent storage.<\/p>\n SQL Server 2019 extends the support for PMEM devices to Linux, providing full enlightenment of data and transaction logs placed on PMEM. Enlightenment is a way to access the storage device using efficient user-space memcpy() operations. Rather than going through the file system and storage stack, SQL Server leverages DAX support on Linux to place data directly into the device. This helps to reduce latency.<\/p>\n The first step to enabling enlightenment of database files in SQL Server on Linux is to configure the devices. In Linux, use the ndctl utility to configure PMEM device and create a namespace<\/a>.<\/p>\n ndctl create-namespace -f -e namespace0.0 –mode=fsdax* –map=mem<\/p>\n You can verify the namespace using ndctl, as shown by this sample output:<\/p>\n ndctl list<\/p>\n [<\/p>\n \u00a0 {<\/p>\n \u00a0\u00a0\u00a0 “dev”:”namespace0.0″,<\/p>\n \u00a0\u00a0\u00a0 “mode”:”memory”,<\/p>\n \u00a0\u00a0\u00a0 “size”:1099511627776,<\/p>\n \u00a0\u00a0\u00a0 “blockdev”:”pmem0″,<\/p>\n \u00a0\u00a0\u00a0 “numa_node”:0<\/p>\n \u00a0 }<\/p>\n ]<\/p>\n Next, create and mount PMEM device.<\/p>\n With XFS:<\/p>\n mkfs.xfs -f \/dev\/pmem0<\/p>\n mount -o dax,noatime \/dev\/pmem0 \/mnt\/dax<\/p>\n xfs_io -c “extsize 2m” \/mnt\/dax<\/p>\n With EXT4:<\/p>\n mkfs.ext4 -b 4096 -E stride=512 -F \/dev\/pmem0<\/p>\n mount -o dax,noatime \/dev\/pmem0 \/mnt\/dax<\/p>\n Once your device has been configured, formatted, and mounted, you can place database files in it or create a new database.<\/p>\n Note that PMEM devices are O_DIRECT safe. Therefore, you must enable trace flag (TF) 3979 using mssql-conf utility to disable the forced flush mechanism. This is a server-wide configuration change, so don\u2019t use this trace flag if you have any O_DIRECT non-compliant devices that require forced flush to ensure data integrity.<\/p>\n Now that you know how to use PMEM on SQL Server 2019 on Linux, you can reduce latency considerably. To learn more about what you can do with Microsoft SQL 19, check out the free Packt guide Introducing Microsoft SQL 19<\/a>. If you\u2019re ready to jump to a fully managed cloud solution, check out the Essential Guide to Data in the Cloud<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" With the release of SQL Server 2019 on Linux, Microsoft introduced persistent memory (PMEM) support on Linux. This is an exciting development, as previous versions of SQL Server on Linux didn\u2019t support PMEM. Let\u2019s look at how to configure the PMEM for SQL Server on Linux. SQL Server 2016 introduced support for non-volatile DIMMs and<\/p>\n","protected":false},"author":1457,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","footnotes":""},"post_tag":[],"product":[5227,2536,2418],"content-type":[2424],"topic":[],"coauthors":[2487],"class_list":["post-29136","post","type-post","status-publish","format-standard","hentry","product-sql","product-sql-server-2019","product-sql-server-on-linux","content-type-best-practices"],"yoast_head":"\nEnable enlightenment of database files<\/h2>\n