Cache server memcache-personal offline test use

Source: Internet
Author: User
Tags fpm memcached

1. Introduction:
Memcached is a high-performance distributed memory object caching system for dynamic Web applications to mitigate database load. It improves the speed of dynamic, database-driven Web sites by caching data and objects in memory to reduce the number of times a database is read. Memcached is based on a hashmap that stores key/value pairs. Its daemon (daemon) is written in C, but the client can write in any language and communicate with the daemon through the Memcached protocol

2. Why use?

MySQL: The database on disk, read and write speed is relatively slow
Memcached: In-memory database, read and write speed is relatively fast, the disadvantage is that data is easy to lose.

Data storage, Data Warehouse Select MySQL this disk database.
In the case of high concurrency, it is recommended to select the Memcached database when the business is relatively large

At work, MySQL and memcached are used together
3.Memcached application scenarios in the Enterprise

As a front-end cache application for the database, reduce the pressure on the database to be heavily accessed by high concurrency

Advantages:
Ⅰ. For users, user access to the site is faster, query data directly from the Memcached database directly to the data transfer information
Ⅱ. For Web sites, the database reduces stress and requests the MySQL database only if the memory has no data.
Ⅲ. Improves the efficiency of website concurrent access and reduces the number of servers

4. Environmental preparedness

centos6.9 web1 IP 10.0.0.7 to open Word Press
centos7.2 memcached IP 10.0.0.21

5. Installing memcached

centos7.2 Host Installation:

Yum-y Install memcached

Systemctl Start Memcached.service

Test:

Create:
[[email protected] ~]# printf "set key008 0 0 10\r\noldboy0987\r\n" |nc 10.0.0.21 11211
STORED

View:
[[email protected] ~]# printf "Get key008\r\n" |nc 10.0.0.21 11211
VALUE key008 0 10
oldboy0987
END

Delete:
[[email protected] ~]# printf "Delete key008\r\n" |nc 10.0.0.21 11211
DELETED

7.WEB01 operation

Uploading packages

Tar zxvf memcache-2.2.5.tgz
CD memcache-2.2.5
/application/php/bin/phpize
./configure--enable-memcache--with-php-config=/application/php/bin/php-config--with-zlib-dir
Make
Make install

After successful execution:

Sed-i ' $a extension=memcache.so '/application/php/lib/php.ini
Pkill PHP
/application/php/sbin/php-fpm-t
/application/php/sbin/php-fpm
/application/php/bin/php-m|grep Memcache

After successful execution:

7.PHP Code Testing

Cat >>/application/nginx/html/blog/mc.php<< ' EOF '
<?php
$memcache = new Memcache;
$memcache->connect (' 10.0.0.21 ', 11211) or Die ("Could not Connect");
$memcache->set (' key20180314 ', ' Hello,world ');
$get _value = $memcache->get (' key20180314 ');
echo $get _value;
?>
Eof

8.WEB Management memcached

Tar XF memadmin-1.0.12.tar.gz-c/application/nginx/html/blog/
Browser Access Http://blog.etiantian.org/memadmin



!
cd/application/nginx/html/blog/wp-content/
Rz
grep 127.0.0.1 object-cache.php
Sed-i ' s#127.0.0.1#10.0.0.21# ' object-cache.php

Web uses word press to upload a blog post using memcached to view the cache

Cache server memcache-personal offline test use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.