dhtcrawler2 Documentation
repository·master·Indexed 24 days ago
https://github.com/btdig/dhtcrawler2An Erlang-based DHT crawler for high-speed, stable crawling of P2P torrent networks. It indexes torrent data into MongoDB and provides search capabilities via an HTTP interface. The system supports MongoDB text search, Sphinx search integration for advanced text or Chinese character support, and MongoDB Replica Set deployment for primary and secondary database architecture.
What's inside dhtcrawler2
- Developers can write custom HTTP front-end UIs based on the torrent database. If you need assistance with the database format to facilitate this, contact the project maintainer.
Deploy a MongoDB Replica Set for dhtcrawler2
masterTo support the dhtcrawler2 architecture, you can deploy a MongoDB Replica Set consisting of a primary database (used by the crawler) and secondary databases (used by the HTTP server for queries).
Prerequisites:
- Ensure
mongodis included in your systemPATH.
Deployment Steps:
- Start the primary node using
db-start-primary.bat. - Start the secondary nodes using
db-start-slave.bat. - Initialize the primary database using
init-primary-db.bat.
Critical Note: After running the initialization script, verify that the
rs.initiate()command was successful within the MongoDB shell to ensure the replica set is correctly configured.# Sequence of operations db-start-primary.bat db-start-slave.bat init-primary-db.bat # Verify rs.initiate() success in mongo shell- Ensure
Install and run dhtcrawler2
masterdhtcrawler2 is an Erlang-based DHT crawler that joins P2P networks to collect torrent information and stores it in a MongoDB database. It provides an HTTP interface for searching torrents by keyword.
Prerequisites
- Erlang: Install Erlang R16B or newer.
- MongoDB: Download and start MongoDB with text search enabled.
Setup Steps
- Start MongoDB with the
textSearchEnabledparameter:mongod --dbpath your-database-path --setParameter textSearchEnabled=true - Start the Crawler:
- On Windows, run
win_start_crawler.bat.
- On Windows, run
- Start the Hash Reader:
- On Windows, run
win_start_hash.bat.
- On Windows, run
- Start the HTTP Server:
- On Windows, run
win_start_http.bat.
- On Windows, run
- Access the Interface: Wait several minutes, then navigate to
http://localhost:8000in your browser.
mongod --dbpath your-database-path --setParameter textSearchEnabled=trueEnable Sphinx search integration
masterBy default, dhtcrawler2 uses MongoDB text search. To switch to Sphinx search (recommended for advanced text searching or Chinese character support), follow these steps:
1. Install Sphinx
- Download a Sphinx fork like
coreseek(which supports Chinese characters). - Add the Sphinx
bindirectory to your systemPATHso the crawler can invoke theindexertool.
2. Configure Sphinx
- Edit
etc/csft.confto add a delta index. Example configuration:source delta:xml { type = xmlpipe2 xmlpipe_command = cat g:/downloads/coreseek-4.1-win32/var/test/delta.xml } index delta:xml { source = delta path = g:/downloads/coreseek-4.1-win32/var/data/delta }
- Use absolute paths for all directories. ### 3. Initialize Sphinx Index - Run `win_init_sphinx_index.bat` to generate a default `sphinx-builder` config file. Terminate the script once generated. - Edit `priv/sphinx_builder.config` to specify the `main` and `delta` Sphinx index source file names, index names, and the Sphinx config file. **Note**: These must match the configurations you wrote in `etc/csft.conf`. - Run `win_init_sphinx_index.bat` again to initialize the index file. Terminate the script once finished. **Warning**: Do not run this initialization step again once it has succeeded. ### 4. Run the Search Pipeline - Start the Sphinx `searchd` server. - Run `win_start_sphinx_builder` to start the builder, which reads torrents from MongoDB and builds the Sphinx index. - Update `priv/hash_reader.config` by setting `search_method` to `sphinx`. - Update `priv/httpd.config` by setting `search_method` to `sphinx`.source delta:xml { type = xmlpipe2 xmlpipe_command = cat g:/downloads/coreseek-4.1-win32/var/test/delta.xml } index delta:xml { source = delta path = g:/downloads/coreseek-4.1-win32/var/data/delta }- Download a Sphinx fork like
Configure dhtcrawler2 settings
masterConfiguration is handled in two ways:
- File-based Configuration: Most settings are located in
priv/dhtcrawler.config. This file is automatically generated upon the first run. You typically only need to modify network addresses in this file. - Function Arguments: Other configuration values are passed directly as arguments to Erlang functions.
Specific component configurations include:
priv/hash_reader.config: Controls the hash reader behavior (e.g.,search_method).priv/httpd.config: Controls the HTTP server behavior (e.g.,search_method).priv/sphinx_builder.config: Used when configuring Sphinx search integration.
- File-based Configuration: Most settings are located in