sr-scripts 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/bin/sr-start-slave CHANGED
@@ -85,7 +85,7 @@ p current_master
85
85
  current_instance_id = `curl http://169.254.169.254/latest/meta-data/instance-id`
86
86
  current_instance = connection.servers.get(current_instance_id)
87
87
 
88
- latest_snapshots.each_index |index| do
88
+ latest_snapshots.each_index do |index|
89
89
  snapshot_id = latest_snapshots[index]
90
90
  current_disk = master_disks[index]
91
91
 
@@ -103,15 +103,29 @@ latest_snapshots.each_index |index| do
103
103
  end
104
104
  end
105
105
 
106
- exit
106
+ current_instance.reload
107
+ p current_instance
107
108
 
109
+ # this should be something other than sleep, it needs to wait to make sure all disks are mounted
108
110
  sleep 15
109
111
 
112
+ `mkdir /mnt/mysql`
110
113
  # NEED TO FIND OUT IF NUMBER OF DISKS IS GREATER THAN 1, IF SO, THEN use mdadm to create an array and mount, if not, then just mount
114
+ if latest_snapshots.length > 1
115
+ `/sbin/mdadm --assemble /dev/md0 #{master_disks.join(' ')}`
116
+ `mount -t xfs /dev/md0 /mnt/mysql`
117
+ else
118
+ # `mount -t xfs /dev/md0 /mnt/mysql`
119
+ end
111
120
 
112
- `mkdir /mnt/mysql`
113
- `mount -t xfs /dev/sdk /mnt/mysql`
114
- `service mysql start`
121
+ #`service mysql start`
115
122
 
116
123
  #`mysql -e "CHANGE MASTER TO MASTER_HOST='#{current_master.private_ip_address}', MASTER_LOG_FILE='binarylogs.006693', MASTER_LOG_POS=785268118;"`
117
124
  # start mysql, connect to mysql and issue change master and start slave commands
125
+
126
+ #NEED TO TAG THE INSTANCE THAT STARTED WITH SOME OF THE INFO FROM THE CURRENT MASTER
127
+
128
+ connection.tags.create(:resource_id => current_instance.id, :key => "master_instance_id", :value => current_master.id)
129
+ connection.tags.create(:resource_id => current_instance.id, :key => "mysql_disks", :value => current_master.tags["mysql_disks"])
130
+
131
+
@@ -1,5 +1,5 @@
1
1
  module Sr
2
2
  module Scripts
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sr-scripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Davy Campano