Trivial Database file under Samba (1)

Source: Internet
Author: User
Tags ibm db2

Samba uses the Trivial Database file to store both permanent and temporary data as part of its work integration file and print sharing between Linux and Windows. This article will mainly explain how Samba uses the Samba Trivial Database (TDB) format to store information, how to view the information inside the TDB file, and how to back up all the information.

Understand TDB files

At runtime, Samba stores a lot of information, from the local password to a series of clients that want to receive the information. Some of this type of data is temporary and may be discarded when Samba is restarted, but others are permanent and will not be discarded. This type of data may be large, or it may not be frequently accessed but stored in the memory or maintained during restart. To meet these requirements, the Samba team created a Trivial Database. It is actually a key-value storage, which means that data is stored and retrieved using a unique key, and there is no table join like in a relational database. Key-value storage-especially TDB-is designed as a fast way to store data to a disk and retrieve it.

Key Value Storage

Although there are many alternatives to TDB, such as GNU Database Manager (GDBM), the Samba project requires multiple processes to write data to the Database at the same time and internal fragments that support locking data. Therefore, the team built their own Database manager and called it the Trivial Database Manager. Through the cluster TDB (Clustered TDB, CTDB) project, TDB has been extended to support cluster operations and can be used in other projects.

If you are familiar with relational databases, such as IBM DB2, MySQL, or PostgreSQL, you will find that key-value storage is very simple. Relational databases may have tables that contain multiple columns, while key-value storage actually has two columns: Key column and value column. Relational databases use Structured Query Language (SQL) to extract information from multiple tables and columns. However, key-value storage is limited to key column operations.

Because of its simplicity, key-value storage is very useful for small series jobs and can execute those jobs very quickly. Key-value storage is basically a hash table on the disk, so you can guess the location of a piece of data without using indexes.

TDB is specially written to process many concurrent writers and binary data, such as internal data structures. Therefore, the fastest way to store and retrieve this data is to use the binary format. Binary storage means that database files can be smaller, and data does not need to be converted between different formats when data is moved into or out of the database.

TDB file for Samba

Samba stores its TDB files in several different places. The easiest way to find these files is to view the output of smbd-B, as shown in Listing 1.

Listing 1. Displaying smbd build information

# smbd -b...Paths:SBINDIR: /usr/sbinBINDIR: /usr/binSWATDIR: /usr/share/swatCONFIGFILE: /etc/samba/smb.confLOGFILEBASE: /var/log/sambaLMHOSTSFILE: /etc/samba/lmhostsLIBDIR: /usr/libMODULESDIR: /usr/lib/sambaSHLIBE1T: soLOCKDIR: /var/lib/sambaSTATEDIR: /var/lib/sambaCACHEDIR: /var/lib/sambaPIDDIR: /var/runSMB_PASSWD_FILE: /var/lib/samba/private/smbpasswdPRIVATE_DIR: /var/lib/samba/private

Multiple paths in Listing 1 point to the location with a TDB file. Fortunately, many of them are the same, which reduces the location you need to view. For example, LOCKDIR, STATEDIR, and CACHEDIR both point to/var/lib/samba, and PRIVATE_DIR is located in a subdirectory called Private. You can access the subdirectories and view the files you need.

TDB files can be roughly divided into two groups: persistent and temporary. Table 1 shows the names and functions of persistent files.

Table 1. Persistent TDB files

File Name Purpose
Account_policy.tdb Storage account policies, such as lock threshold and password length
Group_mapping.tdb Stores Windows NT user Identifiers (SID) and UNIX®Relationship between user IDs
Ntdrivers. tdb Store information about Printer Drivers
Ntforms. tdb Store information about the print queue format-for example, the size of the paper
Ntprinters. tdb Store information about printer initialization settings
Passdb. tdb Only used in some security modes to store authentication certificates
Registry. tdb Skeleton registry accessible through other Windows systems
Secrets. tdb Stores local secrets, such as workstation computer keys and creden similar to Lightweight Directory Access Protocol (LDAP) passwords
Pai_info.tdb For each local shared storage Access Control List (ACL) Information
Winbindd_idmap.tdb If you are using winbind, You can persistently store the ing information between Windows nt sid and dynamically created users.

The TDB file shown in table 1 should be backed up. This document provides the procedure for this operation.

In addition, there are many temporary TDB files that store status information and cache data. Because these files are rebuilt at Samba startup, you do not need to back up them.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.