Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
slapos
Commits
b242c335
Commit
b242c335
authored
Aug 29, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused generic.mysql recipe
parent
47fe7eb3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
360 deletions
+0
-360
setup.py
setup.py
+0
-2
slapos/recipe/generic_mysql/__init__.py
slapos/recipe/generic_mysql/__init__.py
+0
-216
slapos/recipe/generic_mysql/innobackupex.py
slapos/recipe/generic_mysql/innobackupex.py
+0
-24
slapos/recipe/generic_mysql/mysql.py
slapos/recipe/generic_mysql/mysql.py
+0
-49
slapos/recipe/generic_mysql/template/initmysql.sql.in
slapos/recipe/generic_mysql/template/initmysql.sql.in
+0
-3
slapos/recipe/generic_mysql/template/my.cnf.in
slapos/recipe/generic_mysql/template/my.cnf.in
+0
-60
slapos/recipe/generic_mysql/template/mysql-init-function.sql.in
.../recipe/generic_mysql/template/mysql-init-function.sql.in
+0
-6
No files found.
setup.py
View file @
b242c335
...
@@ -110,9 +110,7 @@ setup(name=name,
...
@@ -110,9 +110,7 @@ setup(name=name,
'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe'
,
'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe'
,
'generic.kumofs = slapos.recipe.generic_kumofs:Recipe'
,
'generic.kumofs = slapos.recipe.generic_kumofs:Recipe'
,
'generic.memcached = slapos.recipe.generic_memcached:Recipe'
,
'generic.memcached = slapos.recipe.generic_memcached:Recipe'
,
'generic.mysql = slapos.recipe.generic_mysql:Recipe'
,
'generic.mysql.wrap_update_mysql = slapos.recipe.generic_mysql:WrapUpdateMySQL'
,
'generic.mysql.wrap_update_mysql = slapos.recipe.generic_mysql:WrapUpdateMySQL'
,
'generic.mysql.wrap_mysqld = slapos.recipe.generic_mysql:WrapMySQLd'
,
'generic.varnish = slapos.recipe.generic_varnish:Recipe'
,
'generic.varnish = slapos.recipe.generic_varnish:Recipe'
,
'gitinit = slapos.recipe.gitinit:Recipe'
,
'gitinit = slapos.recipe.gitinit:Recipe'
,
'haproxy = slapos.recipe.haproxy:Recipe'
,
'haproxy = slapos.recipe.haproxy:Recipe'
,
...
...
slapos/recipe/generic_mysql/__init__.py
View file @
b242c335
...
@@ -25,206 +25,6 @@
...
@@ -25,206 +25,6 @@
#
#
##############################################################################
##############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
import
os
class
Recipe
(
GenericBaseRecipe
):
def
_options
(
self
,
options
):
options
[
'password'
]
=
self
.
generatePassword
()
if
'test-database'
in
options
:
options
[
'test-password'
]
=
self
.
generatePassword
()
options
.
setdefault
(
'parallel-test-database-amount'
,
'0'
)
for
x
in
xrange
(
int
(
options
[
'parallel-test-database-amount'
])):
options
[
'test-password-%s'
%
x
]
=
self
.
generatePassword
()
def
install
(
self
):
path_list
=
[]
template_filename
=
self
.
getTemplateFilename
(
'my.cnf.in'
)
mysql_binary
=
self
.
options
[
'mysql-binary'
]
socket
=
self
.
options
[
'socket'
]
if
'ip'
in
self
.
options
:
networking
=
'port = %s
\
n
bind-address = %s'
%
(
self
.
options
[
'port'
],
self
.
options
[
'ip'
],
)
else
:
networking
=
'skip-networking'
log_bin
=
self
.
options
.
get
(
'binlog-path'
,
''
)
if
log_bin
:
log_bin
=
'log_bin = %s'
%
log_bin
expire_logs_days
=
self
.
options
.
get
(
'binlog-expire-days'
)
if
expire_logs_days
>
0
:
expire_logs_days
=
'expire_logs_days = %s'
%
expire_logs_days
else
:
expire_logs_days
=
''
mysql_conf_file
=
self
.
createFile
(
self
.
options
[
'conf-file'
],
self
.
substituteTemplate
(
template_filename
,
{
'networking'
:
networking
,
'data_directory'
:
self
.
options
[
'data-directory'
],
'pid_file'
:
self
.
options
[
'pid-file'
],
'socket'
:
self
.
options
[
'socket'
],
'error_log'
:
self
.
options
[
'error-log'
],
'slow_query_log'
:
self
.
options
[
'slow-query-log'
],
'log_bin'
:
log_bin
,
'expire_logs_days'
:
expire_logs_days
,
})
)
path_list
.
append
(
mysql_conf_file
)
mysql_script_list
=
[]
# user defined functions
udf_registration
=
"DROP FUNCTION IF EXISTS last_insert_grn_id;
\
n
DROP FUNCTION IF EXISTS mroonga_snippet;
\
n
DROP FUNCTION IF EXISTS mroonga_command;
\
n
"
mroonga
=
self
.
options
.
get
(
'mroonga'
,
'ha_mroonga.so'
)
if
mroonga
:
udf_registration
+=
"CREATE FUNCTION last_insert_grn_id RETURNS "
\
"INTEGER SONAME '"
+
mroonga
+
"';
\
n
"
udf_registration
+=
"CREATE FUNCTION mroonga_snippet RETURNS "
\
"STRING SONAME '"
+
mroonga
+
"';
\
n
"
udf_registration
+=
"CREATE FUNCTION mroonga_command RETURNS "
\
"STRING SONAME '"
+
mroonga
+
"';
\
n
"
mysql_script_list
.
append
(
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'mysql-init-function.sql.in'
),
{
'udf_registration'
:
udf_registration
,
}
))
# real database
mysql_script_list
.
append
(
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'initmysql.sql.in'
),
{
'mysql_database'
:
self
.
options
[
'database'
],
'mysql_user'
:
self
.
options
[
'user'
],
'mysql_password'
:
self
.
options
[
'password'
]
}
))
# default test database
if
'test-database'
in
self
.
options
:
mysql_script_list
.
append
(
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'initmysql.sql.in'
),
{
'mysql_database'
:
self
.
options
[
'test-database'
],
'mysql_user'
:
self
.
options
[
'test-user'
],
'mysql_password'
:
self
.
options
[
'test-password'
]
}
))
# parallel test databases
for
x
in
xrange
(
int
(
self
.
options
[
'parallel-test-database-amount'
])):
mysql_script_list
.
append
(
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'initmysql.sql.in'
),
{
'mysql_database'
:
self
.
options
[
'mysql-test-database-base'
]
+
'_%s'
%
x
,
'mysql_user'
:
self
.
options
[
'mysql-test-user-base'
]
+
'_%s'
%
x
,
'mysql_password'
:
self
.
options
[
'test-password-%s'
%
x
]
}
))
mysql_script_list
.
append
(
'EXIT'
)
mysql_script
=
'
\
n
'
.
join
(
mysql_script_list
)
mysql_upgrade_binary
=
self
.
options
[
'mysql-upgrade-binary'
]
mysql_update
=
self
.
createPythonScript
(
self
.
options
[
'update-wrapper'
],
'%s.mysql.updateMysql'
%
__name__
,
[
dict
(
mysql_script
=
mysql_script
,
mysql_binary
=
mysql_binary
,
mysql_upgrade_binary
=
mysql_upgrade_binary
,
socket
=
socket
,
)]
)
path_list
.
append
(
mysql_update
)
mysqld
=
self
.
createPythonScript
(
self
.
options
[
'wrapper'
],
'%s.mysql.runMysql'
%
__name__
,
[
dict
(
mysql_base_directory
=
self
.
options
[
'mysql-base-directory'
],
mysql_install_binary
=
self
.
options
[
'mysql-install-binary'
],
mysqld_binary
=
self
.
options
[
'mysqld-binary'
],
data_directory
=
self
.
options
[
'data-directory'
],
mysql_binary
=
mysql_binary
,
socket
=
socket
,
configuration_file
=
mysql_conf_file
,
)]
)
path_list
.
append
(
mysqld
)
environment
=
{
'PATH'
:
self
.
options
[
'bin-directory'
]}
# TODO: move to a separate recipe (ack'ed by Cedric)
if
'backup-script'
in
self
.
options
:
# backup configuration
full_backup
=
self
.
options
[
'full-backup-directory'
]
incremental_backup
=
self
.
options
[
'incremental-backup-directory'
]
innobackupex_argument_list
=
[
self
.
options
[
'perl-binary'
],
self
.
options
[
'innobackupex-binary'
],
'--defaults-file=%s'
%
mysql_conf_file
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
'--ibbackup=%s'
%
self
.
options
[
'xtrabackup-binary'
]]
innobackupex_incremental
=
self
.
createWrapper
(
self
.
options
[
'innobackupex-incremental'
],
innobackupex_argument_list
+
[
'--incremental'
],
environment
)
path_list
.
append
(
innobackupex_incremental
)
innobackupex_full
=
self
.
createWrapper
(
self
.
options
[
'innobackupex-full'
],
innobackupex_argument_list
,
environment
)
path_list
.
append
(
innobackupex_full
)
backup_controller
=
self
.
createPythonScript
(
self
.
options
[
'backup-script'
],
__name__
+
'.innobackupex.controller'
,
[
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
])
path_list
.
append
(
backup_controller
)
# TODO: move to a separate recipe (ack'ed by Cedric)
# percona toolkit (formerly known as maatkit) installation
for
pt_script_name
in
(
'pt-align'
,
'pt-archiver'
,
'pt-config-diff'
,
'pt-deadlock-logger'
,
'pt-diskstats'
,
'pt-duplicate-key-checker'
,
'pt-fifo-split'
,
'pt-find'
,
'pt-fingerprint'
,
'pt-fk-error-logger'
,
'pt-heartbeat'
,
'pt-index-usage'
,
'pt-ioprofile'
,
'pt-kill'
,
'pt-mext'
,
'pt-mysql-summary'
,
'pt-online-schema-change'
,
'pt-pmp'
,
'pt-query-digest'
,
'pt-show-grants'
,
'pt-sift'
,
'pt-slave-delay'
,
'pt-slave-find'
,
'pt-slave-restart'
,
'pt-stalk'
,
'pt-summary'
,
'pt-table-checksum'
,
'pt-table-sync'
,
'pt-table-usage'
,
'pt-upgrade'
,
'pt-variable-advisor'
,
'pt-visual-explain'
,
):
option_name
=
pt_script_name
+
'-binary'
if
option_name
not
in
self
.
options
:
continue
pt_argument_list
=
[
self
.
options
[
'perl-binary'
],
self
.
options
[
option_name
],
'--defaults-file=%s'
%
mysql_conf_file
,
'--socket=%s'
%
socket
.
strip
(),
'--user=root'
,
]
pt_exe
=
self
.
createWrapper
(
os
.
path
.
join
(
self
.
options
[
'bin-directory'
],
pt_script_name
),
pt_argument_list
,
environment
)
path_list
.
append
(
pt_exe
)
return
path_list
class
WrapUpdateMySQL
(
GenericBaseRecipe
):
class
WrapUpdateMySQL
(
GenericBaseRecipe
):
def
install
(
self
):
def
install
(
self
):
...
@@ -239,19 +39,3 @@ class WrapUpdateMySQL(GenericBaseRecipe):
...
@@ -239,19 +39,3 @@ class WrapUpdateMySQL(GenericBaseRecipe):
}]
}]
),
),
]
]
class
WrapMySQLd
(
GenericBaseRecipe
):
def
install
(
self
):
return
[
self
.
createPythonScript
(
self
.
options
[
'output'
],
__name__
+
'.mysql.runMysql'
,
[{
'mysqld_binary'
:
self
.
options
[
'binary'
],
'configuration_file'
:
self
.
options
[
'configuration-file'
],
'data_directory'
:
self
.
options
[
'data-directory'
],
'mysql_install_binary'
:
self
.
options
[
'mysql-install-binary'
],
'mysql_base_directory'
:
self
.
options
[
'mysql-base-directory'
],
}]
),
]
slapos/recipe/generic_mysql/innobackupex.py
deleted
100644 → 0
View file @
47fe7eb3
import
os
import
glob
def
controller
(
innobackupex_incremental
,
innobackupex_full
,
full_backup
,
incremental_backup
):
"""Creates full or incremental backup
If no full backup is done, it is created
If full backup exists incremental backup is done starting with base
base is the newest (according to date) full or incremental backup
"""
if
len
(
os
.
listdir
(
full_backup
))
==
0
:
print
'Doing full backup in %r'
%
full_backup
os
.
execv
(
innobackupex_full
,
[
innobackupex_full
,
full_backup
])
else
:
backup_list
=
filter
(
os
.
path
.
isdir
,
glob
.
glob
(
full_backup
+
"/*"
)
+
glob
.
glob
(
incremental_backup
+
"/*"
))
backup_list
.
sort
(
key
=
lambda
x
:
os
.
path
.
getmtime
(
x
),
reverse
=
True
)
base
=
backup_list
[
0
]
print
'Doing incremental backup in %r using %r as a base'
%
(
incremental_backup
,
base
)
os
.
execv
(
innobackupex_incremental
,
[
innobackupex_incremental
,
'--incremental-basedir=%s'
%
base
,
incremental_backup
])
slapos/recipe/generic_mysql/mysql.py
View file @
b242c335
...
@@ -4,55 +4,6 @@ import time
...
@@ -4,55 +4,6 @@ import time
import
sys
import
sys
import
pytz
import
pytz
def
runMysql
(
conf
):
sleep
=
60
mysqld_wrapper_list
=
[
conf
[
'mysqld_binary'
],
'--defaults-file=%s'
%
conf
[
'configuration_file'
]]
# we trust mysql_install that if mysql directory is available mysql was
# correctly initalised
if
not
os
.
path
.
isdir
(
os
.
path
.
join
(
conf
[
'data_directory'
],
'mysql'
)):
while
True
:
# XXX: Protect with proper root password
# XXX: Follow http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html
popen
=
subprocess
.
Popen
([
conf
[
'mysql_install_binary'
],
'--defaults-file=%s'
%
conf
[
'configuration_file'
],
'--skip-name-resolve'
,
'--datadir=%s'
%
conf
[
'data_directory'
],
'--basedir=%s'
%
conf
[
'mysql_base_directory'
]],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
popen
.
communicate
()[
0
]
if
popen
.
returncode
is
None
or
popen
.
returncode
!=
0
:
print
"Failed to initialise server.
\
n
The error was: %s"
%
result
print
"Waiting for %ss and retrying"
%
sleep
time
.
sleep
(
sleep
)
else
:
print
"Mysql properly initialised"
break
else
:
print
"MySQL already initialised"
print
"Starting %r"
%
mysqld_wrapper_list
[
0
]
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
# try to increase the maximum number of open file descriptors.
# it seems that mysqld requires (max_connections + 810) file descriptors.
# to make it possible, you need to set the hard limit of nofile in
# /etc/security/limits.conf like the following :
# @slapsoft hard nofile 2048
try
:
import
resource
required_nofile
=
2048
# XXX hardcoded value more than 1000 + 810
nofile_limit_list
=
[
max
(
x
,
required_nofile
)
for
x
in
resource
.
getrlimit
(
resource
.
RLIMIT_NOFILE
)]
resource
.
setrlimit
(
resource
.
RLIMIT_NOFILE
,
nofile_limit_list
)
except
ImportError
:
# resource library is only available on Unix platform.
pass
except
ValueError
:
# 'ValueError: not allowed to raise maximum limit'
pass
os
.
execl
(
mysqld_wrapper_list
[
0
],
*
mysqld_wrapper_list
)
def
updateMysql
(
conf
):
def
updateMysql
(
conf
):
sleep
=
30
sleep
=
30
is_succeed
=
False
is_succeed
=
False
...
...
slapos/recipe/generic_mysql/template/initmysql.sql.in
deleted
100644 → 0
View file @
47fe7eb3
CREATE DATABASE IF NOT EXISTS %(mysql_database)s;
GRANT ALL PRIVILEGES ON %(mysql_database)s.* TO %(mysql_user)s@'%%' IDENTIFIED BY '%(mysql_password)s';
GRANT ALL PRIVILEGES ON %(mysql_database)s.* TO %(mysql_user)s@'localhost' IDENTIFIED BY '%(mysql_password)s';
slapos/recipe/generic_mysql/template/my.cnf.in
deleted
100644 → 0
View file @
47fe7eb3
# ERP5 buildout my.cnf template based on my-huge.cnf shipped with mysql
# The MySQL server
[mysqld]
# ERP5 by default requires InnoDB storage. MySQL by default fallbacks to using
# different engine, like MyISAM. Such behaviour generates problems only, when
# tables requested as InnoDB are silently created with MyISAM engine.
#
# Loud fail is really required in such case.
sql-mode="NO_ENGINE_SUBSTITUTION"
skip-show-database
%(networking)s
socket = %(socket)s
datadir = %(data_directory)s
pid-file = %(pid_file)s
log-error = %(error_log)s
slow_query_log
slow_query_log_file = %(slow_query_log)s
long_query_time = 1
max_allowed_packet = 128M
query_cache_size = 0
query_cache_type = 0
innodb_file_per_table = 0
plugin-load = ha_mroonga.so;handlersocket.so
# By default only 100 connections are allowed, when using zeo
# we may have much more connections
max_connections = 1000
# The following are important to configure and depend a lot on to the size of
# your database and the available resources.
#innodb_buffer_pool_size = 4G
#innodb_log_file_size = 256M
#innodb_log_buffer_size = 8M
# very important to allow parallel indexing
innodb_locks_unsafe_for_binlog = 1
# Some dangerous settings you may want to uncomment if you only want
# performance or less disk access. Useful for unit tests.
#innodb_flush_log_at_trx_commit = 0
#innodb_flush_method = nosync
#innodb_doublewrite = 0
#sync_frm = 0
%(log_bin)s
%(expire_logs_days)s
# Force utf8 usage
collation_server = utf8_unicode_ci
character_set_server = utf8
skip-character-set-client-handshake
[mysql]
no-auto-rehash
socket = %(socket)s
[mysqlhotcopy]
interactive-timeout
slapos/recipe/generic_mysql/template/mysql-init-function.sql.in
deleted
100644 → 0
View file @
47fe7eb3
USE mysql;
DROP FUNCTION IF EXISTS last_insert_grn_id;
DROP FUNCTION IF EXISTS mroonga_snippet;
DROP FUNCTION IF EXISTS mroonga_command;
DROP FUNCTION IF EXISTS sphinx_snippets;
%(udf_registration)s
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment