Memcached是免费、开源(BSD license授权)、高性能分布式的对象内存缓存系统,当初是Danga Interactive为了LiveJournal所发展的,但目前被许多软件(如MediaWiki)所使用。Memcached被广泛用于动态数据的缓存,可大大减低数据库负载与压力,提高数据库系统的性
Memcached是免费、开源(BSD license授权)、高性能分布式的对象内存缓存系统,当初是Danga Interactive为了LiveJournal所发展的,但目前被许多软件(如MediaWiki)所使用。Memcached被广泛用于动态数据的缓存,可大大减低数据库负载与压力,提高数据库系统的性能与容量,从而极大地增加动态网页的效率与网速。
Memcached缺乏认证以及安全管制,这代表应该将Memcached服务器放置在防火墙后。
Memcached具有多种语言的客户端开发包,包括:Perl/PHP/JAVA/C/Python/Ruby/C#/MySQL/
一、安装Memcached
A、通过源码编译安装
编译前,请先确认gcc、make、patch等编译工具是否已安装,并可正常使用。
安装Libevent
Libevent是一个异步事件处理软件函式库,以BSD许可证释出。Memcached依赖Libevent,因此必须先编译安装Libevent。
wget http://www.monkey.org/~provos/libevent-2.0.13-stable.tar.gz tar xzvf libevent-2.0.13-stable.tar.gz ./configure make make install
安装Memcached
wget http://memcached.googlecode.com/files/memcached-1.4.7.tar.gz tar xvzf memcached-1.4.7.tar.gz cd memcached-1.4.7 ./configure --prefix=/usr/local/memcached/ make make install
创建软链
ln -s /usr/local/lib/libevent-2.0.so.5 /lib/libevent-2.0.so.5
注:如果你不创建这个软链,启动memcached是可能会报./memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory这样的错误。这是因为memcached无法定位libevent库,libevent默认安装目录是/usr/local/lib/libevent-2.0.so.5,所以这里创建软链解决这个问题。
另:我在编译时用–with-libevent参数指定了libevent的位置,启动依然有这个问题。
启动memcache
./memcached -d -m 64 -p 11211 -l 127.0.0.1 -u nobody -c 1024
memcached常用启动参数描述:
-d:启动一个守护进程, -m:分配给Memcache使用的内存数量,单位是MB,默认是64MB, -u:运行Memcache的用户 -l:监听的服务器IP地址 -p:设置Memcache监听的端口,默认是11211注:-p(p为小写) -c:设置最大并发连接数,默认是1024 -P:设置保存Memcache的pid文件注:-P(P为大写) -h 显示帮助
B、通过APT包安装
apt-get install memcached
二、安装Memcache管理器
A、环境准备
安装Memcache客户端
方法一、通过APT安装
apt-get install php5-memcache
方法二、通过pecl安装
pecl install memcache
重启Apache
/etc/init.d/apache2 restart
B、安装MemAdmin
MemAdmin是一款可视化的Memcached管理与监控工具,使用PHP开发,体积小,操作简单。
主要功能:服务器参数监控:STATS、SETTINGS、ITEMS、SLABS、SIZES实时刷新。服务器性能监控:GET、DELETE、INCR、DECR、CAS等常用操作命中率实时监控。支持数据遍历,方便对存储内容进行监视。支持条件查询,筛选出满足条件的KEY或VALUE。数组、JSON等序列化字符反序列显示。 兼容memcache协议的其他服务,如Tokyo Tyrant (遍历功能除外)。支持服务器连接池,多服务器管理切换方便简洁。
安装
wget http://www.junopen.com/memadmin/memadmin-1.0.5.tar.gz tar xvzf memadmin-1.0.5.tar.gz cp -r memadmin /var/www/
配置访问用户
vi memadmin/config.php #根据自己情况修改用户名和密码 $config['user'] = "admin"; // your username $config['passwd'] = "admin"; // your password
访问https://域名(或IP)/memadmin/index.php,输入用户名/密码访问即可。
C、安装Memcachepphp
Memcachepphp也是一个WEB管理工具,这个程序只有一个文件,部署相当简单。Memcachepphp功能有:管理多个memcache服务器、实时查看各个服务器的内存使用状况、实时查看缓存命中情况、直接浏览缓存内容,删除指定缓存项等。
安装
wget http://livebookmark.net/memcachephp/memcachephp.zip unzip memcachephp.zip cp memcache.php /var/www/
配置Memcachepphp
根据自己的情况修改用户名密码和memcache服务器地址
vi memcache.php define(‘ADMIN_USERNAME’,'memcache’); // Admin Username define(‘ADMIN_PASSWORD’,'password’); // Admin Password define(‘DATE_FORMAT’,'Y/m/d H:i:s’); define(‘GRAPH_SIZE’,200); define(‘MAX_ITEM_DUMP’,50); $MEMCACHE_SERVERS[] = ‘localhost:11211′; // add more as an array //$MEMCACHE_SERVERS[] = ‘mymemcache-server2:11211′; // add more as an array
访问https://域名(或IP)/memadmin/index.php,输入用户名/密码访问即可。
原文地址:Ubuntu下安装Memcached, 感谢原作者分享。

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
