Debian8 (amd64) install and deploy Memcached management tool MemAdmin

Source: Internet
Author: User
Tags sapi

Debian8 (amd64) install and deploy Memcached management tool MemAdmin

Directory
1. Introduction to memadmin tools
2. Install nginx and php Environments
3. memadmin tool deployment
4. simple use of memadmin tools
5. Additional configuration optimization
6. Summary

1. Introduction to memadmin tools
MemAdmin is a visualized Memcached management and monitoring tool. It is developed using PHP and is small in size and easy to operate.
Main functions:
Server parameter monitoring: Real-Time refresh of STATS, SETTINGS, ITEMS, SLABS, and SIZES
Server performance monitoring: real-time monitoring of hit rates of common operations such as GET, DELETE, INCR, DECR, and CAS
Supports data traversal to facilitate monitoring of stored content
Supports conditional queries to filter out keys or values that meet the conditions.
Array, JSON, and other Serialized character deserialization display
Other services compatible with the memcache protocol, such as Tokyo Tyrant (excluding traversal)
Supports server connection pools, facilitating and simplifying multi-server management Switching

2. Install nginx and php Environments

2.1 install nginx
1234567 root @ com :~ # Uname-r
3.16.0-4-amd64
Root @ com :~ # Cat/etc/issue
Debian GNU/Linux 8 \ n \ l
Root @ test1 :~ # Apt-get install nginx
Root @ test1 :~ # Chkconfig -- list nginx
Nginx 0: off 1: off 2: on 3: on 4: on 5: on 6: off

The default nginx page is visible in the browser, as shown below:

2.2 php environment deployment
Root @ test1 :~ # Apt-get install php5-fpm
Root @ test1 :~ # Dpkg-L php5-fpm
/.
/Etc
/Etc/php5
/Etc/php5/fpm
/Etc/php5/fpm/conf. d
/Etc/php5/fpm/pool. d
/Etc/php5/fpm/pool. d/www. conf # This is the configuration file of the php5-fpm
/Etc/php5/fpm/php-fpm.conf
/Etc/logrotate. d
/Etc/logrotate. d/php5-fpm
/Etc/init
/Etc/init/php5-fpm.conf
/Etc/init. d
/Etc/init. d/php5-fpm
/Usr
/Usr/sbin
/Usr/sbin/php5-fpm
/Usr/lib
/Usr/lib/php5
/Usr/lib/php5/20131226
/Usr/lib/php5/php5-fpm-checkconf
/Usr/lib/php5/php5-fpm-reopenlogs
/Usr/share
/Usr/share/man
/Usr/share/man/man8
/Usr/share/man/man8/php5-fpm.8.gz
/Usr/share/lintian
/Usr/share/lintian/overrides
/Usr/share/lintian/overrides/php5-fpm
/Usr/share/php5
/Usr/share/php5/sapi
/Usr/share/php5/sapi/fpm
/Usr/share/bug
/Usr/share/bug/php5-fpm
/Usr/share/bug/php5-fpm/script
/Usr/share/bug/php5-fpm/control
/Usr/share/doc
/Lib
/Lib/systemd
/Lib/systemd/system
/Lib/systemd/system/php5-fpm.service
/Usr/share/doc/php5-fpm

Root @ test1 :~ # Vim/etc/php5/fpm/pool. d/www. conf
# Listen =/var/run/php5-fpm.sock comment this line, which is not mandatory, but I'm used to making the php5-fpm listen on a port instead of sock
Listen = 9000 added this exercise php5-fpm listening on port 9000
Root @ test1 :~ #/Etc/init. d/php5-fpm restart
[OK] Restarting php5-fpm (via systemctl): php5-fpm.service.
Root @ test1 :~ # Ss-ntnl | grep 9000
LISTEN 0 128 *: 9000 *:*

Root @ test1 :~ # Vim/etc/nginx/sites-enabled/default
# Modify nginx configuration so that it can forward php requests to the php5-fpm, in the "# location ~ Add the following code below the \. php $ {"code block:
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/var/www/html $ fastcgi_script_name;
Include fastcgi_params;
}
Nginx: the configuration file/etc/nginx. conf syntax is OK
Nginx: configuration file/etc/nginx. conf test is successful
Root @ test1 :~ # Vim/var/www/html/info. php
<? Php
Phpinfo ();
?>
Root @ test1 :~ # Nginx-t
Root @ test1 :~ #/Etc/init. d/nginx restart
[OK] Restarting nginx (via systemctl): nginx. service.

Open the php test interview in the browser as follows:

3. memadmin tool deployment and simple application

123456 root @ test1 :~ # Ls
Memadmin-1.0.12.tar.gz
Root @ test1 :~ # Tar memadmin-1.0.12.tar.gz-C/var/www/html/
Root @ test1 :~ # Cd/var/www/html/
Root @ test1:/var/www/html # ls
Index.nginx-debian.html info. php memadmin

Access memadmin for testing as follows:

