mirror of
https://github.com/status-im/consul.git
synced 2025-01-11 06:16:08 +00:00
consul: Increase DB size on 64bit systems. Fixes #81.
This commit is contained in:
parent
e6e4f7c410
commit
2dd0d80274
@ -11,6 +11,7 @@ import (
|
|||||||
"net/rpc"
|
"net/rpc"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -25,11 +26,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
serfLANSnapshot = "serf/local.snapshot"
|
serfLANSnapshot = "serf/local.snapshot"
|
||||||
serfWANSnapshot = "serf/remote.snapshot"
|
serfWANSnapshot = "serf/remote.snapshot"
|
||||||
raftState = "raft/"
|
raftState = "raft/"
|
||||||
snapshotsRetained = 2
|
snapshotsRetained = 2
|
||||||
raftDBSize = 128 * 1024 * 1024 // Limit Raft log to 128MB
|
raftDBSize32bit uint64 = 128 * 1024 * 1024 // Limit Raft log to 128MB
|
||||||
|
raftDBSize64bit uint64 = 8 * 1024 * 1024 * 1024 // Limit Raft log to 8GB
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is Consul server which manages the service discovery,
|
// Server is Consul server which manages the service discovery,
|
||||||
@ -243,8 +245,16 @@ func (s *Server) setupRaft() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the maximum raft size based on 32/64bit. Since we are
|
||||||
|
// doing an mmap underneath, we need to limit our use of virtual
|
||||||
|
// address space on 32bit, but don't have to care on 64bit.
|
||||||
|
dbSize := raftDBSize32bit
|
||||||
|
if runtime.GOARCH == "amd64" {
|
||||||
|
dbSize = raftDBSize64bit
|
||||||
|
}
|
||||||
|
|
||||||
// Create the MDB store for logs and stable storage
|
// Create the MDB store for logs and stable storage
|
||||||
store, err := raftmdb.NewMDBStoreWithSize(path, raftDBSize)
|
store, err := raftmdb.NewMDBStoreWithSize(path, dbSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,16 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
dbNodes = "nodes"
|
dbNodes = "nodes"
|
||||||
dbServices = "services"
|
dbServices = "services"
|
||||||
dbChecks = "checks"
|
dbChecks = "checks"
|
||||||
dbKVS = "kvs"
|
dbKVS = "kvs"
|
||||||
dbMaxMapSize = 512 * 1024 * 1024 // 512MB maximum size
|
dbMaxMapSize32bit uint64 = 512 * 1024 * 1024 // 512MB maximum size
|
||||||
|
dbMaxMapSize64bit uint64 = 32 * 1024 * 1024 * 1024 // 32GB maximum size
|
||||||
)
|
)
|
||||||
|
|
||||||
// The StateStore is responsible for maintaining all the Consul
|
// The StateStore is responsible for maintaining all the Consul
|
||||||
@ -96,8 +98,16 @@ func (s *StateStore) initialize() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the maximum db size based on 32/64bit. Since we are
|
||||||
|
// doing an mmap underneath, we need to limit our use of virtual
|
||||||
|
// address space on 32bit, but don't have to care on 64bit.
|
||||||
|
dbSize := dbMaxMapSize32bit
|
||||||
|
if runtime.GOARCH == "amd64" {
|
||||||
|
dbSize = dbMaxMapSize64bit
|
||||||
|
}
|
||||||
|
|
||||||
// Increase the maximum map size
|
// Increase the maximum map size
|
||||||
if err := s.env.SetMapSize(dbMaxMapSize); err != nil {
|
if err := s.env.SetMapSize(dbSize); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user