mirror of https://github.com/hashicorp/consul
snapshot: some improvments to the snapshot process
parent
5f079eb05b
commit
99c3322dc1
|
@ -1054,7 +1054,7 @@ func (s *Server) setupRaft() error {
|
|||
log = cacheStore
|
||||
|
||||
// Create the snapshot store.
|
||||
snapshots, err := raft.NewFileSnapshotStoreWithLogger(path, snapshotsRetained, s.logger.Named("snapshot"))
|
||||
snapshots, err := raft.NewFileSnapshotStoreWithLogger(path, snapshotsRetained, s.logger.Named("raft.snapshot"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ func New(logger hclog.Logger, r *raft.Raft) (*Snapshot, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create snapshot file: %v", err)
|
||||
}
|
||||
logger.Info("creating temporary file of snapshot", "path", archive.Name())
|
||||
|
||||
// If anything goes wrong after this point, we will attempt to clean up
|
||||
// the temp file. The happy path will disarm this.
|
||||
|
@ -112,7 +113,7 @@ func (s *Snapshot) Read(p []byte) (n int, err error) {
|
|||
}
|
||||
|
||||
// Close closes the snapshot and removes any temporary storage associated with
|
||||
// it. You must arrange to call this whenever NewSnapshot() has been called
|
||||
// it. You must arrange to call this whenever New() has been called
|
||||
// successfully. This is safe to call on a nil snapshot.
|
||||
func (s *Snapshot) Close() error {
|
||||
if s == nil {
|
||||
|
|
|
@ -20,7 +20,8 @@ If ACLs are enabled, a management token must be supplied in order to perform
|
|||
a snapshot save.
|
||||
|
||||
-> Note that saving a snapshot involves the server process writing the snapshot to a
|
||||
temporary file on-disk before sending that file to the CLI client. The default location
|
||||
temporary file on-disk before sending that file to the CLI client. Upon successful completion,
|
||||
the temporary file will be removed. The default location of the temporary file
|
||||
can vary depending on operating system, but typically is `/tmp`. You can get more detailed
|
||||
information on default locations in the Go documentation for [os.TempDir](https://golang.org/pkg/os/#TempDir).
|
||||
If you need to change this location, you can do so by setting the `TMPDIR` environment
|
||||
|
@ -28,6 +29,8 @@ variable for the Consul server processes. Keep in mind that setting the environm
|
|||
the CLI client attempting to perform a snapshot save will have no effect. It _must_ be set in
|
||||
the context of the server process. If you're using Systemd to manage your Consul server
|
||||
processes, then adding `Environment=TMPDIR=/path/to/dir` to your Consul unit file will work.
|
||||
Another side effect is that one snapshot file is also taken at `data_dir/raft/snapshops`,
|
||||
resulting from Raft snapshot.
|
||||
|
||||
The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of
|
||||
[blocking queries](/consul/api-docs/features/blocking) and [agent caching](/consul/api-docs/features/caching)
|
||||
|
|
Loading…
Reference in New Issue