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

What is the installation and configuration of memcached under suse linux

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Today, I will talk to you about the installation configuration of memcached under suse linux. Many people may not know much about it. In order to let everyone know more, Xiaobian summarized the following contents for everyone. I hope everyone can gain something according to this article.

Memcached is a high-performance distributed in-memory object caching system for dynamic Web applications to reduce database load. It reduces the number of database reads by caching data and objects in memory, thus greatly reducing the database load, better allocating resources, and achieving faster access.

Memcached uses libevent to balance any number of open links, uses non-blocking network I/O, implements reference counting for internal objects, and uses its own page block allocator and hash table, so virtual memory does not fragment.

Environment: SUSE LINUX ENTERPRISE SERVER 10 (64bit)

Software version: libevent-2.0.10 memcached-1.4.5

Install Memcached

Memcached will use libevent library for Socket processing, so install libevent first. The specific steps are as follows:

1. Install libevent:

# tar zxvf libevent-2.0.10-stable.tar.gz

# cd libevent-2.0.10-stable

# ./ configure -prefix=/usr (specify installation path)

Note the three NOs in the red box, mainly because there is no GCC and C, C++ compilation environment, insert SUSE LINUX 10 CD and use the YAST2 command to install the corresponding package.

# make

# make install

Note: The package required is roughly

glibc-devel-2.4-31.74.1.x86_64.rpm

libmudflap-4.1.2_20070115-0.29.6.x86_64.rpm

gcc-4.1.2_20070115-0.29.6.x86_64.rpm

libstdc++-devel-4.1.2_20070115-0.29.6.x86_64.rpm

gcc-c++-4.1.2_20070115-0.29.6.x86_64.rpm

2. Test whether libevent is installed successfully

5. Start Memcached's server side:

# /usr/local/bin/memcached -d -m 1000 -u root -l 192.168.1.252 -p 8990 -c 2000 -P /tmp/memcached.pid

The-d option starts a daemon.

-m is the amount of memory allocated to Memcached, in MB, here I have 1000MB.

-u is the user running Memcached, I'm root here

-l is the IP address of the listening server, I specify the IP address of the server here 192.168.1.252

-p is the port where Memcached is set to listen. I set 8990 here, preferably port above 1024.

-c option is the maximum number of concurrent connections running, the default is 1024, I set 2000 here, according to your server load to set

-P is set to save Memcached pid file, I here is saved at/tmp/memcached.pid

To end the Memcached process, execute:

# kill cat /tmp/memcached.pid

Multiple daemons can also be started, but ports cannot be duplicated.

6. Error resolution encountered on the server side of starting Memcached:

As shown in the figure:

7. Configure the client again.

Memcached Client for Java

Download the latest version of the client package: java_memcached-release_2.5.1.zip, unzip, find java_memcached-release_2.5.1.jar in the folder, this is the client JAR package. Add this JAR package to your project's build path and Memcached will be available for your project.

Example code:

import com.danga.MemCached.*;

public class MyCache {

public static void main(String[] args) {

/**

* Initialize SockIOPool, manage memcached connection pool

* */

String[] servers = { "192.168.1.252:8990">

SockIOPool pool = SockIOPool.getInstance();

pool.setServers(servers);

pool.setFailover(true);

pool.setInitConn(10);

pool.setMinConn(5);

pool.setMaxConn(250);

pool.setMaintSleep(30);

pool.setNagle(false);

pool.setSocketTO(3000);

pool.setAliveCheck(true);

pool.initialize();

/**

* Create MemcachedClient instance

* */

MemCachedClient memCachedClient = new MemCachedClient();

for (int i = 0; i < 1000; i++) {

/**

* Add objects to memcached cache

* */

boolean success = memCachedClient.set("" + i, "Hello! ");

/**

* Fetch objects by key value from memcached cache

* */

String result = (String) memCachedClient.get("" + i);

System.out.println(String.format("set( %d ): %s", i, success));

System.out.println(String.format("get( %d ): %s", i, result));

}

}

}

After reading the above, do you have any further understanding of how memcached is installed under suse linux? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report