diff --git a/tsdb/config.go b/tsdb/config.go index e25108915c..ab203b066f 100644 --- a/tsdb/config.go +++ b/tsdb/config.go @@ -51,7 +51,7 @@ const ( type Config struct { Dir string `toml:"dir"` Engine string `toml:"-"` - Index string `toml:"-"` + Index string `toml:"index-version"` // General WAL configuration options WALDir string `toml:"wal-dir"` diff --git a/tsdb/index.go b/tsdb/index.go index 0244c53a78..d3b5edf07a 100644 --- a/tsdb/index.go +++ b/tsdb/index.go @@ -76,12 +76,12 @@ func RegisteredIndexes() []string { // If the path does not exist then the DefaultFormat is used. func NewIndex(id uint64, path string, options EngineOptions) (Index, error) { // Create a new index. - if _, err := os.Stat(path); os.IsNotExist(err) { + if _, err := os.Stat(path); os.IsNotExist(err) && options.Config.Index != "inmem" { return newIndexFuncs[options.IndexVersion](id, path, options), nil } // Use default format. - format := DefaultIndex + format := options.Config.Index // Lookup index by format. fn := newIndexFuncs[format] diff --git a/tsdb/index/tsi1/index.go b/tsdb/index/tsi1/index.go index 26b1e295c4..3d16016192 100644 --- a/tsdb/index/tsi1/index.go +++ b/tsdb/index/tsi1/index.go @@ -14,6 +14,12 @@ import ( "github.com/influxdata/influxdb/tsdb" ) +func init() { + tsdb.RegisterIndex("tsi1", func(id uint64, path string, opt tsdb.EngineOptions) tsdb.Index { + return &Index{Path: path} + }) +} + // File extensions. const ( LogFileExt = ".tsi.log" diff --git a/tsdb/shard.go b/tsdb/shard.go index d50ce87a32..acffbce873 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -245,6 +245,11 @@ func (s *Shard) Open() error { // Initialize underlying index. ipath := filepath.Join(s.path, "index") + // Create directory. + if err := os.MkdirAll(ipath, 0700); err != nil { + return err + } + idx, err := NewIndex(s.id, ipath, s.options) if err != nil { return err