memcachedのインストール方法

  • Git hubよりインストール

github.com

[vagrant@localhost ~]$ tar -zxf memcached-1.5.3.tar.gz
[vagrant@localhost ~]$ cd memcached-1.5.3/
[vagrant@localhost memcached-1.5.3]$ ./configure --prefix=/usr/local/memcached --enable-64bit --with-libevent=/usr/lib64/


[vagrant@localhost memcached-1.5.3]$ make && make test && sudo make install
  • systemd serviceとして登録

  • /usr/lib/systemd/system/memcached.service

[Unit]
Description=Memcached
Before=httpd.service
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/memcached
ExecStart=/usr/local/memcached/bin/memcached -p ${PORT} -u ${USER} -m ${CACHESIZE} -c ${MAXCONN} ${OPTIONS} -o modern

[Install]
WantedBy=multi-user.target
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

あとは、telnetで接続できる。

# systemctl daemon-reload
# systemctl restart memcached
# systemctl status memcached
● memcached.service - Memcached
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-02-23 10:22:27 UTC; 9s ago
 Main PID: 1460 (memcached)
   CGroup: /system.slice/memcached.service
           └─1460 /usr/local/memcached/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -o modern

Feb 23 10:22:27 v systemd[1]: Stopping Memcached...
Feb 23 10:22:27 v systemd[1]: Started Memcached.
Feb 23 10:22:27 v systemd[1]: Starting Memcached...
Feb 23 10:22:27 v memcached[1400]: Signal handled: Terminated.
$ telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set foo 0 0 3
123
STORED
get foo
VALUE foo 0 3
123
END