Linux under Memcached Server deployment

Source: Internet
Author: User
Tags gettext memcached openssl iptables

650) this.width=650; "Width=" 397 "height=" 169 "title=" Linux "class=" Alignnone size-full wp-image-145 "src="/HTTP/ Www.osyunwei.com/wp-content/uploads/2011/10/linux.jpg "/>

Operating system: CentOS 6.x 64-bit

Implementation purpose: Install and deploy the 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, to close SELinux

Vi/etc/selinux/config

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

selinux=disabled #增加

: wq! #保存退出

Setenforce 0 #使配置立即生效

Third, the system contract

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

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

Iv. Download the 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. Install the build 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 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 commands to start the memcache are:

/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 running memcache, such as root or memcached

-L is the server IP address of the listener, here specifies the IP address of the server 192.168.4.6, does not set the default listening server all IP addresses

-P is the port that sets Memcache listening, which defaults to 11211

The-c option is the maximum number of concurrent connections that are running, by default 1024

-P is a PID file that is set to save Memcache,/usr/local/memcached/memcached.pid

Start-up, add a line to the/etc/rc.d/rc.local

/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

IP is not specified, the default listener local all IP address, the user is best to choose non-root users, such as memcached

Close memcached Service

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

Kill 22856 #结束进程

Or

Killall memcached #结束服务

4, set 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

# See 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.


Linux under Memcached Server deployment

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.