Subversion Repositories ALCASAR

Rev

Rev 3322 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3322 Rev 3324
Line 210... Line 210...
210
		return 7
210
		return 7
211
	fi
211
	fi
212
	echo "Successfully connected with '$remote_ssh_user' to primary ($remote_addr:$remote_ssh_port)"
212
	echo "Successfully connected with '$remote_ssh_user' to primary ($remote_addr:$remote_ssh_port)"
213
 
213
 
214
	# Retrieve remote db_replication pwd
214
	# Retrieve remote db_replication pwd
215
	if ! /usr/bin/scp -q -P "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr":local-db_replication-pwd.txt /tmp/primary-db_replication-pwd.txt
215
	if ! /usr/bin/scp -q -P "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr":/home/replication/local-db_replication-pwd.txt /home/replication/primary-db_replication-pwd.txt
216
	then
216
	then
217
		echo "error: cannot retrieve remote primary db_user pwd" >&2
217
		echo "error: cannot retrieve remote primary db_user pwd" >&2
218
		return 7
218
		return 7
219
	fi
219
	fi
220
	remote_db_pwd=$(cat /tmp/primary-db_replication-pwd.txt)
220
	remote_db_pwd=$(cat /home/replication/primary-db_replication-pwd.txt)
221
	rm /tmp/primary-db_replication-pwd.txt
221
	rm /home/replication/primary-db_replication-pwd.txt
222
	echo "Successfully retrieve remote primary db_user pass"
222
	echo "Successfully retrieve remote primary db_user pass"
223
 
223
 
224
	# Test database credentials
224
	# Test database credentials
225
	if ! /usr/bin/ssh -q -p "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr" -- /usr/bin/mariadb --user="$remote_db_user" --password="$remote_db_pwd" --execute="QUIT"
225
	if ! /usr/bin/ssh -q -p "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr" -- /usr/bin/mariadb --user="$remote_db_user" --password="$remote_db_pwd" --execute="QUIT"
226
	then
226
	then
Line 300... Line 300...
300
		return 19
300
		return 19
301
	fi
301
	fi
302
	echo "Primary database dump locally copied"
302
	echo "Primary database dump locally copied"
303
	alcasar-mariadb.sh --import /tmp/alcasar-users-database-primary.sql.gz
303
	alcasar-mariadb.sh --import /tmp/alcasar-users-database-primary.sql.gz
304
	rm -f /tmp/alcasar-users-database-primary.sql.gz
304
	rm -f /tmp/alcasar-users-database-primary.sql.gz
-
 
305
	/usr/bin/ssh -q -p "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr" -- "rm -f /home/replication/alcasar-users-database-primary.sql.gz"
305
}
306
}
306
 
307
 
307
add_symmetric_replication() {
308
add_symmetric_replication() {
308
	hostname="$(/usr/local/bin/alcasar-replication-ssh-keys-management.sh --show-pubkey | cut -d' ' -f3 | cut -d'@' -f2 |cut -d'.' -f1)"
309
#	hostname="$(/usr/local/bin/alcasar-replication-ssh-keys-management.sh --show-pubkey | cut -d' ' -f3 | cut -d'@' -f2 |cut -d'.' -f1)"
309
	active_db_port="$(/usr/local/bin/alcasar-replication-list.sh --all |grep Master_Port|cut -d" " -f2)"
310
	active_db_port="$(/usr/local/bin/alcasar-replication-list.sh --all |grep Master_Port|cut -d" " -f2)"
310
	echo "adding symmetric replication (--name=$hostname --bind-port=$active_db_port --db-user=db_replication --db-password=$REPL_DB_USER_PWD)"
311
	echo "adding data for symetrical replication (--bind-port=$active_db_port)"
311
# First idea  : copy local db_user passwd remotely.
-
 
312
#if ! /usr/bin/scp -q -P "$remote_ssh_port" /home/replication/local-db_replication-pwd.txt "$remote_ssh_user"@"$remote_addr":secondary-"$hostname"-"$active_db_port"-db_replication-pwd.txt
312
	if ! /usr/bin/scp -q -P "$remote_ssh_port" /home/replication/local-db_replication-pwd.txt "$remote_ssh_user"@"$remote_addr":/home/replication/"$active_db_port"-db_replication-pwd.txt
313
	# second idea : remotely add the replication.
-
 
314
	if ! /usr/bin/ssh -p "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr" -- "sudo /usr/local/bin/alcasar-replication-add.sh --to-secondary --name=$hostname --bind-port=$active_db_port --db-user=db_replication --db-password=$REPL_DB_USER_PWD"
-
 
315
	then
313
	then
316
		echo "error: cannot add symmetric replication" >&2
314
		echo "error: cannot copy local db_replication-pwd to primary" >&2
317
		return 7
315
		return 7
318
	fi
316
	fi
-
 
317
#	if ! /usr/bin/ssh -p "$remote_ssh_port" "$remote_ssh_user"@"$remote_addr" -- "sudo /usr/local/bin/alcasar-replication-add.sh --to-secondary --name=$hostname --bind-port=$active_db_port --db-user=db_replication --db-password=`cat /home/replication/"$hostname"-"$active_db_port"-db_replication-pwd.txt`"
-
 
318
#	then
-
 
319
#		echo "error: cannot add symmetric replication" >&2
-
 
320
#		return 7
-
 
321
#	fi
319
	echo "Successfully add symmetric replication"
322
#	echo "Successfully add symmetric replication"
320
}
323
}
321
 
324
 
322
find_common_free_port() {
325
find_common_free_port() {
323
	remote_busy_ports_file=/tmp/remote_busy_ports
326
	remote_busy_ports_file=/tmp/remote_busy_ports
324
	local_busy_ports_file=/tmp/local_busy_ports
327
	local_busy_ports_file=/tmp/local_busy_ports