An error is reported. Follow the prompts to install memcache extension support:
Root @ test1:/var/www/html # apt-get install php5-memcache
Root @ test1:/var/www/html # dpkg-L php5-memcache
/.
/Usr
/Usr/lib
/Usr/lib/php5
/Usr/lib/php5/20131226
/Usr/lib/php5/20131226/memcache. so # The library file is here
/Usr/share
/Usr/share/doc
/Usr/share/doc/php5-memcache
/Usr/share/doc/php5-memcache/examples
/Usr/share/doc/php5-memcache/examples/memcache.php.gz
/Usr/share/doc/php5-memcache/examples/example. php
/Usr/share/doc/php5-memcache/changelog.Debian.gz
/Usr/share/doc/php5-memcache/copyright
/Usr/share/doc/php5-memcache/memcache.php.gz
/Usr/share/doc/php5-memcache/changelog.gz
/Usr/share/doc/php5-memcache/package.xml.gz
/Usr/share/doc/php5-memcache/README.gz
/Usr/share/doc/php5-memcache/CREDITS
/Usr/share/doc/php5-memcache/example. php
/Usr/share/php
/Usr/share/php/. registry
/Usr/share/php/. registry/.channel.pecl.php.net
/Usr/share/php/. registry/.channel.pecl.php.net/memcache.reg
/Etc
/Etc/php5
/Etc/php5/mod-available
/Etc/php5/mod-available/memcache. ini

Root @ test1:/var/www/html # vim/etc/php5/fpm/php. ini
# Search for the "extension" keyword and add the following code under "; extension_dir =" ext"
Extension_dir = "/usr/lib/PHP 5/20131226"
Extension = memcache. so
Root @ test1:/var/www/html #/etc/init. d/php5-fpm restart
[OK] Restarting php5-fpm (via systemctl): php5-fpm.service.

Visit the test page again, as shown in the following figure. Information about memcache is displayed:

Visit the memadmin page again, as shown below:

Now, the memadmin tool has been deployed.
4. simple use of memadmin tools

