Superior Administrator _.:=iTake=:._ Posted August 20, 2019 Superior Administrator Report Posted August 20, 2019 Install memcached from YUM repository Use following YUM command to install memcached package from CentOS 7 base repository: yum -y install memcached This installation provides a memcached instance with configuration file /etc/sysconfig/memcached. Run multiple memcached processes Assume that you have a requirement of running two memcached processes with following configurations: config1 – configuration of first process listen address: 127.0.0.1 listen port: 11211 maximum concurrent connections: 1024 maximum in-memory cache size: 256MB config2 – configuration of second process listen address: 127.0.0.1 listen port: 11212 maximum concurrent connections: 2048 maximum in-memory cache size: 512MB Let us use config1 configuration for the default memcached process. For that, edit /etc/sysconfig/memcached using your favorite editor (say nano text editor) and make following settings in it: nano /etc/sysconfig/memcached PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="256" OPTIONS="-l 127.0.0.1" Start the first memcached process: systemctl start memcached.service Enable it on server boot: systemctl enable memcached.service Check status of first memcached process; it should be running if no problem happened: systemctl status memcached.service memcached.service - Memcached Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled) Active: active (running) since Mon 2014-12-15 15:20:00 EDT; 17s ago Main PID: 24217 (memcached) CGroup: /system.slice/memcached.service └─24217 /usr/bin/memcached -u memcached -p 11211 -m 64 -c 1024 -l 127.0.0.1 Dec 15 15:20:00 localhost.localdomain systemd[1]: Starting Memcached... Dec 15 15:20:00 localhost.localdomain systemd[1]: Started Memcached. 1
Superior Administrator _.:=iTake=:._ Posted August 20, 2019 Author Superior Administrator Report Posted August 20, 2019 To create the second process with config2 configuration, create its configuration file /etc/sysconfig/memcached2 with following settings: nano /etc/sysconfig/memcached2 PORT="11212" USER="memcached" MAXCONN="2048" CACHESIZE="512" OPTIONS="-l 127.0.0.1" Create systemd unit file /etc/systemd/system/memcached2.service with following settings: [unit] Description=Memcached2 Before=httpd.service After=network.target [service] Type=simple EnvironmentFile=-/etc/sysconfig/memcached2 ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS [install] WantedBy=multi-user.target Start the second memcached process: systemctl start memcached2.service Enable it on server boot: systemctl enable memcached2.service Check status of second memcached process; it should be running if no problem happened: systemctl status memcached2 memcached2.service - Memcached2 Loaded: loaded (/etc/systemd/system/memcached2.service; enabled) Active: active (running) since Mon 2014-12-15 15:20:03 EDT; 20s ago Main PID: 24226 (memcached) CGroup: /system.slice/memcached2.service └─24226 /usr/bin/memcached -u memcached -p 11212 -m 128 -c 1024 -l 127.0.0.1 Dec 15 15:20:03 localhost.localdomain systemd[1]: Starting Memcached2... Dec 15 15:20:03 localhost.localdomain systemd[1]: Started Memcached2. To verify listening sockets of memcached processes, use following ss command: ss -lnp | grep memcached tcp UNCONN 0 0 127.0.0.1:11211 *:* users:(("memcached",24217,27)) tcp UNCONN 0 0 127.0.0.1:11212 *:* users:(("memcached",24226,27)) tcp LISTEN 0 128 127.0.0.1:11211 *:* users:(("memcached",24217,26)) tcp LISTEN 0 128 127.0.0.1:11212 *:* users:(("memcached",24226,26)) You can see that the two memcached processes are listening to ports 11211 and 11212 respectively on loopback IP address 127.0.0.1. If you require more memcached processes, create separate configuration and systemd unit files. Then manage the processes using systemctl as explained above. Conclusion In this article, we showed you a method to run multiple memcached processes on a CentOS 7 Linux system by extending the default binary RPM installation. Each extra memcached process owns a separate configuration file and is managed by a separate systemd service unit file. Source: This is the hidden content, please Sign In or Sign Up 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now