+5 votes
206 views
How to configure Memcached Ubuntu

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

1 Answer

+3 votes
Best answer

1. How to install Memcached in Ubuntu Server 20.04
2. How to configure Memcached in Ubuntu
3. How to enable the use of Memcached with Ubuntu applications

One of the objects that allows us to access websites or the configuration of an application faster is the cache memory. It is housed in memory with the various variables of the site or application so that access is light since the CPU must not read the web properties and thus speeds up this process. But if said site, for example, if the site modifies its IP address or if any of its redirect files is modified, this will cause the opposite effect since its opening will be slow and with errors..

 

To help maintain this cache control we have a utility called Memcached which we will explain through this tutorial.

 

What is Memcached
The memcached utility allows centralized control over the Ubuntu cache based on the acceleration of web applications since it processes directly on the database load which is closely related to performance when opening. applications or websites.

 

Memcached acts in a simple way since it analyzes the memory resources and will take from where there is more quantity in order to offer it where it is scarce. This allows for a better distribution of this memory and this results in the following:

  • Make each node independent of other nodes
  • Enables each node to use memory from other nodes in order to optimize and speed up processes where memory is scarce

 

characteristics
By installing memcached we are accessing the following:
  • The client software thanks to which we can see the available memcached servers in the system
  • A server software where the values ​​of the assigned keys are stored in an internal hash table
  • Memcached adds a hashing algorithm which is client based in order to select a server based which is based on the distributed key, this helps to improve the security of memcached
  • An LRU which allows us to see when memcached needs to access old data in order to speed up processes

 

That is why below we give you all the steps you must follow to know how to install Memcached in Ubuntu Server 20.04 and how to configure it step by step..

 

 


1. How to install Memcached in Ubuntu Server 20.04

 

Step 1

The first step will be to update the system packages, for this we execute:
 sudo apt  update  
image

 

Step 2

Next we are going to install memcached in Ubuntu by executing the following command:
 sudo apt  install  memcached libmemcached-tools 
image

 

Step 3

We enter the letter "S" to confirm the download and installation of memcached in the system:

 

image

 

Step 4

When we have installed memcached we will validate its status by executing:
 sudo systemctl status memcached 
image

 

Up to this point we have installed memcached on Ubuntu Server.

 


2. How to configure Memcached in Ubuntu


Memcached configuration settings are housed in the /etc/memcached.conf directory. There we find that Memcached listens on port 11211 and is configured to listen through the localhost.

 

Step 1

We validate this by accessing the preferred editor:
 sudo nano /etc/memcached.conf 
image

 

In case the application to connect to the memcached service is installed on the same memcached server, this line should be left the same without any modification, but if it has to be connected remotely, we must edit the localhost address (127.0 .0.1) by the IP address of the remote client..

 

Step 2

In case of making any changes we save it with the Ctrl + O keys and we leave the editor with the Ctrl + X keys.
Then we restart memcached by executing:
 sudo systemctl restart memcached 
image

 

Step 3

Now we must allow remote connections to Ubuntu, for this we grant these permissions in the Ubuntu Firewall as follows:
 sudo ufw allow 11211 / tcp we apply the changes: sudo ufw reload 
Note
In case the Firewall is not active we must execute "sudo ufw enable" for its enablement.

 

 

image

 

Step 4

We check the status of the Firewall:
 sudo ufw status 
image

 


3. How to enable the use of Memcached with Ubuntu applications


Based on the applications that we have to administer, we must install the respective utilities.

 

Step 1

For example, if we want to manage PHP we will execute:
 sudo apt  install  php-memcached 
image

 

Step 2

For Python we execute:
 pip  install  pymemcache pip  install  python-memcached  On  the  local   server  we can  check  the 
Cache status by executing the following:
 memcstat --servers =  "127.0.0.1"  
image

 

Step 3

To check the memcached records we will use the following line:
 sudo journalctl -u memcached 
image

 

With memcached it will be very simple and centralized the cache management in Ubuntu Server. In this way you will know how to install and configure Memcached in Ubuntu Server 20.04 to be able to use this utility and take advantage of all the benefits it offers.

 


by (3.5m points)

Related questions

+5 votes
1 answer
asked Aug 20, 2019 in Linux / Unix by backtothefuture (552k points) | 497 views
+4 votes
1 answer
asked May 14, 2020 in Linux / Unix by backtothefuture (552k points) | 637 views
+3 votes
1 answer
asked Jun 22, 2019 in Linux / Unix by backtothefuture (552k points) | 239 views
+3 votes
1 answer
+5 votes
1 answer
asked Nov 10, 2019 in Linux / Unix by backtothefuture (552k points) | 321 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