By default, the logon username and password of the memadmin tool are admin, which can be changed in the configuration file as follows:
Root @ test1:/var/www/html # pwd
/Var/www/html
Root @ test1:/var/www/html # vim memadmin/config. php
<? Php
If (! Defined ('in _ madm') exit ();
$ Config ['user'] = "admin"; // your username
$ Config ['passwd'] = "admin"; // your password
.........

After logging on to memadmin, the following page is displayed:

After you click "add", memcached will be added to the "server connection list", as shown below:

Click "start management" to view the monitoring information of the memcached server, for example:

Next, let's explore how to use this tool!
5. Additional configuration optimization

Now we can use the memadmin tool as much as possible, but the main function of this server is to provide the memcached service, while memadmin is just a management tool for memcached, use Frequency is not particularly high, so, allocated to nginx, php5-fpm resources only need a little, especially when your server resources are very tight, you should optimize the nginx and php5-fpm services.
5.1 nginx Optimization
Let's take a look at the working features of nginx by default, as shown below:
Root @ test1 :~ # Pgrep nginx
11748
11750
11751
11752
11753
Root @ test1 :~ # Ps aux | grep nginx
Root 11748 0.0 0.3 91172 3064? Ss nginx: master process/usr/sbin/nginx-g daemon on; master_process on;
Www-data 11750 0.0 0.4 91816 4776? S nginx: worker process
Www-data 11751 0.0 0.4 91828 5028? S nginx: worker process
Www-data 11752 0.0 0.3 91476 3752? S nginx: worker process
Www-data 11753 0.0 0.3 91476 3752? S nginx: worker process
Root 12909 0.0 0.2 12948 2196 pts/1 S + grep nginx
# By default, nginx has one master process and four worker processes.

1234 root @ test1 :~ # Ss-tnl | grep 80
LISTEN 0 128 *: 80 *:*
LISTEN 0 128: 80 :::*
# Nginx listens to IPV6 addresses by default.

For my environment, nginx only needs to start a worker process, and listening to IPV6 addresses is not necessary, so make the following changes:
Root @ test1 :~ # Find/etc/nginx/*-type f | xargs grep "worker_processes"
/Etc/nginx. conf: worker_processes 4;
Root @ test1 :~ # Vim/etc/nginx. conf
Worker_processes 1; # change to "1"
Root @ test1 :~ # Find/etc/nginx/*-type f | xargs grep "listen 80"
/Etc/nginx/sites-available/default: listen 80 default_server;
/Etc/nginx/sites-available/default: # listen 80;
Root @ test1 :~ # Vim/etc/nginx/sites-available/default
.....
Server {
Listen 80 default_server;
# Listen [:]: 80 default_server; # comment this row
Root @ test1 :~ # Nginx-t
Nginx: the configuration file/etc/nginx. conf syntax is OK
Nginx: configuration file/etc/nginx. conf test is successful
Root @ test1 :~ #/Etc/init. d/nginx reload
[OK] Reloading nginx configuration (via systemctl): nginx. service.
The optimized result is as follows:
Root @ test1 :~ # Ps aux | grep nginx
Root 11748 0.0 0.4 91280 5000? Ss nginx: master process/usr/sbin/nginx-g daemon on; master_process on;
Www-data 13031 0.0 0.3 91600 3808? S nginx: worker process
Root 13052 0.0 0.2 12948 2064 pts/1 S + grep nginx
Root @ test1 :~ # Ss-tnl | grep 80
LISTEN 0 128 *: 80 *:*

5.2 php Optimization

Here for php optimization, we can control the number of php5-fpm working process to save resources, at the beginning of the "/etc/php5/fpm/php-fpm.conf" file is found for a long time did not find the relevant configuration options, and finally found the relevant configuration file using the powerful find command.
Let's take a look at the number of php startup processes by default:
Root @ test1 :~ # Ps aux | grep php
Root 11946 0.0 1.3 93540 13996? Ss php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
Www-data 11949 0.0 1.0 94124 10720? S php-fpm: pool www
Www-data 11950 0.0 1.1 93980 12088? S php-fpm: pool www
Root 13124 0.0 0.2 12948 2204 pts/1 S + grep php

By default, two working processes are also enabled in php. You only need one of them to perform the following operations:

Root @ test1 :~ # Find/etc/php5/*-type f | xargs grep "max_children" # search for files with the keyword "max_children"
/Etc/php5/fpm/pool. d/www. conf:; static-a fixed number (pm. max_children) of child processes;
/Etc/php5/fpm/pool. d/www. conf:; pm. max_children-the maximum number of children that can
/Etc/php5/fpm/pool. d/www. conf:; pm. max_children-the maximum number of children that
/Etc/php5/fpm/pool. d/www. conf: pm. max_children = 5

There are several optimization parameters for Php:
Pm, pm. max_children, pm. start_servers, pm. min_spare_servers, pm. max_spare_servers
Pm = dynamic # for dedicated servers, pm can be set to static.
# The options for controlling sub-processes include static and dynamic. If static is selected, a fixed number of sub-processes is specified by pm. max_children. If dynamic is selected, it is determined by the following parameters:
Pm. max_children #, maximum number of child Processes
Pm. start_servers #, number of processes at startup
Pm. min_spare_servers # ensures the minimum number of idle processes. If the number of idle processes is smaller than this value, a new sub-process is created.
Pm. max_spare_servers #. ensure the maximum number of idle processes. If the number of idle processes exceeds this value, clean it.

Here, the values I set are as follows:
Root @ test1 :~ # Vim/etc/php5/fpm/pool. d/www. conf
.....
Pm = static # change the pm value to static. The default value is dynamic.
Pm. max_children = 1 # change the value of pm. max_clil.pdf to "1". The default value is "5"
Root @ test1 :~ #/Etc/init. d/php5-fpm restart
[OK] Restarting php5-fpm (via systemctl): php5-fpm.service.
Root @ test1 :~ # Ps aux | grep php-fpm
Root 13235 0.0 1.3 93524 14016? Ss php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
Www-data 13238 0.0 0.6 93524 6428? S pm php-fpm: pool www
Root 13258 0.0 0.1 12944 1984 pts/1 S + grep php-fpm
# Now there is only one php-fpm workflow.

Observe that a nginx worker Process occupies about 4 MB of memory, and a php-fpm occupies about MB of memory, after optimization, the memory size can be reduced to 4 MB * 4 + 6.5 = MB.

6. Summary

Now the company's system environment is slowly migrating from CentOS to Debian. For me who have never been in touch with the Debian system, we also need an adaptation process, we found that Debian and Centos are still quite different in usage. This time we encountered some problems when building the php environment.

MemAdmin Chinese interface, the operation is very simple, but I found several problems in use, for example: Only data can be written, not data can be read, The refreshing interval of status monitoring is not effective, etc.

There is also a simple memcached status monitoring tool, also good, called memcachephp-master, which can be used to obtain the VALUE corresponding to the KEY, just to make up for my lack of MemAdmin can not get the VALUE here. This tool is also easy to deploy and will not be demonstrated here.

The related attachments are downloaded from the help home Resource Station.

------------------------------------------ Split line ------------------------------------------

Free in http://linux.bkjia.com/

The username and password are both www.bkjia.com

The specific download directory is/July 6, 2016,/July 25, January,/Debian8 (amd64). Install and deploy Memcached management tool MemAdmin/

For the download method, see

------------------------------------------ Split line ------------------------------------------

Install and configure Memcached source code in CentOS 6.6

Memcached installation and startup script

Performance problems of using Memcached in PHP

Install Memcached in Ubuntu and its command explanation

Install and apply Memcached

Use Nginx + Memcached's small image storage solution

Getting started with Memcached

For details about Memcached, click here
Memcached: click here

This article permanently updates the link address:

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.