centos源码安装多线程memcached multi-threaded

本文档介绍了如何在CentOS系统上源码安装支持多线程的Memcached。默认的Memcached仅使用单线程,但通过重新编译并启用特定选项,可以使其支持多线程。在编译过程中需要libevent库,并且注意配置选项,如未指定线程数,系统将默认使用四个线程。在多线程环境中,确保操作系统支持并正确配置以避免死锁问题。
摘要由CSDN通过智能技术生成

  唉,本来好好的使用的memcached的,突然要修改成支持多线程。对于memcached默认是只使用一个线程的,也就是说所有的请求都是通过一个线程来响应请求。如果想使memcached支持多线程,那么你就必须重新编译memcached。在编译memcached的时候,使用--enable-threads选项来告诉memcached来支持多线程。然后编译安装完成之后,memcached就可以支持多线程响应请求。

  需要注意的是如果你在启动的是没有通过-t选项指定thread的个数,那么memcached默认是四个线程。另外如果你指定的线程树超过了你cpu的核数,则有可能引发死锁问题,而且必须你的机器支持多线程编程(这句话不是很理解,是翻译过来的。现在机器不都是支持的吗)。


首先贴上安装的代码步骤,然后对出现问题简单分析一下。

下面的安装步骤是分为两个部分,一种是直接通过yum安装工具进行安装。这种方式是安装的单线程的memcached,如果想支持多线程,那么就必须采用第二种即通过编译源码进行安装。通过源码编译安装的话,必须是要机器上安装有libevent包,否则也是无法正常编译完成的。

1:Installing memcached from a Binary Distribution

To install memcached on a Red Hat, or Fedora host, use yum:

root-shell> yum install memcached
Note

On CentOS, you may be able to obtain a suitable RPM from another source, or use the source tarball.

To install memcached on a Debian or Ubuntu host, use apt-get:

root-shell> apt-get install memcached

To install memcached on a Gentoo host, use emerge:

root-shell> emerge install memcached


2:Building memcached from Source

On other Unix-based platforms, including Solaris, AIX, HP-UX and Mac OS X, and Linux distributions not mentioned already, you must install from source. For Linux, make sure you have a 2.6-based kernel, which includes the improved epoll interface. For all platforms, ensure that you have libevent 1.1 or higher installed. You can obtain libevent from libevent web page.

You can obtain the source for memcached from memcached Web site.

To build memcached, follow these steps:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值