Вы находитесь на странице: 1из 13

7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.

11 - If Not True Then False

(/) search

Install Memcached on Fedora 26/25,


CentOS/RHEL 7.3/6.9/5.11
45 (https://www.if-not-
true-then-
3 false.com/2010/install-

person JR update weeks insert_ memcached-on-


ago centos-fedora-red-
hat/comment-page-
2/#comments)

Memcached is a high-performance, distributed memory object caching system,


generic in nature, but originally intended for use in speeding up dynamic web
applications by alleviating database load. Memcached is a very useful also in
other cases, than only dynamic web applications.

This guide explains howto install Memcached 1.4.15/1.4.17/1.4.36 stable version of distributed
memory object caching system on Fedora 26/25/24/23/22/21/20 and CentOS / Red Hat (RHEL)
7.3/6.9/5.11. Fedora 24/23/22/21/20/19/18/17/16/15/14/13/12, CentOS 7/6 and Red Hat
(RHEL) 7/6 has Memcached on default repos, so extra repositories is not needed.

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 1/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

Braun BT5070 HP DeskJet


Rs. Rs.
4,331.00 9,799.00

1. Install Memcached 1.4.15/1.4.17/1.4.36 on


Fedora 26/25/24/23, CentOS/Red Hat (RHEL)
7.3/6.9/5.11

1.1 Install Remi repository (not needed on Fedora


26/25/24/23/22/21 and CentOS/RHEL 7/6):
Bash

## Remi Dependency on CentOS and Red Hat (RHEL)


rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

1.2 Install Memcached package


Fedora 26/25/24/23

Bash

dnf install memcached

CentOS/Red Hat (RHEL) 7/6.9

Bash

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 2/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

yum install memcached

CentOS/Red Hat (RHEL) 5.11

Bash

yum --enablerepo=remi install memcached

1.3 Con gure memcached


Most important value to con gure is CACHESIZE, which is cache size on Megabytes. Example
Following con guration use 512 Mb memory for Memcached. Edit le
/etc/syscon g/memcached.

Bash

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS=""

1.4 Start Memcached

Fedora 26/25/24/23 and CentOS/RHEL 7.3

Bash

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 3/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

systemctl start memcached.service ## use restart after update

systemctl enable memcached.service

CentOS/RHEL 6.9/5.11

Bash

# Set Memcached to start automatically on boot


chkconfig memcached on
# Start Memcached
/etc/init.d/memcached start
## OR ##
service memcached start

1.5 Check that Memcached is Running and Working


Bash

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 4/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

echo stats | nc localhost 11211


STAT pid 7599
STAT uptime 10
STAT time 1265288542
STAT version 1.4.4
STAT pointer_size 32
STAT rusage_user 0.003999
STAT rusage_system 0.052991
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 6
STAT bytes_written 0
STAT limit_maxbytes 536870912
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
END

# Try to get some value


echo get some_value | nc localhost 11211
END

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 5/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

# Not found, but check the stats again


echo stats | nc localhost 11211
STAT pid 7599
STAT uptime 10
STAT time 1265288542
STAT version 1.4.4
[...]
STAT cmd_get 1
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 1
STAT delete_misses 0
[...]
STAT evictions 0
END

Everything working nice. Then its time to test memcache example with some web application.

2. Open Memcached Port (11211) on Iptables


Firewall (If the Memcached will also be used other
local servers)

2.1 CentOS/Red Hat (RHEL) 6.9/5.11

Edit /etc/syscon g/iptables le:

Bash
nano -w /etc/sysconfig/iptables

Add following INPUT line:

Bash
-A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT

Restart Iptables Firewall:

Bash
https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 6/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

service iptables restart


## OR ##
/etc/init.d/iptables restart

2.2 Fedora 26/25/24/23 and CentOS/Red Hat (RHEL) 7.3

List Your Active Firewalld Zones:

Bash
firewall-cmd --get-active-zones

Example output:

Bash

public
interfaces: wlp1s0

Add New Rule to Firewalld:

You might have active zone like public, FedoraWorkstation, FedoraServer.

Bash
firewall-cmd --permanent --zone=public --add --port=11211/tcp

Restart rewalld.service:

Bash

systemctl restart firewalld.service

2.3 Test remote connection:


Bash
echo stats | nc memcache_host_name_or_ip 11211

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 7/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

3. Install Memcache and/or Memcached PHP


Module on Fedora, CentOS and Red Hat (RHEL)
More information about Memcache Module
(http://www.php.net/manual/en/book.memcache.php).
More information about Memcached Module
(http://www.php.net/manual/en/book.memcached.php).

3.1 Install Memcache Module and PHP


Bash

## Fedora 26/25/24/23 ##
dnf install php php-pecl-memcache

## CentOS/RHEL 7.3/6.9/5.11 ##
yum install php php-pecl-memcache

3.2 Install Memcached Module and PHP


Bash

## Fedora 26/25/24/23 ##
dnf install php php-pecl-memcached

## CentOS/RHEL 7.3/6.9/5.11 ##
yum install php php-pecl-memcached

3.3 Restart Web server


Bash

## Fedora 26/25/24/23 and CentOS/RHEL 7.3 ##


systemctl restart httpd.service

## CentOS/RHEL 6.9/5.11 ##
/etc/init.d/httpd restart
## OR ##
service httpd restart

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 8/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

Categories: Linux (https://www.if-not-true-then-false.com/category/linux/), Servers


(https://www.if-not-true-then-false.com/category/servers/)
Tagged with: Bash (https://www.if-not-true-then-false.com/tag/bash/), CentOS (https://www.if-
not-true-then-false.com/tag/centos/), CentOS 6 (https://www.if-not-true-then-
false.com/tag/centos-6/), CentOS 7 (https://www.if-not-true-then-false.com/tag/centos-7/),
Command line (https://www.if-not-true-then-false.com/tag/command-line/), Fedora
(https://www.if-not-true-then-false.com/tag/fedora/), Linux (https://www.if-not-true-then-
false.com/tag/linux/), Memcache (https://www.if-not-true-then-false.com/tag/memcache/),
Memcached (https://www.if-not-true-then-false.com/tag/memcached/), Red Hat (https://www.if-
not-true-then-false.com/tag/red-hat/), Red Hat 6 (https://www.if-not-true-then-false.com/tag/red-
hat-6/), Red Hat 7 (https://www.if-not-true-then-false.com/tag/red-hat-7/)

Apple iPhone 6s Install Google Chrome Install Apache/PHP LAMP on Fedora


(Silver, 32GB) on Fedora 26/25, 7.1.6 on Fedora 25/24, 23/22, CentOS/Red H
CentOS/RHEL 7.3 CentOS/RHEL 7.3/6.9 (RHEL) 7.2/6.7/5.11

Ad Amazon India if-not-true-then-false.com if-not-true-then-false.com if-not-true-then-false.com

Related Posts

Install Apache/PHP 7.1.7 on Fedora 26/25, CentOS/RHEL 7.3/6.9


navigate_next
(https://www.if-not-true-then-false.com/2010/install-apache-php-on-
fedora-centos-red-hat-rhel/)
Install Oracle Java 8u131 on Fedora 26/25, CentOS/RHEL
navigate_next
7.3/6.9/5.11 (https://www.if-not-true-then-false.com/2014/install-
oracle-java-8-on-fedora-centos-rhel/)
Install Oracle Java 7u79/80 on Fedora 24/23, CentOS/RHEL
navigate_next
7.2/6.8/5.11 (https://www.if-not-true-then-false.com/2010/install-
sun-oracle-java-jdk-jre-7-on-fedora-centos-red-hat-rhel/)
Install WordPress 4.1.1 on Fedora 21/20, CentOS/RHEL 7/6.6/5.11
navigate_next
(https://www.if-not-true-then-false.com/2010/install-wordpress-on-
fedora-centos-red-hat-rhel/)
Install Apache OpenO ce 4.1.2 on Fedora 24/23, CentOS/RHEL
navigate_next
7.2/6.8 (https://www.if-not-true-then-false.com/2010/install-
https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 9/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

navigate_next
7.2/6.8 (https://www.if-not-true-then-false.com/2010/install-
openo ce-org-on-fedora-centos-red-hat-rhel/)

41,499 6,999 1,090

4,940 799 7,999


Amazon India

45 Comments

arrow_back READ COMMENTS (45) (HTTPS://WWW.IF-NOT-

Leave a Comment

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

Comment *

help
https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 10/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

Name *

Email *

Website

POST COMMENT
send

(//srv.buysellads.com/ads/click/x/GTND42QECTAIK5QJCKSLYKQMCTYDL2JECESILZ

(//srv.buysellads.com/ads/click/x/GTND42QECTAIK5QJCYBLYKQMCTYDLK7ECYBDLZ3JCWYDT5QECYAI6KJKC6BITK37CYSDTK3EHJNCLSIZ

(//srv.buysellads.com/ads/click/x/GTND42QECTAIK5QJCYSLYKQMCTYDLK3NCVSICZ3JCWYDT5QYCA7I553

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 11/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

(//srv.buysellads.com/ads/click/x/GTND42QECTAIK5QJCYSLYKQMCTYDLKQECAAIPZ3JCWYDT53ICA7I4K7

(//srv.buysellads.com/ads/click/x/GTND42QECTAIK5QJCYSLYKQMCTYDLK7NFT7DKZ3JCWYDT5QJCTSDE2

Advertise Here

Most Popular Posts

Last Updated Posts

Recent Posts

Recent Comments

ADVERTISE (HTTPS://WWW.IF-NOT-TRUE-THEN-FALSE.COM/ADVERTISE/)
CONTACT (HTTPS://WWW.IF-NOT-TRUE-THEN-FALSE.COM/CONTACT/)
TERMS OF SERVICE / DISCLAIMER (HTTPS://WWW.IF-NOT-TRUE-THEN-FALSE.COM/TERMS-OF-SERVICE-
DISCLAIMER/)
PRIVACY POLICY (HTTPS://WWW.IF-NOT-TRUE-THEN-FALSE.COM/PRIVACY-POLICY/)

Copyright 2017 If Not True Then False (/)

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 12/13
7/25/2017 Install Memcached on Fedora 26/25, CentOS/RHEL 7.3/6.9/5.11 - If Not True Then False

https://www.if-not-true-then-false.com/2010/install-memcached-on-centos-fedora-red-hat/ 13/13

Вам также может понравиться