Translate

viernes, 27 de febrero de 2015

Install Second Memcached Server as a Service on Windows


Problem

Sometimes we need to install a second memcached server instance in the same machine (e.g. a developer working in two projects locally and both use memcached).

If we need to install memcached as a service we execute something like this command:

c:/path/to/exe/memcached.exe  -d install


The problem is that we can't run it twice because we will get the following error


So, we got a couple of options:


Solution 1: Initialize a second instance of memcached server in  a different port using de command prompt


We just need to run the following command: memcached.exe -p [port]





the issue whit this approach is if we close the cmd we will stop the new memcached instance..

Solution 2: Run the second memcached server instance as a windows service


We just need to run the following command. This will create a windows service with the name we want and will execute the .exe file we set with the binpath parameter (See command documentation).

sc create [service_name] binpath= "[path to .exe and its parameters]"

First, open de cmd with admin rights which can be done with one of this ways
















So we will get something like:

sc create Second_Memached binpath= "C:\memcached-win32-1.4.4-14\memcached.exe -p 11212 -d runservice"

NOTEbinpath=[blank space here]"c:\path\to\exe\memcached.exe -p 11212 -d runservice"
NOTEbinpath= "c:\path\to\exe\memcached.exe -p 11212 -d runservice" the quotes surround the memcached command and its parameters
NOTE: you will need admin privileges to excecute this command

The result will be something like this message



Note the service is not already running, so will need to start it manually


And now we have a second memcached server instance running


One last thing to note is that service Startup Type is set to Manual. So next time we restart out machine we will have to get it started again. To solve it we can set it to Automatic right clicking on the service and then clicking on Properties


I hope this help you. See you


Luxant

About Luxant

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.