Skip to content

Commit

Permalink
Merge pull request #1657 from druid-io/backport-for-0-8-1-rc2
Browse files Browse the repository at this point in the history
Merge fixes for 0.8.1 rc2
  • Loading branch information
fjy committed Aug 22, 2015
2 parents d9adc9c + 66230bc commit 8dc6eda
Show file tree
Hide file tree
Showing 20 changed files with 509 additions and 100 deletions.
86 changes: 86 additions & 0 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Druid - a distributed column store.
~ Copyright 2012 - 2015 Metamarkets Group Inc.
~
~ Licensed 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<packaging>pom</packaging>

<artifactId>distribution</artifactId>
<name>distribution</name>
<description>distribution</description>

<parent>
<artifactId>druid</artifactId>
<groupId>io.druid</groupId>
<version>0.8.1-rc2-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>io.druid</groupId>
<artifactId>druid-services</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>io.druid</groupId>
<artifactId>extensions-distribution</artifactId>
<version>${project.parent.version}</version>
<classifier>extensions-repo</classifier>
<type>zip</type>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.parent.artifactId}-${project.parent.version}</finalName>
<tarLongFileMode>posix</tarLongFileMode>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<executions>
<execution>
<id>download-licenses</id>
<goals>
<goal>download-licenses</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
~ limitations under the License.
-->

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>bin</id>
<formats>
<format>tar.gz</format>
Expand Down Expand Up @@ -105,9 +105,18 @@
</fileSets>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>true</useTransitiveDependencies>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>io.druid:extensions-distribution</exclude>
</excludes>
</dependencySet>
<dependencySet>
<unpack>true</unpack>
<includes>
<include>io.druid:extensions-distribution</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
2 changes: 1 addition & 1 deletion docs/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ These properties specify the jdbc connection and other configuration around the

|Property|Description|Default|
|--------|-----------|-------|
|`druid.metadata.storage.type`|The type of metadata storage to use. Choose from "mysql", "postgres", or "derby".|derby|
|`druid.metadata.storage.type`|The type of metadata storage to use. Choose from "mysql", "postgresql", or "derby".|derby|
|`druid.metadata.storage.connector.connectURI`|The jdbc uri for the database to connect to|none|
|`druid.metadata.storage.connector.user`|The username to connect with.|none|
|`druid.metadata.storage.connector.password`|The password to connect with.|none|
Expand Down
150 changes: 118 additions & 32 deletions docs/content/dependencies/metadata-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,125 @@ layout: doc_page
---
# Metadata Storage

The Metadata Storage is an external dependency of Druid. We use it to store various metadata about the system, but not to store the actual data. There are a number of tables used for various purposes described below.
The Metadata Storage is an external dependency of Druid. Druid uses it to store
various metadata about the system, but not to store the actual data. There are
a number of tables used for various purposes described below.

Supported Metadata Storages
---------------------------
## Supported Metadata Storages

The following metadata storages are supported:
The following metadata storage engines are supported:

* Derby (default - only works if you have all processes running on the same node)
* MySQL (io.druid.extensions:mysql-metadata-storage)
* PostgreSQL (io.druid.extensions:postgresql-metadata-storage)

To choose a metadata storage to use, set the `druid.extensions` config to include the module for the metadata storage.
To choose a metadata storage, set the `druid.extensions` configuration to
include the extension for the metadata storage you plan to use.


## Set up MySQL
## Setting up MySQL

1. If you don't already have it, download MySQL Community Server here: [http://dev.mysql.com/downloads/mysql/](http://dev.mysql.com/downloads/mysql/).
2. Install MySQL.
3. Create a druid user and database.
1. Install MySQL

