How to install memcached on OpenSUSE / SUSE Linux

There is no greater hope in human life than survival. At the same time, it is important to live well. With that in mind, every content on the website is written so that a person can get all the information from here to start his life to make beautifully.

According to that, Technology is one of the topics. It is also a part of life.

Read carefully Details of Technology related article

While working with the client’s system, I noticed that the database would come under load due to increased demand. After reviewing the code, the developer and I conclude that something like memcached will improve performance by caching queries. This page explains how to install a memcached server on OpenSUSE or SUSE enterprise Linux server using the ssh command.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements OpenSUSE/SUSE Linux
Est. reading time 2 minutes

What is a Memcached server?

A memcached is nothing but an in-memory object store that web applications can use for caching values to reduce the need to perform expensive computations. In other words, we can reduce the load on the PostgreSQL or MySQL/MariaDB database servers quickly. Of course, you do need Memcached support in PHP or Python too.

Installing memcached on OpenSUSE / SUSE Linux

The procedure to install memcached server is as follows:

  1. First, refresh the repo and install any pending updates:
    zypper ref && zypper up

    Installing updates

  2. Search for the memcached package, run:
    zypper se memcached

    Searching for memcached package

  3. Install memcached server in OpenSUSE or SUSE Linux using the zypper command:
    zypper in memcached

    Click to enlarge

  4. Enable and start the memcached service using the systemctl command:
    systemctl enable memcached.service
    systemctl start memcached.service
    systemctl status memcached.service

    Viewing the service status using the systemctl (click to enlarge)

  5. To configure memcached server edit the config file:
    vim /etc/sysconfig/memcached
  6. Let set a cap of 256 MB (-m) of memory, the default connection port 11211 (-p), and limit the number of simultaneous incoming connections to 4096 (-c) for and (-l ip1,ip2). Update MEMCACHED_PARAMS=”-l″ as follows:
    MEMCACHED_PARAMS="-l, -m 256 -p 11211 -c 4096"
  7. Save and close the file
  8. Restart the memcached service:
    systemctl restart memcached.service
  9. Open TCP/11211 port using the firewall-cmd for LAN CIDR
    firewall-cmd --permanent --zone=public --add-rich-rule 'rule family="ipv4" source address="" port port=11211 protocol=tcp accept'See how to set up a firewall using FirewallD on OpenSUSE Linux for more info.
  10. Install Python extension (python 3 memcached client), run:
    zypper in python3-python-memcached
    # Do you need Python 2 support? Try #
    zypper in python2-python-memcached
  11. Want PHP MemcacheD client extension? Try:
    zypper in php7-memcached
    # Do you have php8 repo enabled? try #
    zypper in php8-memcached
  12. For Perl MemcacheD client extension, try:
    zypper in perl-Cache-Memcached
  13. Make sure you restart the Apache web server, type:
    systemctl restart apache2.service
  14. Are you using PHP-fpm with Nginx/Apache? Then restart PHP-fpm too:
    systemctl restart php-fpm.service

A note about accessing memcahed

You need to use the nc command (netcat) or telnet command. You can install the nc or telnet client as follows:
zypper in netcat
zypper in telnet

Patreon supporters only guides 🤓

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare
  • Join my Patreon to support independent content creators and start reading latest guides:

Join Patreon


The syntax is:

echo 'command' | nc {mem_server_ip_here} {mem_server_port_here}
echo 'command' | nc 11211
## or ##
telnet 11211

For example, let us view the status and stats, run:
echo 'stats' | nc 11211

STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 612
STAT cas_badval 0
STAT touch_hits 396
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 7342632
STAT bytes_written 14366101
STAT limit_maxbytes 268435456
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT time_in_listen_disabled_us 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT slab_reassign_rescues 0
STAT slab_reassign_chunk_rescues 0
STAT slab_reassign_evictions_nomem 0
STAT slab_reassign_inline_reclaim 0
STAT slab_reassign_busy_items 0
STAT slab_reassign_busy_deletes 0
STAT slab_reassign_running 0
STAT slabs_moved 0
STAT lru_crawler_running 0
STAT lru_crawler_starts 29414
STAT lru_maintainer_juggles 6016847
STAT malloc_fails 0
STAT log_worker_dropped 0
STAT log_worker_written 0
STAT log_watcher_skipped 0
STAT log_watcher_sent 0
STAT bytes 833880
STAT curr_items 895
STAT total_items 4365
STAT slab_global_page_pool 0
STAT expired_unfetched 662
STAT evicted_unfetched 0
STAT evicted_active 0
STAT evictions 0
STAT reclaimed 708
STAT crawler_reclaimed 376
STAT crawler_items_checked 44780
STAT lrutail_reflocked 37
STAT moves_to_cold 5650
STAT moves_to_warm 4903
STAT moves_within_lru 4871
STAT direct_reclaims 0
STAT lru_bumps_dropped 0

Use the flush_all. For example:
echo 'flush_all' | nc localhost 11211

Uninstalling and removing Memcached

If you no longer need a Memcached server, uninstall it and all other extensions. For instance:
zypper remove memcached

Reading installed packages...
Resolving package dependencies...
The following package is going to be REMOVED:
1 package to remove.
After the operation, 191.0 KiB will be freed.
Continue? [y/n/v/...? shows all options] (y): y
(1/1) Removing memcached-1.5.6-4.7.1.x86_64 .....................................................................................................................................................................................[done]
Additional rpm output:
Removed /etc/systemd/system/
rm: cannot remove '/var/lib/systemd/migrated/memcached': No such file or directory
There are running programs which still use files and libraries deleted or updated by recent upgrades. They should be restarted to benefit from the latest updates. Run 'zypper ps -s' to list these programs.

And finally extensions too:
zypper remove python3-python-memcached php7-memcached
Remove the firewall rule too:
firewall-cmd --remove-rich-rule 'rule family="ipv4" source address="" port port=11211 protocol=tcp accept' --permanent

Summing up

That is all. I hope this will help someone install and use memcached on OpenSUSE or SUSE Enterprise Linux server to speed up web apps. Do check Memcached documentation. To control memcached sevice use the systemctl command:
systemctl start memcached.service
systemctl stop memcached.service
systemctl restart memcached.service
systemctl status memcached.service
systemctl cat memcached.service

Use the man command to read docs locally:
man memcached


Did you like this article?
Share it on any of the following social media channels below to give us your vote. Your feedback helps us improve.

Other related Technologies ideas you might enjoy

Related Articles

Leave a Reply

Your email address will not be published.