Setting up a Storm Cluster
Here's a summary of the steps for setting up a Storm cluster:
- Set up a Zookeeper cluster
- Install dependencies on Nimbus and worker machines
- Download and extract a Storm release to Nimbus and worker machines
- Fill in mandatory(强制的,务必的) configurations into storm.yaml
- Launch daemons under supervision using "storm" script and a supervisor of your choice
Set up a Zookeeper cluster
Storm uses Zookeeper for coordinating(协同) the cluster. Zookeeper is not used for message passing, so the load Storm places on Zookeeper is quite low. Single node Zookeeper clusters should be sufficient(充足的) for most cases, but if you want failover(失效备援) or are deploying large Storm clusters you may want larger Zookeeper clusters. Instructions for deploying Zookeeper are here.
A few notes about Zookeeper deployment:
- It's critical(关键的) that you run Zookeeper under supervision, since Zookeeper isfail-fast and will exit the process if it encounters any error case. See here for more details.
- It's critical(关键的) that you set up a cron to compact Zookeeper's data and transaction logs. The Zookeeper daemon does not do this on its own, and if you don't set up a cron, Zookeeper will quickly run out of disk space. See here for more details.
Install dependencies on Nimbus(云) and worker machines
Next you need to install Storm's dependencies on Nimbus and the worker machines. These are:
- Java 7+ (Apache Storm 1.x is tested through travis ci against both java 7 and java 8 JDKs)
- Python 2.6.6 (Python 3.x should work too, but is not tested as part of our CI enviornment)
These are the versions of the dependencies that have been tested with Storm. Storm may or may not work with different versions of Java and/or Python.
Download and extract a Storm release to Nimbus and worker machines
Next, download a Storm release and extract the zip file somewhere on Nimbus and each of the worker machines. The Storm releases can be downloaded from here.
Fill in mandatory(强制的) configurations into storm.yaml
The Storm release contains a file atconf/storm.yaml
that configures the Storm daemons. You can see the default configuration values
here
. storm.yaml overrides anything in defaults.yaml. There's a few configurations that are mandatory to get a working cluster:
1) storm.zookeeper.servers: This is a list of the hosts in the Zookeeper cluster for your Storm cluster. It should look something like:
storm.zookeeper.servers:
- "111.222.333.444"
- "555.666.777.888"
If the port that your Zookeeper cluster uses is different than the default, you should set storm.zookeeper.port as well.
2) storm.local.dir: The Nimbus and Supervisor daemons require a directory on the local disk to store small amounts of state (like jars, confs, and things like that). You should create that directory on each machine, give it proper permissions, and then fill in the directory location using this config. For example:
storm.local.dir: "/mnt/storm"
If you run storm on windows, it could be:
storm.local.dir: "C:\\storm-local"
If you use a relative path, it will be relative to where you installed storm(STORM_HOME). You can leave it empty with default value $STORM_HOME/storm-local
3) nimbus.seeds: The worker nodes need to know which machines are the candidate(候选人|申请者) of master in order to download topology jars and confs. For example:
nimbus.seeds: ["111.222.333.44"]
You're encouraged to fill out the value to list of machine's FQDN(Fully Qualified Domain Name-全称域名). If you want to set up Nimbus H/A, you have to address all machines' FQDN which run nimbus. You may want to leave it to default value when you just want to set up 'pseudo(假的|虚伪的)-distributed'(伪分布式) cluster, but you're still encouraged to fill out FQDN.
4) supervisor.slots.ports: For each worker machine, you configure how many workers run on that machine with this config. Each worker uses a single port for receiving messages, and this setting defines which ports are open for use. If you define five ports here, then Storm will allocate(分配|拨给) up to five workers to run on this machine. If you define three ports, Storm will only run up to three. By default, this setting is configured to run 4 workers on the ports 6700, 6701, 6702, and 6703. For example:
supervisor.slots.ports:
- 6700
- 6701
- 6702
- 6703
Monitoring Health of Supervisors
Storm provides a mechanism(机制) by which administrators can configure the supervisor to run administrator supplied scripts periodically(定期的) to determine if a node is healthy or not. Administrators can have the supervisor determine if the node is in a healthy state by performing any checks of their choice in scripts located in storm.health.check.dir. If a script detects the node to be in an unhealthy state, it must print a line to standard output beginning with the string ERROR. The supervisor will periodically run the scripts in the health check dir and check the output. If the script’s output contains the string ERROR, as described above, the supervisor will shut down any workers and exit.
If the supervisor is running with supervision "/bin/storm node-health-check" can be called to determine if the supervisor should be launched or if the node is unhealthy.
The health check directory location can be configured with:
storm.health.check.dir: "healthchecks"
The scripts must have execute permissions. The time to allow any given healthcheck script to run before it is marked failed due to timeout can be configured with:
storm.health.check.timeout.ms: 5000
Configure external libraries and environmental variables (optional)
If you need support from external libraries or custom plugins, you can place such jars into the extlib/ and extlib-daemon/ directories. Note that the extlib-daemon/ directory stores jars used only by daemons (Nimbus, Supervisor, DRPC, UI, Logviewer), e.g., HDFS and customized scheduling libraries. Accordingly(因此), two environmental variables STORM_EXT_CLASSPATH and STORM_EXT_CLASSPATH_DAEMON can be configured by users for including the external classpath and daemon-only external classpath.
Launch daemons under supervision using "storm" script and a supervisor of your choice
The last step is to launch all the Storm daemons. It is critical that you run each of these daemons under supervision. Storm is a fail-fast system which means the processes will halt(停止|终止) whenever an unexpected error is encountered. Storm is designed so that it can safely halt at any point and recover correctly when the process is restarted. This is why Storm keeps no state in-process -- if Nimbus or the Supervisors restart, the running topologies are unaffected(不受影响的). Here's how to run the Storm daemons:
- Nimbus: Run the command "bin/storm nimbus" under supervision on the master machine.
- Supervisor: Run the command "bin/storm supervisor" under supervision on each worker machine. The supervisor daemon is responsible for starting and stopping worker processes on that machine.
- UI: Run the Storm UI (a site you can access from the browser that gives diagnostics(诊断) on the cluster and topologies) by running the command "bin/storm ui" under supervision. The UI can be accessed by navigating your web browser to http://{ui host}:8080.
As you can see, running the daemons is very straightforward. The daemons will log to the logs/ directory in wherever you extracted the Storm release.