+4 votes
628 views
How to install Memcached on CentOS 8 | SET UP

in Linux / Unix by (552k points)
reopened | 628 views

1 Answer

+5 votes
Best answer

1. How to install Memchached on CentOS 8
2. How to configure Memcached in CentOS 8
3. How to enable Memcached for CentOS 8 applications

The operating systems handle different ways of managing the registered data and one of these is that in the memory of the computer , the cache is saved. This cache is sent by web objects and in memory this cache integrates a series of parameters and instructions that allow them to be read by the CPU and with this, much faster access to these sites is offered..

 

However, an accumulation of this cache can be an error factor, especially if web objects (such as web pages) change their IP or values, to manage the cache in a more comprehensive way we have a utility called "Encachad" and we will see how to use it in CentOS 8 .

 

What is Memcached
Memcached has been developed as a high performance caching system optimizing the use and management of the cache in the system. Its goal is to accelerate dynamic web applications by directly managing the load on the database which directly impacts performance.

 

To understand how memchached helps this process we must understand that the application will use parts of the system where there is plenty of memory and that we do not use, and that portion implements it in the scarce or needed area, this facilitates the following:

  • That each node can be independent of the other
  • That each node can make use of the memory of other nodes to optimize processes where memory is missing

 

Memcached
Memcached is made up of the following:
  • A client software, which lists the available memcached servers
  • Integration of a hashing algorithm, this algorithm is client-based and allows you to select a server based on the distributed key for security issues.
  • The server software in which the values ​​are stored with their respective keys assigned in an internal hash table.
  • The LRU which indicates when memcached should access old data to speed processes

 

 


1. How to install Memchached on CentOS 8


By default, Memcached packages are included in the CentOS 8 repositories. This allows us to use the dnf package manager for installation.

 

Step 1

We are going to execute the following:
 sudo dnf  install  memcached libmemcached 
image

 

Step 2

We enter the letter "s" to validate the download and installation of Memchached and its packages:

 

image

 

Step 3

Detailed information about the Memcached package can be accessed with the following command:
 rpm -qi memcached 
image

 

There we find specific details of Memcached..

 

Step 4

Memcached can be installed directly from the source with the following lines:
 sudo yum install libevent-devel sudo wget https:  //memcached.org/latest  tar -zxf memcached  -1.  xxtar.gz cd memcached  -1.  xx ./configure --prefix = / usr / local / memcached  make  &&  make  test && sudo  make  install 

2. How to configure Memcached in CentOS 8


The Memcached configuration is available in the / etc / sysconfig / memcached file and has different variables to use.

 

Step 1

By default Memcached listens to port 11211 and is configured to listen only to the localhost system as we can see in the file:
 nano / etc / sysconfig / memcached 
image

 

Step 2

If we need to configure Memcached so that applications on remote systems are able to connect to the server, there we must change the local host address 127.0.0.1 to the remote host address.

 

The values ​​in this file are:

 

PORT
Refers to the port used by Memcached for its execution.

USER
Indicates the start daemon for the memcached service.

MAXCONN
This is a value that allows you to define the number of simultaneous connections, its default value is 1024 and it can be edited based on current needs.

CACHESIZE
It is an editable value which refers to the size of the cache memory which by default is 2048 and it is possible to increase it up to 4 GB.

OPTIONS
There it is possible to configure the IP address of the server, so that the Apache or Nginx web servers can connect here

 

In case of allowing external connections, we must enable the Firewall permissions:

 sudo firewall-cmd --  add  -port =  11211  / tcp --zone =  public  --permanent sudo firewall-cmd –reload 
image

 

Step 3

We confirm that the port is authorized with the following command:
 sudo firewall-cmd --  list  -ports | grep  11211  
image

 

Step 4

Let's start and enable Memcached at the start of CentOS 8 boot:
 sudo systemctl  start  memcached sudo systemctl  enable  memcached 
image

 

Step 5

We check the Memcached status:
 sudo systemctl status memcached 
image

 


3. How to enable Memcached for CentOS 8 applications

 

Step 1

Some applications have PHP technology, these allow you to install the php-pecl-memcache extension so that the application can establish a connection to the Memcached server:
 sudo dnf  install  php-pecl-memcache (memcached extension  for  PHP) sudo dnf  install  perl-  Cache  -Memcached (memcached extension  for  PERL) sudo dnf  install  python-memcached (memcached extension  for  PYTHON) 
Step 2

To validate the statistics of the local server we will execute the following:
  memcached-tool  127  .0   .0   .1   stats  
image

 

Memcached is a comprehensive option to manage the cache on our CentOS 8 server.

 


by (3.5m points)

Related questions

+3 votes
1 answer
asked Jun 22, 2019 in Linux / Unix by backtothefuture (552k points) | 234 views
+4 votes
1 answer
asked Oct 8, 2020 in Linux / Unix by backtothefuture (552k points) | 364 views
+5 votes
1 answer
asked Sep 2, 2020 in Linux / Unix by backtothefuture (552k points) | 2k views
+3 votes
1 answer
asked Aug 13, 2020 in Linux / Unix by backtothefuture (552k points) | 1.9k views
+4 votes
1 answer
asked Jun 9, 2020 in Linux / Unix by backtothefuture (552k points) | 625 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users