Backup Strategies and MySQL Management in IMT3003

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/117

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

118 Terms

1
New cards

Backup

Backup er enkelt, viktig, men kan bli dyrt, med lite fokus på restore.

2
New cards

Backup media

Typer media som brukes for backup inkluderer Tape, disk, og Optisk.

3
New cards

Hjemmelaget / kjøpt

Refererer til om backup-løsningen er utviklet internt eller kjøpt fra en leverandør.

4
New cards

Rutiner / Backup plan

Planlegging og prosedyrer for hvordan backup skal utføres.

5
New cards

Mengde data

Refererer til volumet av data som skal tas backup av.

6
New cards

Båndbredde

Kapasiteten for dataoverføring som påvirker hastigheten på backup.

7
New cards

Applikasjoner med egne dataformater

Programmer som har spesifikke formater for lagring av data som kan påvirke backup.

8
New cards

Corpus

Datamengden som skal bli tatt backup av.

9
New cards

Endringsrate (change rate)

Hvor mye av corpus har endret seg mellom hver gang backup tas.

10
New cards

Backup vindu

Det tidsrommet vi kan ta backup.

11
New cards

Snapshot

En lokal kopi tas for backup, slik at corpus kan endre seg underveis.

12
New cards

Lokal / Remote

Refererer til hvor backup skal være plassert.

13
New cards

Medium

Hvor dataene lagres.

14
New cards

Partiell backup

Backup av deler av corpus, for eksempel en del hver dag.

15
New cards

Inkrementell backup

Backup av endringene siden sist, forutsetter en full backup tidligere.

16
New cards

Full backup

En komplett kopi av hele corpus som må tas regelmessig.

17
New cards

Linux verktøy for backup

Gode løsninger for backup inkluderer tar + gz, rsync, scp, og cp -al.

18
New cards

tar + gz

Lag en gzip av en hel mappe.

19
New cards

rsync

Synkroniserer to mapper, gjerne over SSH.

20
New cards

scp

Bruker SSH til å flytte filer.

21
New cards

cp -al

Tar kopi, men lager bare ny inode og bruker ikke mer plass før den originale filen endrer seg.

22
New cards

Error-log

Inneholder feilsituasjoner og om mysqld serveren har blitt startet/stoppet. Var egen logfil, men mange automatiske installasjoner lar den peke rett mot /var/log/syslog.

23
New cards

Query log

Inneholder en lang log over ALLE spørringer, gruppert på forbindelser til databasen. Inneholder også tidspunkt for forbindelsens start og stopp, men ikke hvor lang tid hver enkelt spørring tok. Er ikke skrudd på til vanlig.

24
New cards

Binær-log

En viktig bestanddel av MySQL sin mulighet til å ta backup / restore. Kun operasjoner som forandrer data blir lagret og først etter at de er fullført. Filen er på et binært format for raskest mulig skriving og lesing /var/log/mysql/mysql-bin.xxxxxx. Filen mysql-bin.index holder orden. Bruk kommandoen mysqlbinlog til å lese den.

25
New cards

Slow (langsom) query log

Inneholder alle queries som varer lengre enn det som er spesifisert i long_query_time = X.

26
New cards

Logfil vedlikehold

Linux vil automatisk rotere log-filene for oss hver natt, maks syv netter. Binær-logfiler roteres, men ikke på samme ukentlige sirkel. Man kan fremprovosere en ny binær-log fil med kommandoen mysqladmin flush-logs.

27
New cards

MySQL Backup

Når man lager en backup-strategi, er det viktigst å spørre seg om hvordan man vil kunne gjenopprette data. Backup i MySQL består av det å dumpe data og å ta vare på logfiler.

28
New cards

Situasjoner hvor ekstra backup er nødvendig

Før man skal oppgradere / gjøre store endringer. Etter feil som er blitt gjort av sysadmin. Etter ondsinnede kommandoer har blitt kjørt, f.eks delete * from posts. Etter tap av maskinvare eller planlagt migrering til ny server.

29
New cards

mysqldump

Vanligste verktøyet til å ta backup av en database og alt dets innhold. Skriver ut alt som SQL-kode med tanke på at du en gang kanskje vil bruke den til å gjenopprette databasen. Backup skrives til skjerm, må omdirigeres til fil.

30
New cards

mysqldump

A command-line utility for creating backups of MySQL databases.

31
New cards

Selective backup of databases

Backing up only specific databases or tables instead of all.

32
New cards

mysqldump [options] database [tables]

Command format for backing up a single database.

33
New cards

mysqldump [options] --databases db1 db2 db3

Command format for backing up multiple specified databases.

34
New cards

mysqldump [options] --all-databases

Command format for backing up all databases.

35
New cards

--add-drop-table

Option to include commands that drop tables before recreating them.

36
New cards

--add-locks

Option to add locks around each table restoration.

37
New cards

--create-options

Option to include all MySQL options when creating tables.

38
New cards

--disable-keys

Option to not optimize the index after each tuple is added.

39
New cards

--extended-insert

Option for optimizing insert operations.

40
New cards

--lock-tables

Option to lock all tables before the dump.

41
New cards

--quick

Option to not load everything into memory before writing it out.

42
New cards

--set-charset

Option to include a command to set the same character set.

43
New cards

--opt

Option that enables all the options discussed so far.

44
New cards

--master-data=2

Includes the last position and file number in the binary log file.

45
New cards

--flush-logs

Switches to a new binary log file right after the lock is taken.

46
New cards

mysqldump example

