ubuntu 16.04二进制安装Memcached版本

一、下载libevent与memcached解压包

官网地址:https://src.fedoraproject.org/repo/pkgs/libevent/

官网地址:https://memcached.org/downloads

二、安装libevent 

cd  /usr/local

tar  -zxvf   libevent-1.3b.tar.gz

mv  libevent-1.3b   libevent

cd  libevent

./configure --prefix=/usr/local/libevent

make

编译 libevent 出错: event.c error: 'CLOCK_MONOTONIC' undeclared,如图所示:

解决方法:修改libevent目录下 event.c,并在CLOCK_MONOTONIC前端添加#include<time.h>即可,如图所示

 输入wq!保存退出即可

重新编译:make

编译安装:make  install

ls -al /usr/lib | grep libevent

备注:安装memcached之前,需要先安装libevent依赖包;

三、安装memcached

cd  /usr/local

tar  -zxvf   memcached-1.5.16.tar.gz

mv  memcached-1.2.1.  memcached   

cd  memcached

./configure --prefix=/usr/local/memcached     --with-libevent=/usr/local/libevent

make&&make  install

/usr/local/memcached/bin/memcached -d -m 128 -l 192.168.209.19 -u root

四、memcached设置开机自启

CentOS自启方式:

vim /etc/rc.d/rc.local

/usr/local/memcached/bin/memcached  -u root -d -m 2048 -l 172.16.75.206 -p 11211 -P /tmp/memcached.pid

使用wq保存退出即可

sudo  systemctl  enable  memcached

sudo  systemctl  start  memcached

Ubuntu自启方式:

输入 vim /etc/init.d/memcached 进入编辑模式

#!/bin/sh
/usr/wubin/memcached1.5/memcached/bin/memcached -d -m 128 -l 172.16.75.206 -u root

使用wq保存退出即可

cd /etc/init.d
sudo chmod 755 memcached
sudo chkconfig memcached on
sudo reboot

检查开机状态:systemctl status memcached.service

查看memcached进程:

ps  -ef  |  grep  memcached

 

posted @ 2022-03-21 14:13  斌斌的博客  阅读(61)  评论(0编辑  收藏  举报