Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

How to install and configure memcached on Ubuntu Linux 18.04

by Editorial Staff
December 4, 2018
in Linux
Reading Time: 4 mins read

[ad_1]

I would like to reduce the load on my MariaDB/MySQL/PostgreSQL server using memcached. How do I install and configure memcached server on Ubuntu Linux 18.04 LTS?

Introduction : Memcached is a high-performance, distributed memory object caching server. It is free and open source software intended for use in speeding up dynamic web applications by mitigating database load. This page shows how to install, configure, verify memcached installation on Ubuntu Linux 18.04 LTS.

How to install and configure memcached on Ubuntu 18.04

The procedure to install and configure memcached on Ubuntu is as follows:

  1. Update your Ubuntu based system using the apt command
  2. Install memcached on Ubuntu by running sudo apt install

Step 1 – Update your Ubuntu server

Type the following apt command or apt-get command to upgrade system to latest software:
$ sudo apt update
$ sudo apt upgrade

Update Ubuntu Linux 18.04 LTS server package index
Update Ubuntu Linux 18.04 LTS server package index and install updates if any

Step 2 – Install memcached server on Ubuntu

Again run apt command as follows:
$ sudo apt install memcached

Ubuntu Linux 18.04 LTS install and configure memcached
Installing memcached server from the official Ubuntu repos

Step 3 – Configure memcached server on Ubuntu Linux 18.04 LTS

Next you need to edit config file named /etc/memcached.conf using a text editor such as nano command or vim command:
$ sudo nano /etc/memcached.conf
OR
$ sudo vi /etc/memcached.conf
Start with a cap of 256 MB of memory:
-m 256
Default connection port for memcached is 11211:
-p 11211
Specify which IP address to listen on. The default is to listen on all IP addresses. This parameter is one of the only security measures that memcached has, so make sure
it’s listening on a firewalled interface. In my example, I am going to listen on 127.0.0.1 and servers private IP address 172.26.12.173 :
-l 127.0.0.1,172.26.12.173
Limit the number of simultaneous incoming connections. The daemon default is 1024 but I am going to increase to 4096:
-c 4096
Save and close the file when using vim text editor by typing ESC + 😑.

How to restart, stop, reload memcached server on Ubuntu 18.04

One can use the systemctl command as follows:
$ sudo systemctl stop memcached
$ sudo systemctl start memcached
$ sudo systemctl restart memcached
$ sudo systemctl status memcached

How to start, stop, restart memached on Ubuntu Linux
Command to start, stop, restart memached on Ubuntu Linux 18.04 LTS

How to open memcached port 11211 using ufw

Let us say you have lxd based containers running on Ubuntu and using 10.147.164.0/24 sub-net range. I am going to limit IP access with the ufw based firewall on Ubuntu as follows:
sudo ufw allow from container_ip1 to any port 11211
sudo ufw allow from vm2_ip2 to any port 11211
sudo ufw allow from sub/net to any port 11211
sudo ufw allow from 10.147.164.5 to any port 11211
sudo ufw allow from 10.147.164.3 to 172.26.12.173 port 11211 proto tcp
sudo ufw allow from 10.147.164.0/24 to any port 11211

How to verify that memcached is running

Use the ss command or netstat command to verify that TCP port # 11211 open and listing:
$ sudo ss -tulpn | grep :11211
$ sudo netstat -tulpn | grep :11211

Verify memcached works before using it from Ubuntu

How to install CLI tool for talking to memcached via libmemcached

Let us install libmemcached-tools for management of memcached server and testing purpose:
$ sudo apt install libmemcached-tools
Ubuntu commandline tools for talking to memcached via libmemcached
Verify memcached server connectivity:
$ memcstat --servers=127.0.0.1

Dumps the state of memcached servers
Dumps the state of memcached servers with the help of memstat command

How to access memcached from PHP/Perl/Python/Ruby lang

Install package as per your needs:

  • ruby-dalli – Ruby client
  • php-memcached – PHP module
  • python-memcache – Python client
  • python3-pymemcache – Python 3.x client
  • libcache-memcached-libmemcached-perl – Perl for Memcached::libmemcached
See also  How Common Signals are Used in Kubernetes Pod Management

Conclusion

This page showed how to install, configure, verify memcached server on Ubuntu Linux 18.04 LTS. For more info see the official memached project page here. Alternately, you can install memcached extensions for WordPress to improve performance.

[ad_2]

Related Posts

Top Commands to Check the Running Processes in Linux
Linux

Top Commands to Check the Running Processes in Linux

May 27, 2022
4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error
Linux

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022
How Common Signals are Used in Kubernetes Pod Management
Linux

How Common Signals are Used in Kubernetes Pod Management

November 20, 2021

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

30 VUDU Alternatives To Watch Movies And TV Shows Online

30 VUDU Alternatives To Watch Movies And TV Shows Online

July 3, 2022
finland web hosting reviews

Top 10 Finland Web Hosting Reviews 2022

July 3, 2022
warehouse management systems software

Top 10 Best Warehouse Management Systems In 2022

July 2, 2022
Find Old Pensions and Boost Your Retirement Income

Find Old Pensions and Boost Your Retirement Income

July 2, 2022
Industry 4.0: Unlocking New Business Opportunities for the Manufacturing Industry

Industry 4.0: Unlocking New Business Opportunities for the Manufacturing Industry

July 2, 2022
  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

Β© Techolac Β© Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

Β© Techolac Β© Copyright 2019 - 2022, All Rights Reserved.

Go to mobile version