Installing Memcached Dependencies
Memcached requires the libevent librrary to function properly. Install it using the package manager:
yum install libevent libevent-devel
Installing Memcached
With the dependencies in place, install Memcached:
yum install memcached
Running Memcached as a Background Service
Execute Memcached as a daemon with appropriate resource allocation:
/usr/local/memcached/bin/memcached -d -m 83840 -c 2048 -p 11211 -u root
If the binary location is unknown, locate it with:
sudo find / -name memcached
Replace the path in the command above with the discovered location.
Startup Parameters
| Flag | Description |
|---|---|
-d |
Runs Memcached as a daemon process |
-m |
Allocates memory in megabytes (83840 MB in this example) |
-u |
Specifies the user running the process |
-l |
IP address to bind to for incoming connections |
-p |
TCP port number (default: 11211) |
-c |
Maximum simultaneous client connections |
-P |
Path to the PID file for process tracking |
Verifying the Installation
Confirm Memcached is running:
ps aux | grep memcached
Managing the Service
Locate the running process:
ps -ef | grep memcached
Sample output showing the Memcached process:
root 9662 1 0 10:13 ? 00:00:00 /usr/bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid
The second column displays the process identifier. To halt the service:
kill 9662
Verify termination:
ps -ef | grep memcached
Starting the Service
Launch Memcached manually:
/usr/bin/memcached -d -m 1024 -u root -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid
Adjust memory allocation (-m), connection limit (-c), and port (-p) based on server capacity and expected workload.