jojochuang commented on code in PR #8740: URL: https://github.com/apache/ozone/pull/8740#discussion_r2320023927
########## hadoop-hdds/docs/content/concept/RocksDB.md: ########## @@ -0,0 +1,161 @@ +--- +title: "RocksDB in Apache Ozone" +menu: + main: + parent: Architecture +--- + +<!--- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +> Note: This page covers advanced topics. Ozone administrators typically do not need to tinker with these settings. + +RocksDB is a critical component of Apache Ozone, providing a high-performance embedded key-value store. It is used by various Ozone services to persist metadata and state. + +## 1. Introduction to RocksDB + +RocksDB is a log-structured merge-tree (LSM-tree) based key-value store developed by Facebook. It is optimized for fast storage environments like SSDs and offers high write throughput and efficient point lookups. For more details, refer to the [RocksDB GitHub project](https://github.com/facebook/rocksdb) and the [RocksDB Wiki](https://github.com/facebook/rocksdb/wiki). + +## 2. How Ozone uses RocksDB + +RocksDB is utilized in the following Ozone components to store critical metadata: + +* **Ozone Manager (OM):** The OM uses RocksDB as its primary metadata store, holding the entire namespace and related information. As defined in `OMDBDefinition.java`, this includes tables for: + * **Namespace:** `volumeTable`, `bucketTable`, `keyTable` (for object store layout), `directoryTable`, and `fileTable` (for file system layout). + * **Security:** `userTable`, `dTokenTable` (delegation tokens), and `s3SecretTable`. + * **State Management:** `transactionInfoTable` for tracking transactions, `deletedTable` for pending key deletions, and `snapshotInfoTable` for managing Ozone snapshots. + +* **Storage Container Manager (SCM):** The SCM persists the state of the storage layer in RocksDB. The structure, defined in `SCMDBDefinition.java`, includes tables for: + * `pipelines`: Manages the state and composition of data pipelines. + * `containers`: Stores information about all storage containers in the cluster. + * `deletedBlocks`: Tracks blocks that are marked for deletion and awaiting garbage collection. + * `move`: Coordinates container movements for data rebalancing. + * `validCerts`: Stores certificates for validating datanodes. + * `validSCMCerts`: Stores certificates for validating SCMs. + * `scmTransactionInfos`: Tracks SCM transactions. + * `sequenceId`: Manages sequence IDs for various SCM operations. + * `meta`: Stores miscellaneous SCM metadata, like upgrade status. + * `statefulServiceConfig`: Stores configurations for stateful services. + +* **Datanode:** A Datanode utilizes RocksDB for two main purposes: + 1. **Per-Volume Metadata:** It maintains one RocksDB instance per storage volume. Each of these instances manages metadata for the containers and blocks stored on that specific volume. As specified in `DatanodeSchemaThreeDBDefinition.java`, this database is structured with column families for `block_data`, `metadata`, `delete_txns`, `finalize_blocks`, and `last_chunk_info`. To optimize performance, it uses a fixed-length prefix based on the container ID, enabling efficient lookups with RocksDB's prefix seek feature. + 2. **Global Container Tracking:** Additionally, each Datanode has a single, separate RocksDB instance to record the set of all containers it manages. This database, defined in `WitnessedContainerDBDefinition.java`, contains a `ContainerCreateInfoTable` table that provides a complete index of the containers hosted on that Datanode. + +* **Recon:** Ozone's administration and monitoring tool, Recon, maintains its own RocksDB database to store aggregated and historical data for analysis. The `ReconDBDefinition.java` outlines tables for: + * `containerKeyTable`: Maps containers to the keys they contain. + * `namespaceSummaryTable`: Stores aggregated namespace information for quick reporting. + * `replica_history`: Tracks the historical locations of container replicas, which is essential for auditing and diagnostics. + * `keyContainerTable`: Maps keys to the containers they are in. + * `containerKeyCountTable`: Stores the number of keys in each container. + * `replica_history_v2`: Tracks the historical locations of container replicas with BCSID, which is essential for auditing and diagnostics. + +## 3. Tunings applicable to RocksDB + +Effective tuning of RocksDB can significantly impact Ozone's performance. Ozone exposes several configuration properties to tune RocksDB behavior. These properties are typically found in `ozone-default.xml` and can be overridden in `ozone-site.xml`. + +### General Settings + +Ozone provides a set of general RocksDB configurations that apply to all services (OM, SCM, and Datanodes) unless overridden by more specific settings. With the exception of `hdds.db.profile` and `ozone.metastore.rocksdb.cf.write.buffer.size`, these properties are defined in `RocksDBConfiguration.java`. + +* `hdds.db.profile`: Specifies the RocksDB profile to use, which determines the default `DBOptions` and `ColumnFamilyOptions`. Default value: `DISK`. + * Possible values include `SSD` and `DISK`. + * For example, setting this to `SSD` will apply tunings optimized for SSD storage. + +* **Write Options:** + * `hadoop.hdds.db.rocksdb.writeoption.sync`: If set to `true`, writes are synchronized to persistent storage, ensuring durability at the cost of performance. If `false`, writes are flushed asynchronously. Default: `false`. + +* `ozone.metastore.rocksdb.cf.write.buffer.size`: The write buffer (memtable) size for each column family of the rocksdb store. Default: `128MB`. + +* **Write-Ahead Log (WAL) Management:** + * `hadoop.hdds.db.rocksdb.WAL_ttl_seconds`: The time-to-live for WAL files in seconds. Default: `1200`. + * `hadoop.hdds.db.rocksdb.WAL_size_limit_MB`: The total size limit for WAL files in megabytes. When this limit is exceeded, the oldest WAL files are deleted. A value of `0` means no limit. Default: `0`. + +* **Logging:** + * `hadoop.hdds.db.rocksdb.logging.enabled`: Enables or disables RocksDB's own logging. Default: `false`. + * `hadoop.hdds.db.rocksdb.logging.level`: The logging level for RocksDB (INFO, DEBUG, WARN, ERROR, FATAL). Default: `INFO`. + * `hadoop.hdds.db.rocksdb.max.log.file.size`: The maximum size of a single RocksDB log file. Default: `100MB`. + * `hadoop.hdds.db.rocksdb.keep.log.file.num`: The maximum number of RocksDB log files to retain. Default: `10`. + +### Ozone Manager (OM) Specific Settings + +These settings, defined in `ozone-default.xml`, apply specifically to the Ozone Manager. + +* `ozone.om.db.max.open.files`: The total number of files that a RocksDB can open in the OM. Default: `-1` (unlimited). +* `ozone.compaction.service.enabled`: Enable or disable a background job that periodically compacts rocksdb tables flagged for compaction. Default: `false`. Review Comment: HDDS-13525 is merged and so updated this PR to reflect the change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
