luban-mysql 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/luban/deployment/packages/mysql/base.rb +46 -0
- data/lib/luban/deployment/packages/mysql/configurator.rb +14 -0
- data/lib/luban/deployment/packages/mysql/controller.rb +78 -0
- data/lib/luban/deployment/packages/mysql/installer.rb +62 -0
- data/lib/luban/deployment/packages/mysql/paths.rb +81 -0
- data/lib/luban/deployment/packages/mysql/templates/my.cnf.erb +101 -0
- data/lib/luban/deployment/packages/mysql/templates/myadmin.cnf.erb +11 -0
- data/lib/luban/deployment/packages/mysql/templates/mysql.logrotate.erb +19 -0
- data/lib/luban/deployment/packages/mysql/templates/mysql.monitrc.erb +10 -0
- data/lib/luban/deployment/packages/mysql/version.rb +9 -0
- data/lib/luban/deployment/packages/mysql.rb +7 -0
- data/lib/luban/mysql.rb +1 -0
- data/lib/luban-mysql.rb +0 -0
- data/luban-mysql.gemspec +28 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d11a0ca321f1d170bf940db2c3a59645e28299f0
|
4
|
+
data.tar.gz: b48a2c25359d04a8918948b7e613f0a526b1e2d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb1cde05f458f8f7f80d5a2ba1d0191efa77e339399d8167fa486035bb211a3455f8bb1db41a2eef4ba7f4d0b4c6f35950cfb3876ac08881373f546a404f5939
|
7
|
+
data.tar.gz: 4dd787661584d8eef15a899538fcb21ae60b66a9c828ed81a02c4fc10e9ca7b6b7ed9ddb1c7bfc290dd7918fb0428bfbe47af41f5f81bc6d9d5034cecf379a4e
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Chi Man Lei
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Luban::Mysql
|
2
|
+
|
3
|
+
Luban deployment package to manage MySQL installation, deployment and control
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'luban-mysql'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install luban-mysql
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mysql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
34
|
+
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
39
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "luban/mysql"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Luban
|
2
|
+
module Deployment
|
3
|
+
module Packages
|
4
|
+
class Mysql < Luban::Deployment::Service::Base
|
5
|
+
def default_templates_path
|
6
|
+
@default_templates_path ||= Pathname.new(File.join(File.dirname(__FILE__), 'templates')).realpath
|
7
|
+
end
|
8
|
+
|
9
|
+
%i(reload_process reopen_logs ping_process).each do |action|
|
10
|
+
service_action action, dispatch_to: :controller
|
11
|
+
end
|
12
|
+
|
13
|
+
def decompose_version(version)
|
14
|
+
vers = version.split('.')
|
15
|
+
{ major_version: "#{vers[0]}.#{vers[1]}", patch_level: vers[2] }
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def setup_install_tasks
|
21
|
+
super
|
22
|
+
commands[:install].option :dist, "Binary distribution"
|
23
|
+
end
|
24
|
+
|
25
|
+
def setup_control_tasks
|
26
|
+
super
|
27
|
+
|
28
|
+
task :reload do
|
29
|
+
desc "Reload process"
|
30
|
+
action! :reload_process
|
31
|
+
end
|
32
|
+
|
33
|
+
task :reopen do
|
34
|
+
desc "Reopen log files"
|
35
|
+
action! :reopen_logs
|
36
|
+
end
|
37
|
+
|
38
|
+
task :ping do
|
39
|
+
desc "Ping process"
|
40
|
+
action! :ping_process
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Luban
|
2
|
+
module Deployment
|
3
|
+
module Packages
|
4
|
+
class Mysql
|
5
|
+
class Configurator < Luban::Deployment::Service::Configurator
|
6
|
+
include Paths
|
7
|
+
include Controller::Commands
|
8
|
+
|
9
|
+
alias_method :log_file_path, :general_log_file_path
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Luban
|
2
|
+
module Deployment
|
3
|
+
module Packages
|
4
|
+
class Mysql
|
5
|
+
class Controller < Luban::Deployment::Service::Controller
|
6
|
+
module Commands
|
7
|
+
def self.included(base)
|
8
|
+
base.define_executable 'mysqld_safe'
|
9
|
+
base.define_executable 'mysqladmin'
|
10
|
+
end
|
11
|
+
|
12
|
+
def mysqld_safe_command
|
13
|
+
@mysqld_safe_command ||= "#{mysqld_safe_executable} --defaults-file=#{control_file_path}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def mysqldadmin_command
|
17
|
+
@mysqldadmin_command ||= "#{mysqladmin_executable} --defaults-file=#{admin_control_file_path}"
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :start_command, :mysqld_safe_command
|
21
|
+
alias_method :process_pattern, :mysqld_safe_command
|
22
|
+
|
23
|
+
def start_command
|
24
|
+
@start_command ||= "#{mysqld_safe_command}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def stop_command
|
28
|
+
@stop_command ||= "kill $(cat #{pid_file_path} 2>/dev/null)"
|
29
|
+
end
|
30
|
+
|
31
|
+
def ping_command
|
32
|
+
@ping_command ||= "#{mysqldadmin_command} ping"
|
33
|
+
end
|
34
|
+
|
35
|
+
def reopen_logs_command
|
36
|
+
@reopen_logs_command ||= "#{mysqldadmin_command} flush-logs #{log_types.join(' ')}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def log_types
|
40
|
+
@log_types ||= %w(error general slow)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
include Paths
|
45
|
+
include Commands
|
46
|
+
|
47
|
+
%w(reload_process reopen_logs ping_process).each do |method|
|
48
|
+
define_method(method) do
|
49
|
+
update_result send("#{method}!")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def default_pending_interval; 5; end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def start_process!
|
58
|
+
within install_path do
|
59
|
+
capture(:nohup, "#{start_command} >/dev/null 2>&1 &")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def reload_process!
|
64
|
+
capture("kill -HUP $(cat #{pid_file_path} 2>/dev/null) 2>&1")
|
65
|
+
end
|
66
|
+
|
67
|
+
def reopen_logs!
|
68
|
+
capture("#{reopen_logs_command} 2>&1")
|
69
|
+
end
|
70
|
+
|
71
|
+
def ping_process!
|
72
|
+
capture("#{ping_command} 2>&1")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Luban
|
2
|
+
module Deployment
|
3
|
+
module Packages
|
4
|
+
class Mysql
|
5
|
+
class Installer < Luban::Deployment::Service::Installer
|
6
|
+
include Paths
|
7
|
+
|
8
|
+
define_executable 'mysql'
|
9
|
+
|
10
|
+
def package_dist; task.opts.dist; end
|
11
|
+
def package_full_name; "#{super}-#{package_dist}"; end
|
12
|
+
|
13
|
+
def source_repo
|
14
|
+
@source_repo ||= "http://dev.mysql.com"
|
15
|
+
end
|
16
|
+
|
17
|
+
def source_url_root
|
18
|
+
@source_url_root ||= "get/Downloads/MySQL-#{package_major_version}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def installed?
|
22
|
+
return false unless file?(mysql_executable)
|
23
|
+
pattern = Regexp.new("mysql Ver \.* Distrib #{Regexp.escape(package_version)}")
|
24
|
+
match?("#{mysql_executable} --version 2>&1", pattern)
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def bootstrap_install
|
30
|
+
super
|
31
|
+
assure_dirs(data_path, ssl_rsa_path,
|
32
|
+
innodb_log_group_home_path, bin_log_path,
|
33
|
+
error_log_path, general_log_path, slow_query_log_path)
|
34
|
+
assure(:directory, secure_file_priv_path) do
|
35
|
+
mkdir(secure_file_priv_path)
|
36
|
+
chmod('750', secure_file_priv_path)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure_build_options
|
41
|
+
super
|
42
|
+
@configure_opts.delete(install_prefix)
|
43
|
+
@configure_opts << "--user=#{user}"
|
44
|
+
@configure_opts << "--basedir=#{install_path}"
|
45
|
+
@configure_opts << "--datadir=#{data_path}"
|
46
|
+
@configure_opts << "--log-error=#{error_log_file_path}"
|
47
|
+
@configure_opts << "--innodb_log_group_home_dir=#{innodb_log_group_home_path}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_package
|
51
|
+
info "Building #{package_full_name}"
|
52
|
+
within install_path do
|
53
|
+
execute(:mv, build_path.join('*'), '.', ">> #{install_log_file_path} 2>&1")
|
54
|
+
execute(:"bin/mysqld", "--initialize-insecure #{compose_build_options} >> #{install_log_file_path} 2>&1")
|
55
|
+
execute(:"bin/mysql_ssl_rsa_setup", "--datadir=#{ssl_rsa_path}", ">> #{install_log_file_path} 2>&1")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module Luban
|
2
|
+
module Deployment
|
3
|
+
module Packages
|
4
|
+
class Mysql
|
5
|
+
module Paths
|
6
|
+
def control_file_name
|
7
|
+
@control_file_name ||= "my.cnf"
|
8
|
+
end
|
9
|
+
|
10
|
+
def data_path
|
11
|
+
@data_path ||= shared_path.join('data')
|
12
|
+
end
|
13
|
+
|
14
|
+
def ssl_rsa_path
|
15
|
+
@ssl_rsa_path ||= shared_path.join('ssl_rsa')
|
16
|
+
end
|
17
|
+
|
18
|
+
def ssl_ca_path
|
19
|
+
@ssl_ca_path ||= ssl_rsa_path.join('ca.pem')
|
20
|
+
end
|
21
|
+
|
22
|
+
def ssl_cert_path
|
23
|
+
@ssl_cert_path ||= ssl_rsa_path.join('server-cert.pem')
|
24
|
+
end
|
25
|
+
|
26
|
+
def ssl_key_path
|
27
|
+
@ssl_key_path ||= ssl_rsa_path.join('server-key.pem')
|
28
|
+
end
|
29
|
+
|
30
|
+
def innodb_log_group_home_path
|
31
|
+
@innodb_log_group_home_path ||= shared_path.join('innodb_log')
|
32
|
+
end
|
33
|
+
|
34
|
+
def bin_log_path
|
35
|
+
@bin_log_path ||= shared_path.join('bin_log')
|
36
|
+
end
|
37
|
+
|
38
|
+
def bin_log_file_path
|
39
|
+
@bin_log_file_path ||= bin_log_path.join('mysql-bin')
|
40
|
+
end
|
41
|
+
|
42
|
+
def error_log_path
|
43
|
+
@error_log_path ||= log_path.join('error')
|
44
|
+
end
|
45
|
+
|
46
|
+
def error_log_file_path
|
47
|
+
@error_log_file_path ||= error_log_path.join('mysql-err.log')
|
48
|
+
end
|
49
|
+
|
50
|
+
def general_log_path
|
51
|
+
@general_log_path ||= log_path.join('general')
|
52
|
+
end
|
53
|
+
|
54
|
+
def general_log_file_path
|
55
|
+
@general_log_file_path ||= general_log_path.join(log_file_name)
|
56
|
+
end
|
57
|
+
|
58
|
+
def slow_query_log_path
|
59
|
+
@slow_query_log_path ||= log_path.join('slow')
|
60
|
+
end
|
61
|
+
|
62
|
+
def slow_query_log_file_path
|
63
|
+
@slow_query_log_file_path ||= slow_query_log_path.join('mysql-slow.log')
|
64
|
+
end
|
65
|
+
|
66
|
+
def admin_control_file_path
|
67
|
+
@admin_control_file_path ||= profile_path.join('myadmin.cnf')
|
68
|
+
end
|
69
|
+
|
70
|
+
def socket_path
|
71
|
+
@socket_path ||= app_tmp_path.join('mysql.sock')
|
72
|
+
end
|
73
|
+
|
74
|
+
def secure_file_priv_path
|
75
|
+
@secure_file_priv_path ||= shared_path.join('mysql-files')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# MySQL configuration file
|
2
|
+
|
3
|
+
# MySQL client configuration
|
4
|
+
# =====================================
|
5
|
+
[client]
|
6
|
+
port = 3306
|
7
|
+
socket = <%= socket_path %>
|
8
|
+
default-character-set = utf8
|
9
|
+
|
10
|
+
# MySQL server configuration
|
11
|
+
# =====================================
|
12
|
+
[mysqld]
|
13
|
+
user = <%= user %>
|
14
|
+
port = 3306
|
15
|
+
|
16
|
+
# Directory settings
|
17
|
+
# -------------------------------------
|
18
|
+
basedir = <%= install_path %>
|
19
|
+
datadir = <%= data_path %>
|
20
|
+
tmpdir = <%= app_tmp_path %>
|
21
|
+
socket = <%= socket_path %>
|
22
|
+
pid-file = <%= pid_file_path %>
|
23
|
+
secure_file_priv = <%= secure_file_priv_path %>
|
24
|
+
|
25
|
+
# SSL settings
|
26
|
+
# -------------------------------------
|
27
|
+
ssl_ca = <%= ssl_ca_path %>
|
28
|
+
ssl_cert = <%= ssl_cert_path %>
|
29
|
+
ssl_key = <%= ssl_key_path %>
|
30
|
+
|
31
|
+
# Log settings
|
32
|
+
# -------------------------------------
|
33
|
+
log_output = File
|
34
|
+
|
35
|
+
# Error log
|
36
|
+
log-error = <%= error_log_file_path %>
|
37
|
+
|
38
|
+
# General log
|
39
|
+
general_log = 1
|
40
|
+
general_log_file = <%= general_log_file_path %>
|
41
|
+
|
42
|
+
# Slow query log
|
43
|
+
slow_query_log = 1
|
44
|
+
slow_query_log_file = <%= slow_query_log_file_path %>
|
45
|
+
|
46
|
+
# Binary log
|
47
|
+
binlog_format = mixed # binary logging format - mixed recommended
|
48
|
+
log-bin = <%= bin_log_file_path %>
|
49
|
+
server-id = 1
|
50
|
+
|
51
|
+
# UTF8 settings
|
52
|
+
# -------------------------------------
|
53
|
+
character-set-server = utf8
|
54
|
+
collation-server = utf8_general_ci
|
55
|
+
init_connect = 'SET NAMES utf8'
|
56
|
+
|
57
|
+
# General performance settings
|
58
|
+
skip-external-locking
|
59
|
+
key_buffer_size = 16M # 16K/16M/256M
|
60
|
+
max_allowed_packet = 1M
|
61
|
+
table_open_cache = 64 # 4/64/256
|
62
|
+
sort_buffer_size = 512K # 64K/512K/1M
|
63
|
+
net_buffer_length = 8K # 2K/8K/
|
64
|
+
read_buffer_size = 256K # 256K/256K/1M
|
65
|
+
read_rnd_buffer_size = 512K # 256K/512K/4M
|
66
|
+
myisam_sort_buffer_size = 8M # /8M/64M
|
67
|
+
thread_stack = 128K # 128K//
|
68
|
+
thread_cache_size = 8
|
69
|
+
query_cache_size= 16M
|
70
|
+
|
71
|
+
# InnoDB settings
|
72
|
+
# -------------------------------------
|
73
|
+
innodb_data_home_dir = <%= data_path %>
|
74
|
+
# innodb_data_file_path = ibdata0001:20M:autoextend
|
75
|
+
# innodb_data_file_path = ibdata0001:200M;ibdata0002:200M;ibdata0003:200M
|
76
|
+
innodb_log_group_home_dir = <%= innodb_log_group_home_path %>
|
77
|
+
# You can set .._buffer_pool_size up to 50 - 80 %
|
78
|
+
# of RAM but beware of setting memory usage too high
|
79
|
+
innodb_buffer_pool_size = 32M
|
80
|
+
# Set .._log_file_size to 25 % of buffer pool size
|
81
|
+
innodb_log_file_size = 8M
|
82
|
+
innodb_log_buffer_size = 8M
|
83
|
+
innodb_flush_log_at_trx_commit = 1
|
84
|
+
innodb_lock_wait_timeout = 50
|
85
|
+
|
86
|
+
[mysqldump]
|
87
|
+
quick
|
88
|
+
max_allowed_packet = 16M
|
89
|
+
|
90
|
+
[mysql]
|
91
|
+
no-auto-rehash
|
92
|
+
default-character-set = utf8
|
93
|
+
|
94
|
+
[myisamchk]
|
95
|
+
key_buffer_size = 20M
|
96
|
+
sort_buffer_size = 20M
|
97
|
+
read_buffer = 2M
|
98
|
+
write_buffer = 2M
|
99
|
+
|
100
|
+
[mysqlhotcopy]
|
101
|
+
# interactive-timeout
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# MySQL configuration for administration
|
2
|
+
|
3
|
+
[mysqladmin]
|
4
|
+
socket = <%= socket_path %>
|
5
|
+
default-character-set = utf8
|
6
|
+
user = root
|
7
|
+
# password = <secrete>
|
8
|
+
#
|
9
|
+
# where "<secret>" is the password.
|
10
|
+
#
|
11
|
+
# ATTENTION: this file should be readable ONLY for root!
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# MySQL logrotate configuration
|
2
|
+
|
3
|
+
<%= log_path.join('*').join('*.log') %> {
|
4
|
+
daily
|
5
|
+
missingok
|
6
|
+
rotate 7
|
7
|
+
compress
|
8
|
+
dateext
|
9
|
+
notifempty
|
10
|
+
sharedscripts
|
11
|
+
postrotate
|
12
|
+
# Check if mysqld is really running
|
13
|
+
test -x <%= mysqladmin_executable %> || exit 0
|
14
|
+
if <%= ping_command %> >/dev/null 2>&1
|
15
|
+
then
|
16
|
+
<%= reopen_logs_command %>
|
17
|
+
fi
|
18
|
+
endscript
|
19
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# MySQL Monit configuration
|
2
|
+
|
3
|
+
check process <%= service_entry %>
|
4
|
+
with pidfile <%= pid_file_path %>
|
5
|
+
start program = "/bin/bash -c 'sleep 1; cd <%= install_path %>; <%= start_command %> >/dev/null 2>&1 &'"
|
6
|
+
stop program = "/bin/bash -c '<%= stop_command %>'"
|
7
|
+
if totalmem is greater than 150.0 MB for 40 cycles then alert
|
8
|
+
if failed port 3306 for 4 times within 8 cycles then restart
|
9
|
+
if cpu is greater than 80% for 20 cycles then alert
|
10
|
+
if loadavg(5min) greater than 10 for 40 cycles then alert
|
data/lib/luban/mysql.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "deployment/packages/mysql"
|
data/lib/luban-mysql.rb
ADDED
File without changes
|
data/luban-mysql.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'luban/deployment/packages/mysql/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "luban-mysql"
|
8
|
+
spec.version = Luban::Deployment::Packages::Mysql::VERSION
|
9
|
+
spec.authors = ["Rubyist Chi"]
|
10
|
+
spec.email = ["rubyist.chi@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{MySQL support for Luban}
|
13
|
+
spec.description = %q{Luban::Mysql is a Luban package to manage MySQL installation, deployment and control}
|
14
|
+
spec.homepage = "https://github.com/lubanrb/mysql"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.required_ruby_version = ">= 2.1.0"
|
23
|
+
spec.add_dependency 'luban'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: luban-mysql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rubyist Chi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: luban
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
description: Luban::Mysql is a Luban package to manage MySQL installation, deployment
|
70
|
+
and control
|
71
|
+
email:
|
72
|
+
- rubyist.chi@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- CHANGELOG.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/luban-mysql.rb
|
86
|
+
- lib/luban/deployment/packages/mysql.rb
|
87
|
+
- lib/luban/deployment/packages/mysql/base.rb
|
88
|
+
- lib/luban/deployment/packages/mysql/configurator.rb
|
89
|
+
- lib/luban/deployment/packages/mysql/controller.rb
|
90
|
+
- lib/luban/deployment/packages/mysql/installer.rb
|
91
|
+
- lib/luban/deployment/packages/mysql/paths.rb
|
92
|
+
- lib/luban/deployment/packages/mysql/templates/my.cnf.erb
|
93
|
+
- lib/luban/deployment/packages/mysql/templates/myadmin.cnf.erb
|
94
|
+
- lib/luban/deployment/packages/mysql/templates/mysql.logrotate.erb
|
95
|
+
- lib/luban/deployment/packages/mysql/templates/mysql.monitrc.erb
|
96
|
+
- lib/luban/deployment/packages/mysql/version.rb
|
97
|
+
- lib/luban/mysql.rb
|
98
|
+
- luban-mysql.gemspec
|
99
|
+
homepage: https://github.com/lubanrb/mysql
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 2.1.0
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.5.1
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: MySQL support for Luban
|
123
|
+
test_files: []
|