Typical backup command: mysqldump --opt --master-data=2 --flush-logs --all-databases > backup.sql.

47
New cards

backup.sql

File containing everything needed to restore the database.

48
New cards

Restore command

Command to restore the database from backup.sql: cat backup.sql | mysql.

49
New cards

mysqlbinlog

Utility to read binary log files and output SQL code.

50
New cards

Restore from mysqlbinlog

To restore, output must be sent to the MySQL server: mysqlbinlog mysql-bin.* | mysql.

51
New cards

--stop-datetime="date"

Option to stop processing the log before a specific date.

52
New cards

--start-datetime="date"

Option to start processing the log from a specific date.

53
New cards

--database=db

Option to restrict the output to a specific database.

54
New cards

--start-position=n

Option to start processing the log from a specific position.

55
New cards

--stop-position=n

Option to stop processing the log before a specific position.

56
New cards

mysqlbinlog

A command-line utility for processing MySQL binary log files.

57
New cards

stop-position

A parameter used with mysqlbinlog to stop processing at a specified position in the binary log.

58
New cards

start-position

A parameter used with mysqlbinlog to start processing from a specified position in the binary log.

59
New cards

restore from mysqldump

The process of restoring a database from a dump file created by mysqldump, which also writes changes to the binary log.

60
New cards

SET sql_log_bin=0

A command that can be added to the top of a backup.sql file to prevent logging of the restore operation in the binary log.

61
New cards

mysqladmin flush-logs

A command used to flush the MySQL logs, ensuring that all logs are written and can be rotated.

62
New cards

full backup

A complete copy of the database at a specific point in time, typically performed at regular intervals.

63
New cards

incremental backup

A backup that includes only the changes made since the last backup, allowing for more frequent backups.

64
New cards

binlog.sql

A file that contains the output of mysqlbinlog, which can be edited to remove unwanted commands before being executed on the database.

65
New cards

logrotate

A system utility that automatically manages the rotation of log files, including MySQL binary logs.

66
New cards

mysqldump

A command-line utility for creating backups of MySQL databases by exporting them to a dump file.

67
New cards

server-id

A unique identifier for a MySQL server instance, required for replication and remote access.

68
New cards

remote server

A server that is accessed over a network, allowing for operations like mysqldump and mysqlbinlog to be executed from a different machine.

69
New cards

binary log

A log file that records all changes to the database, which can be used for recovery and replication.

70
New cards

backup strategy

A plan outlining how and when backups are performed, including frequency and methods of backup.

71
New cards

flush logs

The action of clearing or writing out the current logs to disk, ensuring all data is saved.

72
New cards

restore process

The series of steps taken to recover a database from backups and binary logs.

73
New cards

bin-log files

Files that contain the binary log data, which can be processed to recover changes made to the database.

74
New cards

edit binlog.sql

The action of modifying the binlog.sql file to remove specific commands before executing it on the database.

75
New cards

data retrieval

The process of obtaining data from a database, which can be done remotely using mysqldump.

76
New cards

disk protection

Measures taken to safeguard against data loss due to disk failure, especially when backups and logs are stored on the same machine.

77
New cards

Bootstrapping images

The process of using a bootstrap script to pass configuration parameters to container images.

78
New cards

Environment variables

Variables that processes can check in a Linux system, which can be passed to a Docker container when starting it.

79
New cards

Checking current environment variables

Use the command 'set' to check the current environment variables in a Linux system.

80
New cards

Example: Alternative config.php

A PHP script that retrieves environment variables using getenv() for database configuration.

81
New cards

Running a container with environment variables

Use the command 'docker run -e BF_DB_HOST=10.10.0.X -e BF_DB=bf -e BF_USER=bfuser ... mybookface_image:tag' to start a container with specified environment variables.

82
New cards

Docker Swarm

A mode in Docker where multiple servers are connected to collaborate in running containers.

83
New cards

Docker Swarm Mode

A configuration where a swarm consists of one or more managers and multiple nodes.

84
New cards

Creating a swarm

Install Docker on all involved servers and run 'docker swarm init' on the master server.

85
New cards

Node join command

A command that allows other nodes to join the Docker swarm after obtaining the token from the master server.

86
New cards

Checking status of nodes

Use 'docker node ls' to see if all nodes are connected in the swarm.

87
New cards

Changing node availability

Use 'docker node update --availability active ' to change a node's availability.

88
New cards

Removing containers from a node

Use 'docker node update --availability drain node-2' to remove all containers from node-2.

89
New cards

Creating services from containers

A service in Docker consists of one or more instances from the same image, providing benefits like load balancing and fail-over.

90
New cards

Creating a service

Run 'docker service create [options] [image]' to create a service in Docker.

91
New cards

Service options

Options like '--replicas=X' and '--name=xyz' can be used when creating a service.

92
New cards

Example of creating a service

Use 'docker service create -d --replicas=3 --name=hello -p 3000:80 tutum/hello-world' to create a service.

93
New cards

Listing all services

Use 'docker service ls' to list all services in the Docker swarm.

94
New cards

Checking service status

Check the status of a service to determine how it is performing.

95
New cards

docker service ps service-name

Command to list tasks of a service in Docker.

96
New cards

docker service scale name=replicas

Command to increase or decrease the number of replicas (instances) of a service.

97
New cards

Docker Compose

A tool for defining and running multi-container Docker applications.

98
New cards

docker-compose.yml

File where Docker Compose configurations are defined.

99
New cards

docker-compose up [-d]

Command to start the containers defined in a docker-compose.yml file.

100
New cards

docker ps

Command to check the status of running containers.