Skip to content

Commit 4f33953

Browse files
Add files via upload
1 parent f2fd168 commit 4f33953

File tree

6 files changed

+886
-0
lines changed

6 files changed

+886
-0
lines changed

bgbackup.cnf

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
############################################
2+
3+
# bgbackup configuration file
4+
5+
# Check for Percona backup history records to migrate?
6+
# If yes, be warned that backups which meet the current
7+
# delete threshold will be deleted. Backups which have
8+
# already been deleted will be marked with deleted_at
9+
# as today's date.
10+
checkmigrate=no
11+
12+
# Day of week to do full backup. Set to "Everyday" to do full backup everyday (subsequent daily backups will be incremental)
13+
fullbackday=Everyday
14+
15+
# Differential does incremental backup based on the last full backup instead of last full or incremental
16+
differential=no
17+
18+
# Number of full backups to keep
19+
keepnum=10
20+
21+
#s3 bucket name
22+
s3bucket=
23+
24+
#s3 command tool
25+
s3cmd=/usr/bin/s3cmd
26+
27+
# Number of backup table backups to keep.
28+
keepbkuptblnum=1
29+
30+
#Full path of xtrabackup command
31+
innobackupex=/encrypted_data/mysql/software/innobackupex
32+
33+
# Full path to backup directory root
34+
backupdir=/backup-hhc/xtradbbackup
35+
36+
# Path to keep logs
37+
logpath=/encrypted_data/mysql/log
38+
39+
#Backup history Schema
40+
backuphistschema=xtrabackup_history
41+
42+
# Log verbosity
43+
verbose=no
44+
45+
# Log to syslog
46+
syslog=no
47+
48+
# Backup type (directory or archive)
49+
bktype=archive
50+
51+
# Archive type (tar or xbstream) for archive backup type
52+
arctype=xbstream
53+
54+
# Used for parallel and compress
55+
threads=5
56+
57+
# Use parallel threads for backup?
58+
parallel=yes
59+
60+
# Encrypt backup?
61+
encrypt=yes
62+
63+
# Full path to encryption key
64+
cryptkey=/encrypted_data/mysql/conf/backupscript.key
65+
66+
# Compress backup?
67+
compress=yes
68+
69+
# Compression utility used for archives, for now gzip or pigz (parallel gzip) are supported
70+
# For standalone directories, qpress is always used
71+
computil=gzip
72+
73+
74+
# By default, xtrabackup will lock all tables to create a consistent backup of non-transactional
75+
# tables. Enabled nolock to disable this behaviour.
76+
# WARNING: Only disable locking if you do not have or do not care about your non-transactional tables.
77+
nolock=no
78+
79+
# Include Galera info and enable wsrep_desync to avoid flow control during backup.
80+
# When the backup is finished, wait for wsrep_local_recv_queue to drop to 0 before
81+
# disabling wsrep_desync.
82+
galera=yes
83+
84+
# Include slave info?
85+
# WARNING: If slave info is included and nolock is enabled, bgbackup will enable safe-slave-backup.
86+
# (safe slave backups will temporarily pause replication. Please inspect the documentation if your application cannot handle stale reads.)
87+
slave=no
88+
89+
# Comma separated list of email address to be notified.
90+
maillist=
91+
92+
# Email subject prefix
93+
mailsubpre="[Xtra Backup]"
94+
95+
# Email (all or failure)
96+
mailon=all
97+
98+
# Run command(s) after backup, for example: run_on_success=/usr/local/bin/success.sh
99+
# (leave empty if you do not want to run anything)
100+
# If backup succedded
101+
run_after_success=
102+
# If backup failed
103+
run_after_fail=
104+
105+
# Debug prints all variables to the commandline when script is ran.
106+
# This can be a security risk. Set to yes to enable.
107+
debug=no
108+
109+
############################################

my.cnf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# my.cnf: Managed by puppet
2+
3+
[client]
4+
socket = /encrypted_data/mysql/data/mysql.sock
5+
6+
[mysqld]
7+
basedir = /encrypted_data/mysql/xtradbcluster
8+
binlog-checksum = CRC32
9+
binlog_format = ROW
10+
binlog_order_commits = 1
11+
binlog_row_image = minimal
12+
character_set_server = utf8
13+
collation_server = utf8_general_ci
14+
datadir = /encrypted_data/mysql/data
15+
default_password_lifetime = 0
16+
default_storage_engine = InnoDB
17+
eq_range_index_dive_limit = 5000
18+
expire_logs_days = 2
19+
general_log_file = /encrypted_data/mysql/log/general_log.log
20+
ignore-db-dir = 'lost+found'
21+
init_connect = 'SET autocommit=0'
22+
innodb_adaptive_hash_index = 0
23+
innodb_autoinc_lock_mode = 2
24+
innodb_buffer_pool_size = 18G
25+
innodb_data_file_path = ibdata1:10M:autoextend
26+
innodb_data_home_dir = /encrypted_data/mysql/innodb
27+
innodb_flush_method = O_DIRECT
28+
innodb_log_buffer_size = 128M
29+
innodb_log_file_size = 10G
30+
innodb_log_files_in_group = 2
31+
innodb_log_group_home_dir = /encrypted_data/mysql/innodb
32+
innodb_sort_buffer_size = 2097152
33+
innodb_stats_on_metadata = 0
34+
innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:2048M
35+
innodb_track_changed_pages = 1
36+
innodb_undo_directory = /encrypted_data/mysql/undo
37+
key_buffer_size = 402653184
38+
log-error = /encrypted_data/mysql/log/mysqld.log
39+
log_bin = /encrypted_data/mysql/binlog/mysql-bin.log
40+
log_bin_index = /encrypted_data/mysql/binlog/mysql-bin
41+
log_error_verbosity = 3
42+
log_slave_updates = 1
43+
log_timestamps = system
44+
master-verify-checksum = 1
45+
max_allowed_packet = 16M
46+
max_connections = 4000
47+
open_files_limit = 40000
48+
optimizer_switch = 'derived_merge=off'
49+
pid-file = /encrypted_data/mysql/data/mysqld.pid
50+
port = 3306
51+
pxc_strict_mode = PERMISSIVE
52+
read_buffer_size = 2097152
53+
read_rnd_buffer_size = 8388608
54+
server_id = 3
55+
skip_external_locking = 1
56+
skip_name_resolve = 1
57+
slow_query_log = false
58+
slow_query_log_file = /encrypted_data/mysql/log/slow_log.log
59+
socket = /encrypted_data/mysql/data/mysql.sock
60+
sort_buffer_size = 2097152
61+
sql_mode = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,REAL_AS_FLOAT,IGNORE_SPACE
62+
symbolic-links = 0
63+
sync_binlog = 1
64+
table-definition-cache = 20000
65+
table-open-cache-instances = 16
66+
table_open_cache = 20000
67+
thread_cache_size = 2000
68+
thread_handling = pool-of-threads
69+
tmpdir = /encrypted_data/mysql/tmp
70+
transaction_isolation = READ-COMMITTED
71+
user = mysql
72+
wsrep_cluster_address = gcomm://a,b,c
73+
wsrep_cluster_name = abcd
74+
wsrep_log_conflicts = 1
75+
wsrep_node_address = a.b.c.d
76+
wsrep_node_name = abcd-node-3
77+
wsrep_provider = /encrypted_data/mysql/xtradbcluster/lib/libgalera_smm.so
78+
wsrep_provider_options = 'gcache.size=512M;evs.inactive_check_period=PT15S;evs.inactive_timeout=PT60S;evs.suspect_timeout=PT60S;gmcast.peer_timeout=PT60S'
79+
wsrep_slave_threads = 8
80+
wsrep_sst_auth = user@pwd
81+
wsrep_sst_method = xtrabackup-v2
82+
83+
[xtrabackup]
84+
target_dir = /encrypted_data/mysql/backup
85+

mysql_logrotate

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/encrypted_data/mysql/log/slow_log.log /encrypted_data/mysql/log/mysqld.log{
2+
create 600 mysql mysql
3+
daily
4+
rotate 10
5+
missingok
6+
compress
7+
sharedscripts
8+
postrotate
9+
if test -x /usr/bin/mysqladmin &&
10+
env HOME=/root /usr/bin/mysqladmin --login-path=logrotate ping > /dev/null 2>&1
11+
then
12+
env HOME=/root/ /usr/bin/mysql --login-path=logrotate -e 'select @@global.long_query_time into @lqt_save; set global long_query_time=2000; set global slow_query_log=0; select sleep(2); FLUSH ERROR LOGS; FLUSH SLOW LOGS;select sleep(2); set global long_query_time=@lqt_save; set global slow_query_log=1;' > /var/log/mysqladmin.flush-logs 2>&1
13+
fi
14+
endscript
15+
}
16+

