Linux under Memcached Server deployment procedures

Source: Internet
Author: User
Tags curl gettext memcached openssl iptables

Operating system: CentOS 6.x 64-bit

Implementation Purpose: Install deployment memcached Server

First, firewall settings

Vi/etc/sysconfig/iptables #编辑防火墙配置文件, add the following code

-A input-m state--state new-m tcp-p TCP--dport 11211-j ACCEPT

: wq! #保存退出

Service iptables Restart #最后重启防火墙使配置生效

Second, close SELinux

Vi/etc/selinux/config

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

Selinux=disabled #增加

: wq! #保存退出

Setenforce 0 #使配置立即生效

Third, the system agreement

Software source code Package storage location:/USR/LOCAL/SRC

Source Package Compile Installation location:/usr/local/software Name

Four, download the software package

1, download libevent

Https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz

2, download memcached

Http://www.memcached.org/files/memcached-1.4.25.tar.gz

V. Installation of the Compilation tool kit

Yum install-y apr* autoconf automake bison cloog-ppl compat* cpp Curl curl-devel fontconfig fontconfig-devel freetype fre etype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-d Evel Krb5-devel libcom_err-devel libpng* libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* Libgomp LIBXML2 libxml2-devel libxpm* libtiff libtiff* libx* make MPFR ncurses* ntp OpenSSL openssl-devel patch pcre-devel perl ph P-common php-gd policycoreutils ppl telnet t1lib t1lib* nasm nasm* wget zlib-devel gmp-devel

Vi. Installation and Configuration memcached

1. Installation Libevent

Cd/usr/local/src

Tar zxvf libevent-2.0.22-stable.tar.gz

CD libevent-2.0.22-stable

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

Make

Make install

2. Installation memcached

Cd/usr/local/src

Tar zxvf memcached-1.4.25.tar.gz

CD memcached-1.4.25

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

Make

Make install

3. Test memcached

Groupadd memcached #创建组

Useradd-g memcached memcached-s/bin/false #创建账号

Ln-s/usr/local/memcached/bin/memcached/usr/local/bin/memcached #添加软连接

The server-side command to start the memcache is:

/usr/local/memcached/bin/memcached-d-M 4096-u root-l 192.168.4.6-p 11211-c 1024-p/usr/local/memcached/memcached.pi D

Or

/usr/local/memcached/bin/memcached-d-M 4096-u memcached-l 192.168.4.6-p 11211-c 1024

Parameter description:

The-D option is to start a daemon,

-M is the amount of memory allocated to Memcache, in megabytes, 4096MB

-U is a user who runs Memcache, such as root or memcached

-L is the IP address of the server that is listening, where the IP address of the server is specified 192.168.4.6 and the default listener server is not set for all IP addresses

-P is the port that sets the Memcache listening by default of 11211

The-c option is the maximum number of concurrent connections to run, by default 1024

-P is set to save the memcache pid file,/usr/local/memcached/memcached.pid

On/etc/rc.d/rc.local, add a line to the boot

/usr/local/memcached/bin/memcached-d-M 4096-u root-l 192.168.4.6-p 11211-c 1024-p/usr/local/memcached/memcached.pi D

You can also use the following command:

/usr/local/memcached/bin/memcached-d-M 4096-p 11211-u memcached

When IP is not specified, the default is to listen for all local IP addresses, and users should choose to be a non-root user, such as memcached

Turn off the memcached service

Cat/usr/local/memcached/memcached.pid #查看进程

Kill 22856 #结束进程

Or

Killall memcached #结束服务

System Yun-wei www.osyunwei.com warm reminder: qihang01 original Content © Copyright, reproduced please specify the source and the original link

4, set up memcached boot

Vi/etc/rc.d/init.d/memcached

#!/bin/sh

#

# memcached:memcached Daemon

#

# Chkconfig:-90 25

# description:memcached Daemon

#

# Source function library.

. /etc/rc.d/init.d/functions

. /etc/sysconfig/network

Memcached= "/usr/local/memcached/bin/memcached"

Start ()

{

Echo-n $ "Starting memcached:"

Daemon $MEMCACHED-u memcached-d-M 4096-p 11211-c 1024

Echo

}

Stop ()

{

Echo-n $ "Shutting down memcached:"

Killproc memcached

Echo

}

[f $MEMCACHED] | | Exit 0

# How we were called.

Case "$" in

Start

Start

;;

Stop

Stop

;;

Restart|reload)

Stop

Start

;;

Condrestart)

Stop

Start

;;

*)

echo $ "Usage: $ {Start|stop|restart|reload|condrestart}"

Exit 1

Esac

Exit 0

: wq! #保存退出

chmod 775/etc/rc.d/init.d/memcached #赋予文件执行权限

Chkconfig memcached on #设置开机启动

/etc/rc.d/init.d/memcached Start #启动

At this point, the Linux memcached Server deployment is complete.

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.