In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Operating system: CentOS release 6.8 (Final)
Virtual machine: VM
Task: the service and client are installed and configured in a virtual machine master.
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 service installation
[root@localhost ~] # yum install libevent libevent-devel nc-y
[root@localhost ~] # rpm-qa libevent libevent-devel nc
Libevent-1.4.13-4.el6.x86_64
Libevent-devel-1.4.13-4.el6.x86_64
Nc-1.84-24.el6.x86_64
# you can install or compile through yum. The version of yum installation is relatively low. You can download and install the latest version of http://memcached.org/downloads or http://pecl.php.net/package/memcached from the official website.
[root@localhost ~] # yum install memcached-y
[root@localhost ~] # which memcached
/ usr/bin/memcached
[root@localhost ~] # memcached-m 16m-p 11211-d-u root-c 8192 # launch the first instance
[root@localhost ~] # lsof-iRanger 11211 # check the startup status
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Memcached 1857 root 26u IPv4 14225 0t0 TCP *: memcache (LISTEN)
Memcached 1857 root 27u IPv6 14226 0t0 TCP *: memcache (LISTEN)
Memcached 1857 root 28u IPv4 14229 0t0 UDP *: memcache
Memcached 1857 root 29u IPv6 14230 0t0 UDP *: memcache
[root@localhost ~] # ps-ef | grep memcached | grep-v grep # View the process
Root 1857 10 19:14? 00:00:00 memcached-m 16m-p 11211-d-u root-c 8192
[root@localhost ~] # memcached-m 16m-p 11212-d-u root-c 8192 # launch the second instance
[root@localhost ~] # ps-ef | grep memcached | grep-v grep
Root 1857 10 19:14? 00:00:00 memcached-m 16m-p 11211-d-u root-c 8192
Root 1868 10 19:15? 00:00:00 memcached-m 16m-p 11212-d-u root-c 8192
[root@localhost] # lsof-I: 11211
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Memcached 1737 root 26u IPv4 12689 0t0 TCP *: memcache (LISTEN)
Memcached 1737 root 27u IPv6 12690 0t0 TCP *: memcache (LISTEN)
Memcached 1737 root 28u IPv4 12693 0t0 UDP *: memcache
Memcached 1737 root 29u IPv6 12694 0t0 UDP *: memcache
[root@localhost] # lsof-I: 11212
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Memcached 1739 root 26u IPv4 12698 0t0 TCP *: 11212 (LISTEN)
Memcached 1739 root 27u IPv6 12699 0t0 TCP *: 11212 (LISTEN)
Memcached 1739 root 28u IPv4 12702 0t0 UDP *: 11212
Memcached 1739 root 29u IPv6 12703 0t0 UDP *: 11212
[root@localhost] # tail-2 / etc/rc.local
[root@localhost ~] # vi / etc/rc.local # can start two instances automatically
#! / bin/sh
#
# This script will be executed * after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
Touch / var/lock/subsys/local
Memcached-m 16m-p 11211-d-u root-c 8192
Memcached-m 16m-p 11212-d-u root-c 8192
Memcached parameter description:
The-d option is to start a daemon
-m is the amount of memory allocated to Memcache in MB, and this is 16MB.
-u is the user running Memcache. This is root.
-l is the IP address of the server that is listening
-p is the port on which Memcache snooping is set, preferably above 1024
The-c option is the maximum number of concurrent connections running. The default is 1024, which is set according to the load of your server.
-P is the pid file that is set to save Memcache
Other parameters are omitted.
[root@localhost ~] # chkconfig-- level 2345 memcached on # boot service
# write data to memcached
[root@localhost ~] # printf "set key1 0 06\ r\ n skyboy\ r\ n" | nc 127.0.0.1 11211
CLIENT_ERROR bad data chunk
ERROR
[root@localhost ~] # printf "set key1 0 06\ r\ nskyboy\ r\ n" | nc 127.0.0.1 11211
STORED
[root@localhost ~] # printf "set key2 0 05\ r\ nskyboy\ r\ n" | nc 127.0.0.1 11211
CLIENT_ERROR bad data chunk
ERROR
[root@localhost ~] # printf "get key1\ r\ n" | nc 127.0.0.1 11211
VALUE key1 0 6
Skyboy
END
[root@localhost ~] # printf "delete key1\ r\ n" | nc 127.0.0.1 11211
DELETED
[root@localhost ~] # printf "get key1\ r\ n" | nc 127.0.0.1 11211
END
Write data through the telnet command
Connection closed by foreign host.
[root@localhost ~] # telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is'^]'.
Set user01 0 0 7
Oldgirl
STORED
Get user01
VALUE user01 0 7
Oldgirl
END
Delete user01
DELETED
Get user01
END
Quit
Connection closed by foreign host.
Install the Memcached client
Http://pecl.php.net/package/memcache # download all version addresses
[root@localhost tools] # wget http://pecl.php.net/get/memcache-2.2.4.tgz
[root@localhost tools] # tar zxf memcache-2.2.4.tgz
[root@localhost tools] # cd memcache-2.2.4
[root@localhost memcache-2.2.4] #
# phpize is used to extend the PHP expansion module, and the plug-in module of PHP can be built through phpize.
[root@localhost memcache-2.2.4] # / application/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
[root@localhost memcache-2.2.4] #. / configure-- enable-memcache\
-- with-php-config=/application/php/bin/php-config
[root@localhost memcache-2.2.4] # make
[root@localhost memcache-2.2.4] # make install
Installing shared extensions: / application/php5.3.27/lib/php/extensions/no-debug-non-zts-20090626/
[root@localhost memcache-2.2.4] # ls / application/php/lib/php/extensions/no-debug-non-zts-20090626/
Memcache.so # generated the .so module
[root@localhost memcache-2.2.4] # cd / application/php/lib/
[root@localhost lib] # vi php.ini # add the following two lines at the end
Extension_dir= "/ application/php/lib/php/extensions/no-debug-non-zts-20090626/"
Extension=memcache.so
[root@localhost lib] # / application/php/sbin/php-fpm-t # check syntax
[19-Jan-2017 19:50:52] NOTICE: configuration file / application/php5.3.27/etc/php-fpm.conf test is successful
[root@localhost lib] # / application/php/sbin/php-fpm # start the service
[root@localhost lib] # ps-ef | grep php-fpm | grep-v grep
Root 4624 1 0 19:51? 00:00:00 php-fpm: master process (/ application/php5.3.27/etc/php-fpm.conf)
Nginx 4625 4624 0 19:51? 00:00:00 php-fpm: pool www
Nginx 4626 4624 0 19:51? 00:00:00 php-fpm: pool www
Restart fpm
[root@localhost ~] # pkill php-fpm
[root@localhost ~] # ps-ef | grep php-fpm | grep-v grep
[root@localhost ~] # / application/php/sbin/php-fpm
[root@localhost ~] # ps-ef | grep php-fpm | grep-v grep
Root 2186 1 0 23:39? 00:00:00 php-fpm: master process (/ application/php5.3.27/etc/php-fpm.conf)
Nginx 2187 2186 0 23:39? 00:00:00 php-fpm: pool www
Nginx 2188 2186 0 23:39? 00:00:00 php-fpm: pool www
Test whether the Memcached client installation is successful? Http://192.168.222.130/phpinfo.php
The Phpinfo.php file is as follows:
Test whether the LNMP environment connects to the Memcached service successfully?
[root@localhost www] # vi op_mem.php
[root@localhost www] # / application/php/bin/php op_mem.php
Learning Memcached
Or browsers visit: http://192.168.222.130/op_mem.php
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.