```bash
mysql -u root
```
Use your favorite package manager to install mysql, e.g.:
- on Ubuntu/Debian using apt `apt-get install mysql-server`
- on OS X, using [Homebrew](http://brew.sh/) `brew install mysql`

```sql
GRANT ALL ON druid.* TO 'druid'@'localhost' IDENTIFIED BY 'diurd';
CREATE DATABASE druid DEFAULT CHARACTER SET utf8;
```
Alternatively, download and follow installation instructions for MySQL
Community Server here:
[http://dev.mysql.com/downloads/mysql/](http://dev.mysql.com/downloads/mysql/)

2. Create a druid database and user

Connect to MySQL from the machine where it is installed.

```bash
> mysql -u root
```

Paste the following snippet into the mysql prompt:

```sql
-- create a druid database, make sure to use utf8 as encoding
CREATE DATABASE druid DEFAULT CHARACTER SET utf8;

-- create a druid user, and grant it all permission on the database we just created
GRANT ALL ON druid.* TO 'druid'@'localhost' IDENTIFIED BY 'diurd';
```

3. Configure your Druid metadata storage extension:

Add the following parameters to your Druid configuration, replacing `<host>`
with the hostname of the database.

```properties
druid.extensions.coordinates=[\"io.druid.extensions:mysql-metadata-storage"]
druid.metadata.storage.type=mysql
druid.metadata.storage.connector.connectURI=jdbc:mysql://<host>/druid_test
druid.metadata.storage.connector.user=druid
druid.metadata.storage.connector.password=diurd
```

## Setting up PostgreSQL

1. Install PostgreSQL

Use your favorite package manager to install PostgreSQL, e.g.:
- on Ubuntu/Debian using apt `apt-get install postgresql`
- on OS X, using [Homebrew](http://brew.sh/) `brew install postgresql`

2. Create a druid database and user

On the machine where PostgreSQL is installed, using an account with proper
postgresql permissions:

Create a druid user, enter `diurd` when prompted for the password.

```bash
createuser druid -P
```

Create a druid database owned by the user we just created

```bash
createdb druid -O druid
```

*Note:* On Ubuntu / Debian you may have to prefix the `createuser` and
`createdb` commands with `sudo -u postgres` in order to gain proper
permissions.

3. Configure your Druid metadata storage extension:

Add the following parameters to your Druid configuration, replacing `<host>`
with the hostname of the database.

```properties
druid.extensions.coordinates=[\"io.druid.extensions:postgresql-metadata-storage"]
druid.metadata.storage.type=postgresql
druid.metadata.storage.connector.connectURI=jdbc:postgresql://<host>/druid_test
druid.metadata.storage.connector.user=druid
druid.metadata.storage.connector.password=diurd
```

## Metadata Storage Tables

Segments Table
--------------
### Segments Table

This is dictated by the `druid.metadata.storage.tables.segments` property.

This table stores metadata about the segments that are available in the system. The table is polled by the [Coordinator](../design/coordinator.html) to determine the set of segments that should be available for querying in the system. The table has two main functional columns, the other columns are for indexing purposes.
This table stores metadata about the segments that are available in the system.
The table is polled by the [Coordinator](../design/coordinator.html) to
determine the set of segments that should be available for querying in the
system. The table has two main functional columns, the other columns are for
indexing purposes.

The `used` column is a boolean "tombstone". A 1 means that the segment should be "used" by the cluster (i.e. it should be loaded and available for requests). A 0 means that the segment should not be actively loaded into the cluster. We do this as a means of removing segments from the cluster without actually removing their metadata (which allows for simpler rolling back if that is ever an issue).
The `used` column is a boolean "tombstone". A 1 means that the segment should
be "used" by the cluster (i.e. it should be loaded and available for requests).
A 0 means that the segment should not be actively loaded into the cluster. We
do this as a means of removing segments from the cluster without actually
removing their metadata (which allows for simpler rolling back if that is ever
an issue).

The `payload` column stores a JSON blob that has all of the metadata for the segment (some of the data stored in this payload is redundant with some of the columns in the table, that is intentional). This looks something like

Expand All @@ -62,22 +144,26 @@ The `payload` column stores a JSON blob that has all of the metadata for the seg

Note that the format of this blob can and will change from time-to-time.

Rule Table
----------
### Rule Table

The rule table is used to store the various rules about where segments should land. These rules are used by the [Coordinator](../design/coordinator.html) when making segment (re-)allocation decisions about the cluster.
The rule table is used to store the various rules about where segments should
land. These rules are used by the [Coordinator](../design/coordinator.html)
when making segment (re-)allocation decisions about the cluster.

Config Table
------------
### Config Table

The config table is used to store runtime configuration objects. We do not have many of these yet and we are not sure if we will keep this mechanism going forward, but it is the beginnings of a method of changing some configuration parameters across the cluster at runtime.
The config table is used to store runtime configuration objects. We do not have
many of these yet and we are not sure if we will keep this mechanism going
forward, but it is the beginnings of a method of changing some configuration
parameters across the cluster at runtime.

Task-related Tables
-------------------
### Task-related Tables

There are also a number of tables created and used by the [Indexing Service](../design/indexing-service.html) in the course of its work.
There are also a number of tables created and used by the [Indexing
Service](../design/indexing-service.html) in the course of its work.

Audit Table
-----------
### Audit Table

The Audit table is used to store the audit history for configuration changes e.g rule changes done by [Coordinator](../design/coordinator.html) and other config changes.
The Audit table is used to store the audit history for configuration changes
e.g rule changes done by [Coordinator](../design/coordinator.html) and other
config changes.
11 changes: 7 additions & 4 deletions docs/content/development/approximate-histograms.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ especially with long tails, since that's where the approximation will be worse.

### Creating approxiate histogram sketches at ingestion time

To use this feature, an "approxHistogram" aggregator must be included at
indexing time. The ingestion aggregator can only apply to numeric values. To
query for results, an "approxHistogramFold" aggregator must be included in the
To use this feature, an "approxHistogram" or "approxHistogramFold" aggregator must be included at
indexing time. The ingestion aggregator can only apply to numeric values. If you use "approxHistogram"
then any input rows missing the value will be considered to have a value of 0, while with "approxHistogramFold"
such rows will be ignored.

To query for results, an "approxHistogramFold" aggregator must be included in the
query.

```json
{
"type" : "approxHistogram(ingestion), approxHistogramFold(query)",
"type" : "approxHistogram or approxHistogramFold (at ingestion time), approxHistogramFold (at query time)",
"name" : <output_name>,
"fieldName" : <metric_name>,
"resolution" : <integer>,
Expand Down
2 changes: 1 addition & 1 deletion docs/content/misc/cluster-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Sizing for Cores and RAM

The Historical and Broker nodes will use as many cores as are available, depending on usage, so it is best to keep these on dedicated machines. The upper limit of effectively utilized cores is not well characterized yet and would depend on types of queries, query load, and the schema. Historical daemons should have a heap a size of at least 1GB per core for normal usage, but could be squeezed into a smaller heap for testing. Since in-memory caching is essential for good performance, even more RAM is better. Broker nodes will use RAM for caching, so they do more than just route queries.

The effective utilization of cores by Zookeeper, MySQL, and Coordinator nodes is likely to be between 1 and 2 for each process/daemon, so these could potentially share a machine with lots of cores. These daemons work with heap a size between 500MB and 1GB.
The effective utilization of cores by Zookeeper, metadata storage, and Coordinator nodes is likely to be between 1 and 2 for each process/daemon, so these could potentially share a machine with lots of cores. These daemons work with heap a size between 500MB and 1GB.

Storage
-------
Expand Down
2 changes: 1 addition & 1 deletion docs/content/tutorials/tutorial-a-first-look-at-druid.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Druid requires 3 external dependencies.

* A "deep storage" that acts as a data repository. This is generally distributed storage like HDFS or S3. For prototyping or experimentation on a single machine, Druid can use the local filesystem.

* A "metadata storage" to hold configuration and metadata information. This is generally a small, shared database like MySQL or Postgres. For prototyping or experimentation on a single machine, Druid can use a local instance of [Apache Derby](http://db.apache.org/derby/).
* A "metadata storage" to hold configuration and metadata information. This is generally a small, shared database like MySQL or PostgreSQL. For prototyping or experimentation on a single machine, Druid can use a local instance of [Apache Derby](http://db.apache.org/derby/).

* [Apache Zookeeper](http://zookeeper.apache.org/) for coordination among different pieces of the cluster.

Expand Down
2 changes: 1 addition & 1 deletion docs/content/tutorials/tutorial-the-druid-cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cd druid-<version>
## External Dependencies
Druid requires 3 external dependencies.
* A "deep storage" that acts as a data repository. This is generally distributed storage like HDFS or S3. For prototyping or experimentation on a single machine, Druid can use the local filesystem.
* A "metadata storage" to hold configuration and metadata information. This is generally a small, shared database like MySQL or Postgres. For prototyping or experimentation on a single machine, Druid can use a local instance of [Apache Derby](http://db.apache.org/derby/).
* A "metadata storage" to hold configuration and metadata information. This is generally a small, shared database like MySQL or PostgreSQL. For prototyping or experimentation on a single machine, Druid can use a local instance of [Apache Derby](http://db.apache.org/derby/).
* [Apache Zookeeper](http://zookeeper.apache.org/) for coordination among different pieces of the cluster.

For deep storage, we will use the local disk in this tutorial, but for production, HDFS and S3 are popular options. For the metadata storage, Derby is used in this tutorial, but for production MySQL or PostgreSQL etc should be used.
Expand Down
37 changes: 37 additions & 0 deletions examples/bin/run_druid_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set +e
set +u
shopt -s xpg_echo
shopt -s expand_aliases
trap "exit 1" 1 2 3 15

SCRIPT_DIR=`dirname $0`
MAVEN_DIR="${SCRIPT_DIR}/extensions-repo"
SERVER_TYPE="$1"

if [ "x${SERVER_TYPE}" = "x" ]
then
echo "usage: $0 server-type" >& 2
exit 2
fi

if [[ ! -d "${SCRIPT_DIR}/lib" || ! -d "${SCRIPT_DIR}/config" ]]; then
echo "This script appears to be running from the source location. It must be run from its deployed location."
echo "After building, unpack services/target/druid-services-*-SNAPSHOT-bin.tar.gz, and run the script unpacked there."
exit 2
fi

CURR_DIR=`pwd`
cd ${SCRIPT_DIR}
SCRIPT_DIR=`pwd`
cd ${CURR_DIR}

# start process
JAVA_ARGS="${JAVA_ARGS} -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8"
JAVA_ARGS="${JAVA_ARGS} -Ddruid.extensions.localRepository=${MAVEN_DIR}"

DRUID_CP="${SCRIPT_DIR}/config/_common"
DRUID_CP="${DRUID_CP}:${SCRIPT_DIR}/config/$SERVER_TYPE"
DRUID_CP="${DRUID_CP}:${SCRIPT_DIR}/lib/*"

exec java ${JAVA_ARGS} -classpath "${DRUID_CP}" io.druid.cli.Main server "$SERVER_TYPE"
Loading

0 comments on commit 8dc6eda

Please sign in to comment.