In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Brief introduction to Memcached:
(1) introduction:
Memcached is a high-performance distributed in-memory object caching system, which is used for dynamic Web applications to reduce database load. It reduces the number of times to read the database by caching data and objects in memory, thus improving the speed of dynamic, database-driven websites. 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) characteristics:
As a high-speed distributed cache server, memcached has the following characteristics:
1. The protocol is simple
2. Event handling based on libevent
3. Built-in memory storage mode
4. Distributed memcached that does not communicate with each other.
(3) Storage method:
To improve performance, the data saved in memcached is stored in memcached's built-in memory storage space. Because the data exists only in memory, restarting memcached and restarting the operating system will cause all data to disappear. In addition, when the content capacity reaches the specified value, the unused cache is automatically deleted based on the LRU (Least Recently Used) algorithm. Memcached itself is a server designed for caching, so it doesn't think too much about the persistence of the data.
II. Case deployment:
Prepare two virtual machines for the centos7 system, one for the Memcached server and the other for the Memcache client with the LAMP architecture.
Step 1: deploy the Memcached server
(1) install dependent environment package: yum install gcc gcc-c++ make-y (2) decompress package: tar zxvf libevent-2.1.8-stable.tar.gz-C / opt/tar zxvf memcached-1.5.6.tar.gz-C / opt/ (3) compile and install libevent: cd / opt/libevent-2.1.8-stable./configure-- prefix=/usr/local/libeventmake & & make install (4) compile and install memcached: cd / opt/memcached- 1.5.6/./configure\-prefix=/usr/local/memcached\-with-libevent=/usr/local/libevent/make & & make install (5) easy to create a soft link: ln-s / usr/local/memcached/bin/* / usr/local/bin (6) enable memcached service: memcached-d-m 32m-p 11211-u daemon / /-d daemon -m cache size 32m;-p port 11211 (7) to check whether the port is developed properly: netstat-natp | grep memcached
Step 2: client-side deployment of LAMP architecture
(1) LAMP architecture has been described in detail in the blog before: deploy LAMP architecture.
(2) the following is to test whether the LAMP architecture is working properly:
1. Test whether the database is working properly:
Mysql-u root-p / / enter the database CREATE DATABASE sky; / / create a database as skyGRANT all ON sky.* TO 'skyuser'@'%' IDENTIFIED BY' admin123'; / / flush privileges; / / refresh the database
2. Modify the home page of PHP:
Vim / usr/local/httpd/htdocs/index.php
3. Browser access test: http://192.168.220.131/index.php shows that Success is normal.
Step 3: install the Memcache client
(1) install dependency package: yum install autoconf-y (2) extract: tar zvxf memcache-2.2.7.tgz-C / opt/ (3) compile (generate configuration script configure using PHP's phpize script Then configure and compile): cd / opt/memcache-2.2.7/usr/local/php5/bin/phpize. / configure\-- enable-memcache\-- with-php-config=/usr/local/php5/bin/php-config (4) installation: make & & make install (5) after installation, a line will appear, which is the location of the shared file, which will be used later: / usr/local/php5/lib/php/extensions/no-debug-zts-20131226/
Step 4: configure PHP-add Memcached components
Vim / usr/local/php5/php.ini / / search and modify the following line, adding a new line extension_dir = "/ usr/local/php5/lib/php/extensions/no-debug-zts-20131226/" extension = memcache.so
Step 5: the client detects whether the server can connect properly
(1) write the test home page to check whether the memcached is working properly.
Vim / usr/local/httpd/htdocs/index.php
(2) service httpd restart restarts Apache service
(3) browser web page visit: http://192.168.220.131/index.php
3. Operation and management of Memcached database:
(1) the database can be operated and managed by using telnet to connect the host IP address and port 11211.
Yum install telnet-ytelnet 127.0.0.1 11211 / / connect locally with 127.0.0.1, and connect to other hosts using the corresponding IP address.
(2) create new data:
Add username 0 07 / / add data (two zeros indicate that the data will never expire without compression and serialization identification; if the identification number is 7, you need to enter 7 digits. ) allways / / enter a 7-digit number
(2) query data:
Get username / / query data gets username
(3) update the data:
Set username 0 010 / / update information. If the key name does not exist, add the everythingreplace username 0 08 / / update information by yourself. If the key name does not exist, error 12345678 will be reported.
(4) detect / view updated data:
Gets username / / detect updates VALUE username 0 8 412345678
(5) additional data:
Append username 0 07 / / append data exampleprepend username 0 02 / / append data un before key value
(6) clear the data:
Delete username / / clear specified key data flush_all / / clear all cached data OK
(7) View server statistics:
Stats / / display status information stats items / / return statistics of all key-value pairs stats cachedump 1 / return key-value pairs of specified storage space stats slabs / / display information of each slab stats sizes / / output the size and number of all item stats reset / / clear statistics
(8) exit:
Quit
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.