{"id":6065,"date":"2021-04-26T11:39:51","date_gmt":"2021-04-26T11:39:51","guid":{"rendered":"https:\/\/linuxways.net\/?p=6065"},"modified":"2021-04-26T11:39:51","modified_gmt":"2021-04-26T11:39:51","slug":"how-to-install-and-configure-memcached-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-and-configure-memcached-on-centos-8\/","title":{"rendered":"How to Install and Configure Memcached on CentOS 8"},"content":{"rendered":"<p>Memcached is an open-source, high-performance, freely available, and in-memory key-value caching server. It provides various features such as helps to speed up the applications by caching the various objects from the user authentication tokens and database API calls, and. Moreover, Memcached caching server helps in sharing a large amount of data across multiple application instances.<\/p>\n<p>We will explain the installation procedure and configuration of Memcached on CentOS 8 system in this article.<\/p>\n<h2><strong>Prerequisites<\/strong><\/h2>\n<p>To install and configure the Memcached server, root credentials or sudo privileges are required.<\/p>\n<h2><strong>Installation of Memcached on CentOS 8<\/strong><\/h2>\n<p>To install and configure Memcached on CentOS 8 follow the following steps:<\/p>\n<h3><strong>Step 1: Install Memcached caching server<\/strong><\/h3>\n<p>Before starting the installation of the Memcached service, it is recommended that update all system packages to refresh the repository. So, update the apt packages list by typing the below-given command:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>The Memcached packages are already present in the default CentOS 8 repository. Therefore, the installation of these packages is quite easy. Just type the following command with root privileges to install the Memcached on CentOS 8 system:<\/p>\n<pre>$ sudo dnf install memcached libmemcached<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1186\" height=\"67\" class=\"wp-image-6066\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-331.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-331.png 1186w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-331-300x17.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-331-1024x58.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-331-768x43.png 768w\" sizes=\"auto, (max-width: 1186px) 100vw, 1186px\" \/><\/p>\n<p>The \u2018libmemcached\u2019 package comes with various other command-line tools for managing the Memcached services.<\/p>\n<p>During the installation of Memcached, the list of necessary Memcached dependencies along with total size displays on the terminal. To continue the installation of these dependencies press \u2018y\u2019 and then hit the \u2018Enter\u2019 key from your keyboard.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1198\" height=\"763\" class=\"wp-image-6067\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-332.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-332.png 1198w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-332-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-332-1024x652.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-332-768x489.png 768w\" sizes=\"auto, (max-width: 1198px) 100vw, 1198px\" \/> After that, all dependencies and a list of packages will be downloaded and installed on your system as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1195\" height=\"761\" class=\"wp-image-6068\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-333.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-333.png 1195w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-333-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-333-1024x652.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-333-768x489.png 768w\" sizes=\"auto, (max-width: 1195px) 100vw, 1195px\" \/><\/p>\n<p>When the \u2018complete\u2019 status shows on the terminal window that means the installation of all Memcached packages has been completed on this system.<\/p>\n<h3><strong>Step 2: Verify the Memcached installation<\/strong><\/h3>\n<p>Once the installation of the Memcached server is completed, you can ensure the Memcached installation on your system by running the following command:<\/p>\n<pre>$ rpm -q memcached<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1103\" height=\"88\" class=\"wp-image-6069\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-334.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-334.png 1103w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-334-300x24.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-334-1024x82.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-334-768x61.png 768w\" sizes=\"auto, (max-width: 1103px) 100vw, 1103px\" \/><\/p>\n<p>The above command will verify that either Memcached is installed on your system or not. To get more information about the installed Memcached server such as version, architecture, and more. Use the about command with the \u2018qi\u2019 parameter, that displays all information about the installed Memcached caching server:<\/p>\n<pre>$ rpm -qi memcached<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1186\" height=\"622\" class=\"wp-image-6070\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-335.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-335.png 1186w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-335-300x157.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-335-1024x537.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-335-768x403.png 768w\" sizes=\"auto, (max-width: 1186px) 100vw, 1186px\" \/><\/p>\n<h3><strong>Step 3: Enable Memcached Service on CentOS 8<\/strong><\/h3>\n<p>Now, enable the Memcached services on your CentOS 8 system by typing the following command:<\/p>\n<pre>$ sudo systemctl enable memcached --now<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1188\" height=\"118\" class=\"wp-image-6071\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-336.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-336.png 1188w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-336-300x30.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-336-1024x102.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-336-768x76.png 768w\" sizes=\"auto, (max-width: 1188px) 100vw, 1188px\" \/><\/p>\n<p>To check the Memcached caching server running status on your system, use the following command:<\/p>\n<pre>$ sudo systemctl status memcached<\/pre>\n<p>The following Memcached service \u2018running\u2019 status should display on the terminal.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1193\" height=\"326\" class=\"wp-image-6072\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-337.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-337.png 1193w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-337-300x82.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-337-1024x280.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-337-768x210.png 768w\" sizes=\"auto, (max-width: 1193px) 100vw, 1193px\" \/><\/p>\n<p>To exit from the above-displayed output press \u2018Ctrl+C\u2019.<\/p>\n<p>Now, the installation of Memcached is completed. We will discuss the Memcached configurations details in the rest of the article section.<\/p>\n<h2><strong>Memcached Configuration on CentOS 8<\/strong><\/h2>\n<p>Memcached configuration file you can find at this \u2018\/etc\/sysconfig\/memcached\u2019 location. By default, the Memcached services run on the local host and listen on port \u201811211\u2019. If the client with which you want to connect is also running on the same server that you don\u2019t need to make any changes to the configuration file. Open the Memcached configuration file by executing the following command:<\/p>\n<pre>$ sudo nano \/etc\/sysconfig\/memcached<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1197\" height=\"761\" class=\"wp-image-6073\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-338.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-338.png 1197w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-338-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-338-1024x651.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-338-768x488.png 768w\" sizes=\"auto, (max-width: 1197px) 100vw, 1197px\" \/><\/p>\n<p>If the applicant connecting to the server is running on the remote host then, you need to make some changes to the Memcached configuration file.<\/p>\n<p>Let\u2019s suppose, in the private network, the IP of the Memcached server is \u2018192.168.100.16\u2019 and the client\u2019s IP is \u2018192.168.100.26\u2019. So, allows access to the server\u2019s listening port and changes the following line in the configuration file:<\/p>\n<pre>OPTIONS=\"-l 192.168.100.16\"<\/pre>\n<p>Save the above configuration and restart the Memcached services by using the below-mentioned command:<\/p>\n<pre>$ sudo systemctl restart memcached<\/pre>\n<h2><strong>Allow Firewall access<\/strong><\/h2>\n<p>The following commands will create a new zone named Memcached and allow access to the required port and client\u2019s IP.<\/p>\n<pre>$ sudo firewall-cmd --new-zone=memcached --permanent<\/pre>\n<pre>$ sudo firewall-cmd --zone=memcached --add-port=11211\/udp --permanent<\/pre>\n<pre>$ sudo firewall-cmd --zone=memcached --add-port=11211\/tcp --permanent<\/pre>\n<pre>$ sudo firewall-cmd --zone=memcached --add-source=192.168.100.16\/24 --permanent<\/pre>\n<pre>$ sudo firewall-cmd --reload<\/pre>\n<p>Now, enable and restart again the Memcached services.<\/p>\n<h2><strong>Connect to Memcached<\/strong><\/h2>\n<p>To connect with the Memcached server, you will always need to use the language-specific client.<\/p>\n<h3><strong>Memcached for Python<\/strong><\/h3>\n<p>There are many python libraries available to connect with Memcached. You can easily install these python packages through the pip tool.<\/p>\n<pre>$ pip install pymemcache<\/pre>\n<pre>$ pip install python-memcached<\/pre>\n<h3><strong>Memcached with PHP<\/strong><\/h3>\n<p>To use the Memcached caching database with PHP application, you need to install the relevant extension on your CentOS 8 system as follows:<\/p>\n<pre>$ sudo dnf install php-pecl-memcache<\/pre>\n<h2><strong>Uninstall Memcached\u00a0<\/strong><\/h2>\n<p>If you don\u2019t find it useful more on your system then, by executing the following command you can uninstall the Memcached caching server from CentOS 8 along with dependencies:<\/p>\n<pre>$ sudo dnf remove memcached libmemcached<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1201\" height=\"759\" class=\"wp-image-6074\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-339.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-339.png 1201w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-339-300x190.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-339-1024x647.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-339-768x485.png 768w\" sizes=\"auto, (max-width: 1201px) 100vw, 1201px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have explained in this article, how to install and configure the Memcached caching server on CentOS 8 system through the command-line tool. We have elaborated on each step in detail. Now, you can easily install and configure the Memcached server on your CentOS 8 system easily. To read more details about the Memcached server, you can get more help through the internet resources. Please inform us about your queries.<\/p>","protected":false},"excerpt":{"rendered":"<p>Memcached is an open-source, high-performance, freely available, and in-memory key-value caching server. It provides various features such as helps to speed up the applications by caching the various&hellip;<\/p>","protected":false},"author":1,"featured_media":6093,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[93,295],"class_list":["post-6065","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-8","tag-memcached"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6065","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=6065"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/6065\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/6093"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=6065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=6065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=6065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}