Paste the following code into a terminal on CentOS 8. It also works on CentOS 7 and will work on Red Hat 8, RHEL8, as well.
Where the first line has 4G, you can increase or decrease this number which refers to the size of the Swap RAM partition.
fallocate -l 4G /swapfile
chmod 600 /swapfile
echo '/swapfile swap swap sw 0 0' >> /etc/fstab