mirror of https://github.com/status-im/consul.git
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"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -25,11 +26,12 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
serfLANSnapshot = "serf/local.snapshot"
|
||||
serfWANSnapshot = "serf/remote.snapshot"
|
||||
raftState = "raft/"
|
||||
snapshotsRetained = 2
|
||||
raftDBSize = 128 * 1024 * 1024 // Limit Raft log to 128MB
|
||||
serfLANSnapshot = "serf/local.snapshot"
|
||||
serfWANSnapshot = "serf/remote.snapshot"
|
||||
raftState = "raft/"
|
||||
snapshotsRetained = 2
|
||||
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,
|
||||
|
@ -243,8 +245,16 @@ func (s *Server) setupRaft() error {
|
|||
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
|
||||
store, err := raftmdb.NewMDBStoreWithSize(path, raftDBSize)
|
||||
store, err := raftmdb.NewMDBStoreWithSize(path, dbSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,14 +8,16 @@ import (
|
|||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
dbNodes = "nodes"
|
||||
dbServices = "services"
|
||||
dbChecks = "checks"
|
||||
dbKVS = "kvs"
|
||||
dbMaxMapSize = 512 * 1024 * 1024 // 512MB maximum size
|
||||
dbNodes = "nodes"
|
||||
dbServices = "services"
|
||||
dbChecks = "checks"
|
||||
dbKVS = "kvs"
|
||||
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
|
||||
|
@ -96,8 +98,16 @@ func (s *StateStore) initialize() error {
|
|||
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
|
||||
if err := s.env.SetMapSize(dbMaxMapSize); err != nil {
|
||||
if err := s.env.SetMapSize(dbSize); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue