I have installed two instance of elasticsearch on a same machine.but now I am not able to install them as a service
First don't do it unless you have more than 64gb of RAM on your machine.
For tests purposes just download unzip the distribution and run it from the directory.
If you really want to install as a service 2 nodes, you have to manually modify some scripts I guess.
BTW You did not tell what is your OS