Is it possible to run more than one rabbitmq instance on one machine? - rabbitmq

I want to build a RabbitMQ cluster in my dev machine (windows).
reason is that I would like to test and study it.
Is it possible to run more than one rabbitmq instance on one machine?
I am guessing I need to:
Change the listening port
Change the appdata folder (C:\Users\MyUser\AppData\Roaming)
Change the ui plugin port so I can view all instances.
Remove the service and run from cli
Has anyone tried it?
Is there a known guide?

This thread appears to detail what you need. From the thread responses (scroll down):
The following settings are necessary to separate the node runtimes
completely, while allowing them to share the installed code base.
RABBITMQ_CONFIG_FILE /etc/rabbitmq/rabbitmq
RABBITMQ_MNESIA_BASE /var/lib/rabbitmq/mnesia
RABBITMQ_LOG_BASE /var/log/rabbitmq
RABBITMQ_ENABLED_PLUGINS_FILE /etc/rabbitmq/enabled_plugins

Now the official RabbitMQ documentation contains a section "A Cluster on a Single Machine", which describes how to run multiple Rabbit nodes on a single machine.
See https://www.rabbitmq.com/clustering.html#single-machine

One approach that I took when testing out clustering on my dev machine was to fire up several VMs. I had several for Rabbit and one for HAProxy.
While you can, as per one of the other answers, run multiple instances on a single OS instance, the multiple VM approach allowed me to mimic the intended production environment more closely.
NB. I have chosen to interpret your 'one machine' as meaning a physical machine for the purpose of this answer. If your meaning was 'virtual' then I defer to the other answer posted against this question which details how to accomplish this.

You can run multiple RabbitMQ instances on 1 machine without clustering. You just need to change the ports and the node name in rabbitmq-defaults, rabbitmq-env and config files.
For Linux:
Make sure you have Erlang installed, then download the latest version for Generic Unix and extract it.
Go to rabbit installation folder(the folder you just extracted)/sbin -> open the rabbitmq-defaults file and change SYS_PREFIX=${RABBITMQ_HOME} to create the default folder somewhere else, you should set the path to the extracted folder, for ex. /home/YOUR-USERNAME/rabbit_server-msg(this is my extracted folder).
Change the node name. Open the rabbitmq-env file -> find NODENAME=rabbit#${HOSTNAME} and change the name rabbit (ex. rabbitMSG#${HOSTNAME}). In the same file locate and change DEFAULT_NODE_PORT, by default it’s set to 5672. The default clustering port is set by ${DEFAULT_NODE_PORT} + 20000. So if you set the default node port to 5673, the clustering port will be 25673.
Install the Management Plugin. Navigate to rabbitmq-server/sbin and run “./rabbitmq-plugins enable rabbitmq_management”
The AMQP and HTTP ports need to be chnaged in the config file. Copy the file rabbitmq.config.example and paste it in the rabbit_server-msg(again this is my extracted forlder)/etc(this is the default folder created by RabbitMQ from step 1)/rabbitmq folder, rename the file to just rabbitmq.config. If you can’t find the file rabbitmq.config.example in the rabbit folder create a file named rabbitmq.config and copy the code from their GitHub.
Open the config file and uncomment the following lines:
– {tcp_listeners, [5672]} and change the port number (It is recommended to set the same number as the DEFAULT_NODE_PORT in rabbitmq-env for example 5673).
– {listener, [{port, 12345} and change the port number (This is for the management plugin).
NOTE: Be careful with the commas and brackets. Remove the comma after {tcp_listeners, [5672]}. Also after {listener, [{port, 12345} close the brackets like so ]}. Otherwise when you try to run ./rabbitmq-server it will show errors (It will show you on which line in the config file you have an error so you can fix it).
Now start up the server and log in the manager. Check the Listening ports under Ports and contexts to see if you made the changes. Do this for the other servers and you will be able to run as many servers as you want on 1 machine all with different listening ports. To start the RabbitMQ server automatically when you log in use the Startup Application program.
For Windows:
Setting up RabbitMQ for Windows is preatty much the same as on Linux.
Make sure you have Erlang installed, then download the latest version for Windows and extract it.
Go to rabbit(the folder you just extracted)/sbin -> open the rabbitmq-defaults.bat file and change RABBITMQ_BASE to create the default folder somewhere else, you should set the path to the extracted folder, for ex. C:/rabbit_server-msg(this is my extracted folder).
Change the node name. Open the rabbitmq-env.bat file -> find RABBITMQ_NODENAME=rabbit#!HOSTNAME! and change the name rabbit (ex. rabbitMSG#!HOSTNAME!). In the same file locate and change RABBITMQ_NODE_PORT, by default it’s set to 5672. To change the default clustering port locate and change RABBITMQ_DIST_PORT, by default it’s set to 25672.
Install the Management Plugin. Navigate to rabbit-server/sbin and run “rabbitmq-plugins.bat enable rabbitmq_management”.
The AMQP and HTTP ports need to be chnaged in the config file. Create a file named rabbitmq.config and copy the code from their GitHub. Put the file in your installation folder/RabbitMQ (ex. my config is in C:/rabbit_server-msg/RabbitMQ). Also in the rabbitmq-defaults.bat file check CONFIG_FILE it should be set to CONFIG_FILE=!RABBITMQ_BASE!\rabbitmq.
Open the config file and uncomment the following lines:
– {tcp_listeners, [5672]} and change the port number (It is recommended to set the same number as the RABBITMQ_NODE_PORTin rabbitmq-env for example 5673).
– {listener, [{port, 12345} and change the port number (This is for the management plugin).
NOTE: Be careful with the commas and brackets. Remove the comma after {tcp_listeners, [5672]}. Also after {listener, [{port, 12345} close the brackets like so ]}. Otherwise when you try to run rabbitmq-server.bat it will show errors (It will show you on which line in the config file you have an error so you can fix it).
Now start up the server and log in the manager. Check the Listening ports under Ports and contexts to see if you made the changes. Do this for the other servers and you will be able to run as many servers as you want on 1 machine all with different listening ports.
Source: https://lazareski.com/multiple-rabbitmq-instances-on-1-machine/

Related

Where can I find httpd.conf file for Apache on my windows?

I am trying to fix one venerability on my production web server(Apache), Venerability is "The HTTP headers sent by the remote web server disclose information that can aid an attacker, such as the server version and technologies used by the web server"
For this I have gone for some solutions , some where I found that to solve the above Venerability we need to edit the httpd.conf file on server but I did not find httpd.conf file in my entire system (using windows 10 os) can any one please let me know hot find that file or how to resolve that Venerability on production ?
You can find httpd.conf in
installed folder ex Apache24
Apache24/conf/httpd.conf
On Windows, I have seen people run Apache from all kinds of weird and wonderful places.
You need to track down where your Apache instance is running from, normally its running as a service on windows. If you open the properties on the service and look at the Path to executable, it should be something similar to the below.
"C:\Program Files\Apache24\bin\httpd.exe" -k runservice
Or it could be
"D:\Some Application\Version\WEB\tool\SOFTS\HTTPD\bin\httpd.exe" -k runservice
Unless there is an -f flag, setting the location of the conf. There will be a "conf" folder at the same level as the "bin" folder regardless of the path. This location is set at compile time so unless you have bespoke version off Apache this should be the location.
If you are struggling to find the service or a launcher that is running Apache. You can use WMI with a WQL query to look for processes which are called httpd.exe and get its executable path.
wmic process WHERE name="httpd.exe" GET ExecutablePath
In Xampp Control panel, in apache row, click on "config" button and then you see the term Apache(httpd.conf).

Apache server isn't starting on Xampp portable

It may seems as a repeated question but my problem is that I couldn't be able to start Apache server on XAMPP Portable, I'm am aware of the issues that some aplications can cause since they can use the ports where apache is supposed to work, so I decide to change the apache running ports on httpd.conf and httpd-ssl.conf files to Listen on 8080 and 8001 respectively, here are some screenshots of the changes,
http-conf1, http-conf2, httpssl-conf1, httpssl-conf2
In adition to that I also chage the configuration of the "Service & Port Settings" under XAMPP Control Panel, as shown in the folowing image,
xampp-ports
Although, I did all these changes I still can´t get the apache instance running, and keep getting the following error xampp-error, it's important to notice that I´m trying to start apache service in a company workstation and I don't have any admin rights, but I read that ports above 1250 didn't need any admin rigths to run services on them, so I don´t know what to do at this point, any suggestion from you guys would be really appreciated.
Thanks.
There are lot's of answer to this problem here, in particular I think that this is the answer you are looking for:
Have you executed "setup_xampp.bat" script?
It's inside XAMPP folder and it must be executed every time you change XAMPP folder.
(Bolds are mine)
While not explicitly stated in any "immediate" and "easily" visible warning or message, this is also stated in the readme_en.txt file inside the XAMPP portable main folder.
Step 1: Unpack the package into a directory of your choice. Please start the
"setup_xampp.bat" and beginning the installation.
Note: XAMPP makes no entries in the windows registry and no settings for the system variables.
I'd also say there is a not-so-clear note section right above this step:
[NOTE: Unpack the package to your USB stick or a partition of your choice.
There it must be on the highest level like E:\ or W:. It will
build E:\xampp or W:\xampp or something like this. Please do not use the "setup_xampp.bat" for an USB stick installation!]
I've installed it in a random folder (not root) and after running the setup_xampp.bat script everything ran correctly.
If you are using xampp in USB Drive and having issue at different Windows PC/Laptop then Assign a relevant letter to USB according to installation PC/Laptop USB Letter.
Suppose You install xampp in USB at computer Alpha and Computer Alpha assign it letter F to USB and Now You are at other PC/Laptop Bravo and that PC/Laptop assign it to letter W by default then change that letter to F using Bravo system control panel.
Problem: xampp Portable won’t start, failed or just doesn’t work!
Error: Apache shutdown unexpectedly.
[Apache] This may be due to a blocked port, missing dependencies,
[Apache] improper privileges, a crash, or a shutdown by another method.
[Apache] Press the Logs button to view error logs and check... ...
Solution:
Option 2
Step 1: Open Apache "httpd.conf" from xampp control panel. The file will open in notepad.
image-xampp-config
Step 2: Scroll down or search for “ServerRoot”. If result => ServerRoot "/xampp/apache" follow next step. If not follow (Option 2)
image-xammp-ServerRoot
If 'httpd.conf' not like this image follow #Option 2
Step 3: For portable version of xampp don't any other folder name like 'xampp56'
Use only "xampp" And put this on root directory.
No Sub folder/directory
Step 4: Open your USB drive and go to xampp folder, then start the xampp-control-panel with ‘run as administrator’ mode.
Done.
Option 2
Step 1: Open your ‘My Computer’ or ‘This PC’ to confirm your USB drive label on your current PC. E:, F:, G:…
Step 2: Open Apache "httpd.conf" from xampp control panel. The file will open in notepad. Now Scroll down or search for “ServerRoot”
image-changing-file-httpd
Step 3: There’s a file address path after the ServerRoot should change with your current USB drive address path if path not matches with this current PC.
image-notepade-replace-function
Step 4: Repeat the same process for Apache 'httpd-ssl.conf', 'httpd-xampp.conf',
'php.ini'(Please note that php using the backslash “\” instead of forward slash “/”)
image-php-ini-config-update
and
{…your usb…}\xampp\apache\conf\extra\
File name: 'httpd-autoindex.conf', 'httpd-multilang-errordoc.conf'.
Note: If xampp Portable Apache "httpd.conf" like Option 2 you have to Repeat this process Every time. I recommend you to download new version of 'xampp-portable-win32-... .zip'.
Otherwise total of 7 files need to be updated everytime you change
PC!! Apache ('httpd.conf', 'httpd-ssl.conf', 'httpd-xamp.conf')
'php.ini', 'my.ini', 'httpd-autoindex.conf',
'httpd-multilang-errordoc.conf'
Step 5: Open your USB drive and go to xampp folder, then start the xampp-control-panel with ‘run as administrator’ mode.
Done.

JBoss 7.2.0 Final creating server.log file in unexpected places

I am trying to set up JBoss 7.2.0 Final on CentOS 6.5 to handle 4 different deployments of our software. I'm not sure if I have set things up correctly or not, but everything seems to work except that server.log is not ending up where I think I am telling it to be saved in 3 of 4 deployments.
There are 4 HTTP ports being used for the deployments. They are :8080, :8180, :9876, and :9976. I don't know if that is relevant information or not, but I bring it up because in each standalone.xml file I am using the jboss.socket.binding.port-offset option to assign the ports. The only deployment that seems to work flawlessly is :8080, which has jboss.socket.binding.port-offset:0. :8180 has jboss.socket.binding.port-offset:100, etc.
Each deployment lives in its own directory, for example
/opt/jboss-eap-6.1/target/standalone8080/
and
/opt/jboss-eap-6.1/target/standalone9876/
In the standalone.xml file for each deployment (/opt/jboss-eap-6.1/target/standalone9876/configuration/standalone.xml, for example), the server log is specified in the same way:
<file relative-to="jboss.server.log.dir" path="server.log"/>
This should result in the server.log being saved in, for example,
/opt/jboss-eap-6.1/target/standalone9876/log,
and when redeploying the software on each port, I have echoed out the $JBOSS_LOG_DIR variable and it seems on the surface to be set correctly in each case.
However, as mentioned above, only port :8080 creates the server.log file in the expected location (/opt/jboss-eap-6.1/target/standalone8080/log).
The incorrect locations:
--Port :8180 puts its server.log file in the :8080 location. I.e., :8180 overwrites the server.log file at /opt/jboss-eap-6.1/target/standalone8080/log.
--Port :9876 puts its server.log file in /opt/jboss-eap-6.1/target/standalone/log. I.e., it creates a new folder simply called standalone and puts the file there. I will add that in a former time, the entire port :9876 deployment lived in a folder at that path (/opt/jboss-eap-6.1/target/standalone). This apparent clue makes me think there is some other place where there is a setting for the server.log file path. I could be quite wrong.
--Finally, port :9976 is putting its server.log file one level above the desired log directory, in other words, at /opt/jboss-eap-6.1/target/standalone9976.
I don't know if the way these 4 deployments are being handled is fundamentally incorrect or if there is a setting hiding somewhere that is overriding my desired paths.
I saw one poster with a similar problem say they made a change to domain.xml to fix the issue. I don't think I can do that, since I only have one domain.xml file (located in /opt/jboss-eap-6.1/domain/configuration) that is associated with all 4 deployments.
Another post recommended removing the "relative-to" bit in the <file> tag in the standalone.xml file. I tried that with port :9876 as follows:
<file path="/opt/jboss-eap-6.1/target/standalone9876/log/server.log"/>
This did not work for me. The server.log file still ended up in
<file path="/opt/jboss-eap-6.1/target/standalone/log/server.log"/>
Any ideas what I am doing wrong? Is there simply another place I need to declare my log path, or is the way these 4 servers are set up just plain incorrect?
Have a look at each logging.properties file in each configuration directory. You might just need to update those, once, to change the path to {jboss.server.log.dir}/server.log. Then when you start each server you'll need to specify the jboss.server.log.dir directory.
./bin/standalone.sh -Djboss.server.log.dir=$JBOSS_HOME/target/standalone8080/log
There might be a clever way to handle it in the $JBOSS_HOME/bin/standalone.conf file.

Is there a way to check if a directory exists in Apache configuration files?

Is there a way to include configuration settings in Apache based on if a directory exists? Basically I have a portable hard drive that I transport between work and home that has some stuff I'm developing on it. I only want the Apache config to load a particular virtual host if the folder exists.
Since Apache 2.4.34 you can now use <IfFile>...</IfFile> which will check to see if a file exists. There's more details on the <IfFile> page.
No, there seems to be no direct way to do this.
The only thing that might be a solution is the IfDefine directive. You can define defines using the -d parameter to when the server is started.
The parameter-name argument is a define as given on the httpd command line via -Dparameter-, at the time the server was started.
You might be able to check for the existence of a directory in a batch or bash file, and set the -d parameter accordingly.
Whether that is an option, will depend on how your server is started from the portable hard drive.
I've come up with a solution that seems to work for Linux and OS X, and it hinges on "mountpoints". It might be possible to emulate it within Windows, as well, but you would probably have to get creative with FUSE and/or Cygwin.
If you create an empty folder in your home directory, such as "/Users/username/ExtraVhosts", you can add an apache directive to "Include /Users/username/ExtraVhosts/*".
Then, when you insert your thumb drive, you can mount somewhere and then use mountpoint "binding" to cross-link the ExtraVhosts folder to a folder on the mobile device.
An OS X example:
I have a thumb drive called 'Cherrybomb'
When I insert it, it always gets mounted to /Volumes/Cherrybomb
I can then use bindfs (sudo port install bindfs) to mount a subfolder of it, like so:
sudo bindfs /Volumes/Cherrybomb/Projects/vhosts /Users/username/ExtraVhosts
Then I can restart apache to read in the updated configuration:
sudo /opt/local/apache2/bin/apachectl restart
At that point, it's just a matter of adding entries in /etc/hosts for server aliases to get picked up.
The linux equivalent would be using the "--bind" parameter of the mount command.
One caveat: This makes it difficult to quickly unmount the USB drive, since it is always marked as "in use" by apache. Here's a removal procedure:
Close all open files and terminal sessions that are using the drive (the present-working-directory in terminal can cause unmount issues)
Stop apache: sudo /opt/local/apache2/bin/apachectl stop
umount /Users/username/ExtraVhosts
Then you can either unmount it graphically or manually (umount /Volumes/Cherrybomb).
If your work and home machines mount the drive to different locations, you could have multiple vhosts folders - home_vhost, work_vhost, etc - and use that in the binding step.
I hope this helps someone out :)
If you point apache to the mountpoint only there shouldn't be an issue. Just don't point Directory directives to directories within the drive.
eg, if you mount /dev/somedisk /mnt/somevhost, the
/mnt/somevhost directory will be there whether or not you have the drive mounted and apache will start. Apache doesn't care if the directory is empty so a <Directory "/mnt/somevhost"/> won't cause server to not start if the drive isn't mounted.
Work with UNIX not against it :-p This solution should be sufficient for development.

Is it possible to have WAMP run httpd.exe as user [myself] instead of local SYSTEM?

I run a django application over apache with mod_wsgi, using WAMP.
A certain URL allows me to stream the content of image files, the paths of which are stored in database.
The files can be located whether on local machine or under network drive (\\my\network\folder).
With the development server (manage.py runserver), I have no trouble at all reading and streaming the files.
With WAMP, and with network drive files, I get a IOError : obviously because the httpd instance does not have read permission on said drive.
In the task manager, I see that httpd.exe is run by SYSTEM. I would like to tell WAMP to run the server as [myself] as I have read and write permissions on the shared folder. (eventually, the production server should be run by a 'www-admin' user having the permissions)
Mapping the network shared folder on a drive letter (Z: for instance) does not solve this at all.
The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
I've also regedited : I tried to duplicate the HKLM\[...]\wampapache registry key under HK_CURRENT_USER\ and rename the original key, but then the new key does not seem to be found when I cmd this
> httpd.exe -n wampapache -k start
or when I run WAMP.
I've run out of ideas :)
Has anybody ever had the same issue?
Win+R, services.msc
edit wampapache and wampmysqld to log on as some user.
the tray icon is a convenient front end to "net start wampapache" and "net start wampmysqld"
The User/Group directives in httpd.conf do not seem to have any kind of influence on Apache's behaviour.
httpd.exe is started by the root user (this is probably why you see it running under SYSTEM). The user and group lines in httpd.conf determine what user the child processes (that httpd spawns) will run under. These forks are what actually handle page requests, etc. so it is possible that your configuration is already doing what you want it to, it is just unclear from looking at task manager.
You could also try using runas to start WAMP/Apache, though your mileage may vary.
I've just found that executing httpd.exe myself works for me... I just loose all the funky WAMP tray icon, and the "restart apache" menu item, really handy whenever I update my application code...
I'll have to make do with this for the moment...