mysql_script_running_halo.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# This script uses mysqldump to backup all the databases except 'bkp' and 'test' databases.
3+
# This script also uses mysqldump to backup all the tables in the databases.
4+
# The script creates a backup destination folder for each day, the folder name is like 'yyyymmdd',
5+
# The MySQLDump output will be compressed using bzip2
6+
# The script deletes any files and sub-folders older than defined days in the backup folder
7+
# The cronjob line is like this: 10 2 * * * /root/mysql_bkp.sh >/var/log/hhc-mysql-bkp.log 2>&1
8+
. /etc/profile
9+
suffix=$1
10+
dest=/backup-hhc/$1
11+
cmd1=$(which mysql)
12+
hostname=$(hostname --short)
13+
encpswd=`cat /root/.encpswd`
14+
input_file=/backup-hhc/temp.sql
15+
if [ $2 = 'ALL' ]
16+
then
17+
databases=$(echo 'show databases;' | ${cmd1} --login-path=local | grep -i halo)
18+
19+
for d in ${databases[@]}
20+
do
21+
if [[ $d != 'information_schema' && $d != 'performance_schema' && $d != 'test' && $d != 'mysql' && $d != 'refman_hcprdtmplt_1024480_20170822' ]]
22+
then
23+
24+
path="${dest}/${hostname}"
25+
mkdir -p ${path}
26+
27+
timestamp=`date +%Y%b%d-%T`
28+
while read line; do
29+
echo -e "$line" >> $path/$d.csv
30+
${cmd1} $d -e "$line" | sed 's/\t/,/g' >>$path/$d.csv
31+
echo "" >> $path/$d.csv
32+
done < $input_file
33+
34+
fi
35+
done
36+
else
37+
while read line; do
38+
echo -e "$line" >> $path/$dest.csv
39+
${cmd1} $2 -e "$line" | sed 's/\t/,/g' >>$dest.csv
40+
echo "" >> $path/$dest.csv
41+
done < $input_file
42+
fi

mysql_script_running_refman.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# This script uses mysqldump to backup all the databases except 'bkp' and 'test' databases.
3+
# This script also uses mysqldump to backup all the tables in the databases.
4+
# The script creates a backup destination folder for each day, the folder name is like 'yyyymmdd',
5+
# The MySQLDump output will be compressed using bzip2
6+
# The script deletes any files and sub-folders older than defined days in the backup folder
7+
# The cronjob line is like this: 10 2 * * * /root/mysql_bkp.sh >/var/log/hhc-mysql-bkp.log 2>&1
8+
. /etc/profile
9+
suffix=$1
10+
dest=/backup-hhc/$1
11+
cmd1=$(which mysql)
12+
hostname=$(hostname --short)
13+
input_file=/backup-hhc/temp.sql
14+
if [ $2 = 'ALL' ]
15+
then
16+
databases=$(echo 'show databases;' | ${cmd1} --login-path=local | grep -i refman)
17+
18+
for d in ${databases[@]}
19+
do
20+
if [[ $d != 'information_schema' && $d != 'performance_schema' && $d != 'test' && $d != 'mysql' && $d != 'refman_hcprdtmplt_1024480_20170822' ]]
21+
then
22+
23+
path="${dest}/${hostname}"
24+
mkdir -p ${path}
25+
26+
timestamp=`date +%Y%b%d-%T`
27+
while read line; do
28+
echo -e "$line" >> $path/$d.csv
29+
${cmd1} $d -e "$line" | sed 's/\t/,/g' >>$path/$d.csv
30+
echo "" >> $path/$d.csv
31+
done < $input_file
32+
33+
fi
34+
done
35+
else
36+
while read line; do
37+
echo -e "$line" >> $path/$dest.csv
38+
${cmd1} $2 -e "$line" | sed 's/\t/,/g' >>$dest.csv
39+
echo "" >> $path/$dest.csv
40+
done < $input_file
41+
fi

0 commit comments

Comments
 (0)