Class: Dolphin::Mongodb
- Inherits:
-
Base
- Object
- Thor
- Base
- Dolphin::Mongodb
show all
- Defined in:
- lib/dolphin/ubuntu/mongodb.rb
Overview
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Constructor Details
This class inherits a constructor from Dolphin::Base
Instance Method Details
#backup ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/dolphin/ubuntu/mongodb.rb', line 79
def backup
upload("#{@config_root}/mongo/*", "/tmp")
= [
%{
mkdir -p ~/backups/mongodb
mv /tmp/mg* ~/backups/mongodb
# # add cron job to /var/spool/cron/crontabs/user
crontab /tmp/cron.txt
},
]
execute
end
|
#config ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/dolphin/ubuntu/mongodb.rb', line 43
def config
upload("#{@config_root}/mongo/*", "/tmp")
ufw = [
'# ufw',
'sudo ufw allow from 192.168.0.0/16 to any port 27017',
'sudo ufw allow from 192.168.0.0/16 to any port 28017',
]
@group_hash[:mg].each do |item|
ufw << "sudo ufw allow from #{@server_hash[item]}/32 to any port 27017"
ufw << "sudo ufw allow from #{@server_hash[item]}/32 to any port 28017"
end
ufw << "sudo ufw status numbered"
= [
ufw.join("\n"),
%{
sudo mv /tmp/mongodb.conf /etc/
sudo chown root:root /etc/mongodb.conf
sudo mv /tmp/keyfile.txt /etc/
sudo chown mongodb:mongodb /etc/keyfile.txt
sudo chmod go-r /etc/keyfile.txt
sudo restart mongodb
},
]
execute
end
|
#disable ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/dolphin/ubuntu/mongodb.rb', line 19
def disable
= [
%{
sudo stop mongodb
sudo sh -c 'echo manual > /etc/init/mongodb.override'
},
]
execute
end
|
#enable ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/dolphin/ubuntu/mongodb.rb', line 31
def enable
= [
%{
sudo rm -f /etc/init/mongodb.override
sudo start mongodb
},
]
execute
end
|
#install ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/dolphin/ubuntu/mongodb.rb', line 5
def install
= [
%{
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
sudo echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/10gen.list
sudo apt-get update
sudo apt-get -y install mongodb-10gen
},
]
execute
end
|