GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing docs.voltdb.com — 16.3. VoltDB Export Connectors Using VoltDB16.3. VoltDB Export ConnectorsYou use the EXPORT TO TARGET or MIGRATE TO TARGET clauses to identify the sources of export and start queuing export
data. To enable the actual transmission of data to an export target at runtime, you include the In the configuration file, the deployment:
export:
configurations:
- target: log
enabled: true
type: file
- target: archive
enabled: true
type: fileYou configure each export connector by specifying properties as one or more list elements to the
deployment:
export:
configurations:
- target: log
enabled: true
type: file
properties:
- name: type
value: csv
- name: nonce
value: MyExportThe properties that are allowed and/or required depend on the export connector you select. VoltDB comes with five export connectors:
16.3.1. How Export WorksTwo important points about export to keep in mind are:
All nodes in a cluster queue export data, but only one actually writes to the external target. If one or more nodes fail, responsibility for writing to the export targets is transferred to another currently active server. It is possible for gaps to appear in the export queues while servers are offline. Normally if a gap is found, it is not a problem because another node can take over responsibility for writing (and queuing) export data. However, in unusual cases where export falls behind and nodes fail and rejoin consecutively, it is possible for gaps to occur in all the available queues. When this happens, VoltDB issues a warning to the console (and via SNMP) and waits for the missing data to be resolved. You can also use the @Statistics system procedure with the EXPORT selector to determine exactly what records are and are not present in the queues. If the gap cannot be resolved (usually by rejoining a failed server), you must use the voltadmin export release command to free the queue and resume export at the next available record. 16.3.1.1. Export OverflowVoltDB uses persistent files on disk to queue export data waiting to be written to its specified target. If for any reason the export target can not keep up with the connector, VoltDB writes the excess data in the export buffer from memory to disk. This protects your database in several ways:
Even when the target does keep up with the flow, some amount of data is written to the overflow directory to
ensure durability across database sessions. You can specify where VoltDB writes the overflow export data using the
deployment:
paths:
exportoverflow:
path: /tmp/export/If you do not specify a path for export overflow, VoltDB creates a subfolder in the database root directory. See Section 3.7.2, “Configuring Paths for Runtime Features” for more information about configuring paths in the configuration. 16.3.1.2. Persistence Across Database SessionsIt is important to note that VoltDB only uses the disk storage for overflow data. However, you can force VoltDB to write all queued export data to disk using any of the following methods:
This means that if you perform an orderly shutdown with the voltadmin shutdown command, you can recover the database — and any pending export queue data — by simply restarting the database cluster in the same root directories. Note that when you initialize or re-initialize a root directory, any subdirectories of the root are purged.[5] So if your configuration did not specify a different location for the export overflow, and you re-initialize the root directories and then restore the database from a snapshot, the database is restored but the export overflow will be lost. If both your original and new configuration use the same, explicit directory outside the root directory for export overflow, you can start a new database and restore a snapshot without losing the overflow data. 16.3.2. The File Export ConnectorThe file connector receives the serialized data from the export source and writes it out as text files (either comma or tab separated) to disk. The file connector writes the data out one file per source table or stream, "rolling" over to new files periodically. The filenames of the exported data are constructed from:
While the file is being written, the file name also contains the prefix "active-". Once the file is complete and a new file started, the "active-" prefix is removed. Therefore, any export files without the prefix are complete and can be copied, moved, deleted, or post-processed as desired. There is only one required property that must be set when using the file connector. The Table 16.1, “File Export Properties” describes the supported properties for the file connector. Table 16.1. File Export Properties
Whatever properties you choose, the order and representation of the content within the output files is the same. The export connector writes a separate line of data for every INSERT it receives, including the following information:
Table 16.2, “Export Metadata” describes the six columns of metadata generated by the export connector and the meaning of each column. Table 16.2. Export Metadata
16.3.3. The HTTP Export ConnectorThe HTTP connector receives the serialized data from the export streams and writes it out via HTTP requests. The connector is designed to be flexible enough to accommodate most potential targets. For example, the connector can be configured to send out individual records using a GET request or batch multiple records using POST and PUT requests. The connector also contains optimizations to support export to Hadoop via WebHDFS. 16.3.3.1. Understanding HTTP PropertiesThe HTTP connector is a general purpose export utility that can export to any number of destinations from simple messaging services to more complex REST APIs. The properties work together to create a consistent export process. However, it is important to understand how the properties interact to configure your export correctly. The four key properties you need to consider are:
The properties are described in detail in Table 16.3, “HTTP Export Properties”. This section explains the relationship between the properties. There are essentially two types of HTTP export: batch mode and one record at a time. Batch mode is appropriate for exporting large volumes of data to targets such as Hadoop. Exporting one record at a time is less efficient for large volumes but can be very useful for writing intermittent messages to other services. In batch mode, the data is exported using a POST or PUT method, where multiple records are combined in either
comma-separated value (CSV) or Avro format in the body of the request. When writing one record at a time, you can choose
whether to submit the HTTP request as a POST, PUT or GET (that is, as a querystring attached to the URL). When exporting
in batch mode, the method must be either Finally, the endpoint property specifies the target URL where data is being sent, using either the http: or https: protocol. Again, the endpoint must be compatible with the possible settings for the other properties. In particular, if the endpoint is a WebHDFS URL, batch mode must enabled. The URL can also contain placeholders that are filled in at runtime with metadata associated with the export data. Each placeholder consists of a percent sign (%) and a single ASCII character. The following are the valid placeholders for the HTTP endpoint property:
When exporting in batch mode, the endpoint must contain at least one instance each of the %t, %p, and %g placeholders. However, beyond that requirement, it can contain as many placeholders as desired and in any order. When not in batch mode, use of the placeholders are optional. Table 16.3, “HTTP Export Properties” describes the supported properties for the HTTP connector. Table 16.3. HTTP Export Properties
16.3.3.2. Exporting to Hadoop via WebHDFSAs mentioned earlier, the HTTP connector contains special optimizations to support exporting data to Hadoop via the WebHDFS protocol. If the endpoint property contains a WebHDFS URL (identified by the URL path component starting with the string "/webhdfs/v1/"), special rules apply. First, for WebHDFS URLs, the batch.mode property must be enabled. Also, the endpoint must have at least one instance each of the source name (%t), the partition ID (%p), and the export generation (%g) placeholders and those placeholders must be part of the URL path, not the domain or querystring. Next, the method property is ignored. For WebHDFS, the HTTP connector uses a combination of POST, PUT, and GET requests to perform the necessary operations using the WebHDFS REST API. For example, The following configuration file exports stream data to WebHDFS using the HTTP connector and writing each stream to a separate directory, with separate files based on the partition ID, generation, and period timestamp, rolling over every 2 hours: deployment:
export:
configurations:
- target: hadoop
enabled: true
type: http
properties:
- name: endpoint
value: "http://myhadoopsvr/webhdfs/v1/%t/data%p-%g.%d.csv"
- name: batch.mode
value: true
- name: period
value: 2Note that the HTTP connector will create any directories or files in the WebHDFS endpoint path that do not currently exist and then append the data to those files, using the POST or PUT method as appropriate for the WebHDFS REST API. You also have a choice between two formats for the export data when using WebHDFS: comma-separated values (CSV)
and Apache Avro™ format. By default, data is written as CSV data with each record on a separate line and batches of
records attached as the contents of the HTTP request. However, you can choose to set the output format to Avro by
setting the deployment:
export:
configurations:
- target: hadoop
enabled: true
type: http
properties:
- name: endpoint
value: "http://myhadoopsvr/webhdfs/v1/%t/data%p-%g.%d.avro"
- name: type
value: avro
- name:avro.compress
value: true
- name: avro.schema.location
value: "http://myhadoopsvr/webhdfs/v1/%t/schema.json"Avro is a data serialization system that includes a binary format that is used natively by Hadoop utilities such
as Pig and Hive. Because it is a binary format, Avro data takes up less network bandwidth than text-based formats such
as CSV. In addition, you can choose to compress the data even further by setting the When you select Avro as the output format, VoltDB writes out an accompanying schema definition as a JSON document. For compatibility purposes, the source name and columns names are converted, removing underscores and changing the resulting words to lowercase with initial capital letters (sometimes called "camelcase"). The source name is given an initial capital letter, while columns names start with a lowercase letter. For example, the stream EMPLOYEE_DATA and its column named EMPLOYEE_iD would be converted to EmployeeData and employeeId in the Avro schema. By default, the Avro schema is written to a local file on the VoltDB database server. However, you can specify an
alternate location, including a webHDFS URL. So, for example, you can store the schema in the same HDFS repository as
the data by setting the See the Apache Avro web site for more details on the Avro format. 16.3.3.3. Exporting to Hadoop Using Kerberos SecurityIf the WebHDFS service to which you are exporting data is configured to use Kerberos security, the VoltDB servers must be able to authenticate using Kerberos as well. To do this, you must perform the following two extra steps:
The first step is to configure the VoltDB servers to use Kerberos as described in Section 13.9, “Integrating Kerberos Security with VoltDB”. Because use of Kerberos authentication for VoltDB security changes how the clients connect to the database cluster, It is best to set up, enable, and test Kerberos authentication first to ensure your client applications work properly in this environment before trying to enable Kerberos export as well. Once you have Kerberos authentication working for the VoltDB cluster, you can enable Kerberos authentication in
the configuration of the WebHDFS export target as well. Enabling Kerberos authentication in the HTTP connector only
requires one additional property, deployment:
export:
configurations:
- target: hadoop
enabled: true
type: http
properties:
- name: endpoint
value: "myhadoopsvr/webhdfs/v1/%t/data%p-%g.%d.csv"
- name: type
value: csv
- name: kerberos.enable
value: trueNote that Kerberos authentication is only supported for WebHDFS endpoints. 16.3.4. The JDBC Export ConnectorThe JDBC connector receives the serialized data from the export source and writes it, in batches, to another database through the standard JDBC (Java Database Connectivity) protocol. By default, when the JDBC connector opens the connection to the remote database, it first attempts to create tables in the remote database to match the VoltDB export source by executing CREATE TABLE statements through JDBC. This is important to note because, it ensures there are suitable tables to receive the exported data. The tables are created using either the names from the VoltDB schema or (if you do not enable the ignoregenerations property) the name prefixed by the database generation ID. If the target database has existing tables that match the VoltDB export sources in both name and structure (that is, the number, order, and datatype of the columns), be sure to enable the ignoregenerations property in the export configuration to ensure that VoltDB uses those tables as the export target. It is also important to note that the JDBC connector exports data through JDBC in batches. That is, multiple INSERT instructions are passed to the target database at a time, in approximately two megabyte batches. There are two consequences of the batching of export data:
To avoid errors causing batch inserts to fail, it is strongly recommended that the target database not use unique indexes on the receiving tables that might cause constraint violations. If any errors do occur when the JDBC connector attempts to submit data to the remote database, the VoltDB disconnects and then retries the connection. This process is repeated until the connection succeeds. If the connection does not succeed, VoltDB eventually reduces the retry rate to approximately every eight seconds. Table 16.4, “JDBC Export Properties” describes the supported properties for the JDBC connector. Table 16.4. JDBC Export Properties
16.3.5. The Kafka Export ConnectorThe Kafka connector receives serialized data from the export sources and writes it to a message queue using the Apache Kafka version 0.10.2 protocols. Apache Kafka is a distributed messaging service that lets you set up message queues which are written to and read from by "producers" and "consumers", respectively. In the Apache Kafka model, VoltDB export acts as a "producer" capable of writing to any Kafka service using version 0.10.2 or later. Before using the Kafka connector, we strongly recommend reading the Kafka documentation and becoming familiar with the software, since you will need to set up a Kafka service and appropriate "consumer" clients to make use of VoltDB's Kafka export functionality. The instructions in this section assume a working knowledge of Kafka and the Kafka operational model. When the Kafka connector receives data from the VoltDB export sources, it establishes a connection to the Kafka messaging service as a Kafka producer. It then writes records to Kafka topics based on the VoltDB stream or table name and certain export connector properties. The majority of the Kafka export properties are identical in both in name and content to the Kafka producer
properties listed in the Kafka documentation. All but one of these properties are optional for the Kafka connector and
will use the standard Kafka default value. For example, if you do not specify the
The only required property is In addition to the standard Kafka producer properties, there are several custom properties specific to VoltDB. The
properties The Employee.EmpTopic,Company.CoTopic,Enterprise.EntTopic Any mappings in the Note that unless you configure the Kafka brokers with the When configuring the Kafka export connector, it is important to understand the relationship between synchronous versus asynchronous processing and its effect on database latency. If the export data is sent asynchronously, the impact of export on the database is reduced, since the export connector does not wait for the Kafka infrastructure to respond. However, with asynchronous processing, VoltDB is not able to resend the data if the message fails after it is sent. If export to Kafka is done synchronously, the export connector waits for acknowledgement of each message sent to Kafka before processing the next packet. This allows the connector to resend any packets that fail. The drawback to synchronous processing is that on a heavily loaded database, the latency it introduces means export may not be able to keep up with the influx of export data and and have to write to overflow. You specify the level of synchronicity and durability of the connection using the Kafka VoltDB guarantees that at least one copy of all export data is sent by the export connector. But when operating in asynchronous mode, the Kafka connector cannot guarantee that the packet is actually received and accepted by the Kafka broker. By operating in synchronous mode, VoltDB can catch errors returned by the Kafka broker and resend any failed packets. However, you pay the penalty of additional latency and possible export overflow. Finally, the actual export data is sent to Kafka as a comma-separated values (CSV) formatted string. The message includes six columns of metadata (such as the transaction ID and timestamp) followed by the column values of the export stream. Table 16.5, “Kafka Export Properties” lists the supported properties for the Kafka connector, including the standard Kafka producer properties and the VoltDB unique properties. Table 16.5. Kafka Export Properties
16.3.6. The Elasticsearch Export ConnectorThe Elasticsearch connector receives serialized data from the export source and inserts it into an Elasticsearch server or cluster. Elasticsearch is an open-source full-text search engine built on top of Apache Lucene™. By exporting selected tables and streams from your VoltDB database to Elasticsearch you can perform extensive full-text searches on the data not possible with VoltDB alone. Before using the Elasticsearch connector, we recommend reading the Elasticsearch documentation and becoming familiar with the software. The instructions in this section assume a working knowledge of Elasticsearch, its configuration and its capabilities. The only required property when configuring Elasticsearch is the endpoint, which identifies the location of the Elasticsearch server and what index to use when inserting records into the target system. The structure of the Elasticsearch endpoint is the following: <protocol>://<server>:<port>//<index-name>//<type-name> For example, if the target Elasticsearch service is on the server properties:
- name: endpoint
value: http://esearch.lan:9200/employees/personYou can use placeholders in the endpoint that are replaced at runtime with information from the export data, such as the source name (%t), the partition ID (%p), the export generation (%g), and the date and hour (%d). For example, to use the source name as the index name, the endpoint might look like the following: properties:
- name: endpoint
value: "http://esearch.lan:9200/%t/person"When you export to Elasticsearch, the export connector creates the necessary index names and types in Elasticsearch (if they do not already exist) and inserts each record as a separate document with the appropriate metadata. Table 16.6, “Elasticsearch Export Properties” lists the supported properties for the Elasticsearch connector. Table 16.6. Elasticsearch Export Properties
[5] Initializing a root directory deletes any files in the command log and overflow directories. The snapshots directory is archived to a named subdirectory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||