How to install Memcached on CentOS 8

Memcached is a free and open source high-performance memory key-value database. It is mainly used for system caching to improve the response speed of the application by caching the results in the database.

In this guide, we will explain how to install and configure Memcached on CentOS 8.

1. Install Memcached on CentOS

The Memcached package is included in the default CentOS 7 software source. The installation is very simple. Enter the following command as root or another user with sudo privileges:

sudo dnf install memcached libmemcached

The libmemcached package provides some command-line tools for managing Memcached servers.

Once the installation is complete, start and enable the Memcached service.

sudo systemctl enable memcached --now

To verify that memcached is running, enter:

sudo systemctl status memcached

The output is similar to the following:

● memcached.service - memcached daemon
 Loaded:loaded(/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
 Active:active(running) since Mon 2020-04-1320:12:52 UTC; 2s ago
   ...

that's it. You have installed Memcached on your CentOS 8 system and you can start using it.

Two, configure Memcached

Memcached can be configured by editing the /etc/sysconfig/memcached file. By default, Memcached listens to all network interfaces.

If the client connecting to the server is also running on the same server, you do not need to make any changes.

2.1 remote access##

If the application you connect to Memcached is hosted on a remote server, you need to configure your firewall and allow access to Memcached port `11211 from the client IP address.

When improperly configured, Memcached can be used to perform DDOS attacks.

The following example assumes that you want to connect to the Memcached server on the same LAN. The Memcached server IP is 192.168.100.20, and the client's IP address is 192.168.100.30.

The first step is to edit the Memcached configuration file and set the service to monitor the LAN interface:

Open the memcached configuration file:

sudo nano /etc/sysconfig/memcached

In the OPTIONS parameter, add the server IP address -l 192.168.100.20. This informs Memcached to only listen on the specified interface.

OPTIONS="-l 192.168.100.20"

Save the file and restart the Memcached service to make the application take effect:

sudo systemctl restart memcached

Once the service is configured, the next step is to open the memcached port on your firewall.

The CentOS firewall configuration tool is FirewallD. This command will create a new zone with the name memcached, open port 11211 and only allow access from the client IP address.

sudo firewall-cmd --new-zone=memcached --permanent
sudo firewall-cmd --zone=memcached --add-port=11211/udp --permanent
sudo firewall-cmd --zone=memcached --add-port=11211/tcp --permanent
sudo firewall-cmd --zone=memcached --add-source=192.168.100.30/32--permanent
sudo firewall-cmd --reload

Three, connect to Memcached

To connect to the Memcached server, you need to use a client in a specific language.

3.1 PHP

To use Memcached as your PHP application such as Wordpress, Drupal or Magento, you need to install the php-pecl-memcached :

sudo dnf install php-pecl-memcache

3.2 Python

There are some libraries on Python that can be used to interact with memcache, you can use pip to install your favorite libraries:

pip install pymemcache
pip install python-memcached

Four, summary##

We have shown you how to install Memcached on CentOS 8. For more information on this topic, read Memcached Wiki.

Recommended Posts

How to install Memcached on CentOS 8
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on Ubuntu 20.04
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Memcached on Ubuntu 18.04
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to install offline JDK1.8 on centos7.0
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
How to install RPM packages on CentOS Linux
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8
How to install VirtualBox client extension on CentOS 8