Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Memcached (2) YUM installation and compilation installation

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

YUM installation:

It relies on libevent, but this is generally included with the system. In addition, I installed Memcached on a separate server here, but it is also deployed separately in the production environment.

There is usually a memcached in the epel source. Let's take a look.

Yum list all memcached*

Installation

Rpm-ql memcached take a look at the generated file

The first is the service script file, the second is the configuration file, and the third and fourth are the tools

Start, start with the command you need to specify a user, YUM installation will automatically create memcached users. -vv is to show the startup process. Because there is no-d parameter, it is running in the foreground.

Here you can see the memory allocation process. The default memory is 64MB, the default chunk size is 48 bytes, and the growth factor is 1.25x.

The first is 96, and the next 10922 is how many 96-byte chunk are allocated.

The second is 120. it is 1.25 times that of 96. the next 8738 is the number of 96-byte chunk allocated.

The last analogy.

The content of the configuration file is also relatively small.

We start as a service.

Service memcached start

View startup port

Compile and install:

Download the latest version of Memcached: http://memcached.org/ here

Download libevent: http://libevent.org/ from here

Compile and install libevent first: because compiling and installing memcached depends on this library.

[] # tar-xzf libevent-2.1.8-stable.tar.gz [] # cd libevent-2.1.8-stable [] #. / configure-- prefix=/usr/local/libevent

Make & & make install

Installation completed

Install Memcached

[] # tar-xzf memcached1.4.34.tar.gz [] # cd memcached1.4.34 [] # / configure-- prefix=/usr/local/memcached1.4.34-- with-libevent=/usr/local/libevent/

Make & & make install

Installation completed

Create a running account

Groupadd-r memcacheduseradd-r-g memcached-s / sbin/nologin memcached

To start memcached, change to the bin directory in the installation directory, because the environment variable is not configured

. / memcached-u memcached-d

Add an environment variable

In this way, there is no need to change directories when you execute the memcached command later.

Vim / etc/profile.d/memcached.sh adds the following: #! / bin/bashMC_PATH=/usr/local/memcached1.4.34export PATH=$PATH:$MC_PATH/binchmod + x / etc/profile.d/memcached.sh. / etc/profile.d/memcached.sh

Verify it.

Set up as a system service

There is such a script in the scripts directory in the memcached source package, which can be copied to / etc/rc.d/init.d.

Cp memcached.sysv / etc/rc.d/init.d/memcachedchmod + x / etc/rc.d/memcachedchkconfig-- add / etc/rc.d/memcachedchkconfig-- list | grep memcachedchkconfig memcached on

Below, you can modify the script according to your needs, mainly the startup parameters.

#! / bin/sh## chkconfig:-55 4 percent description: The memcached daemon is a network memory cache service.# processname: memcached# config: / etc/sysconfig/memcached# Source function library.. / etc/rc.d/init.d/functions# Settings you want Port PORT=11211# Settings run account USER=memcached# specify maximum number of connections MAXCONN=1024# specify maximum memory CACHESIZE=64OPTIONS= used by memcached "" # specify installation path MEMCACHED_BIN_PATH=/usr/local/memcached1.4.34/binif [- f / etc/sysconfig/memcached]; then. / etc/sysconfig/memcachedfi# Check that networking is up.if ["$NETWORKING" = "no"] then exit 0fiRETVAL0prog0 progression = "memcached" # some variables are referenced here to set startup parameters. You can add other startup parameters by referencing start () {echo-n $"Starting $prog:" # make sure this directory / startup exists. And memcached users have permission to read and write chown $USER / var/run/memcached # write the full path here or you can't find it, if you think the path is too long, you can write a variable reference here. # daemon $MEMCACHED_BIN_PATH/memcached-d-p. Daemon / usr/local/memcached1.4.34/bin/memcached-d-p $PORT-u $USER-m $CACHESIZE-c $MAXCONN-P / var/run/memcached/memcached.pid $OPTIONS RETVAL=$? Echo [$RETVAL-eq 0] & & touch / var/lock/subsys/memcached} stop () {echo-n $"Stopping $prog:" killproc memcached RETVAL=$? Echo if [$RETVAL-eq 0]; then rm-f / var/lock/subsys/memcached rm-f / var/run/memcached/memcached.pid fi} restart () {stop start} # See how we were called.case "$1" in start) start;; stop) stop;; status) status memcached;; restart | reload) restart Condrestart) [- f / var/lock/subsys/memcached] & & restart | |:; *) echo $"Usage: $0 {start | stop | status | restart | reload | condrestart}" exit 1esacexit $?

Create a catalog

KILL drops the process started before, and then we start it with a service script

Settings on CentOS 7

This file is in the scripts directory in the source package.

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

View files copied in the past

Modify the file to write the path where you compiled and installed

Establish a configuration file

If you don't use a configuration file, you can write something like this

Start the service

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report