You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-07 03:22:57 +03:00
MCOL-462
This commit is contained in:
@@ -8,8 +8,7 @@ prefix=/usr/local
|
|||||||
|
|
||||||
#check command
|
#check command
|
||||||
if [ "$1" = "" ]; then
|
if [ "$1" = "" ]; then
|
||||||
echo "Enter Command Name: {launchInstance|getInstance|getZone|getPrivateIP|getKey|getAMI|getType|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion}
|
echo "Enter Command Name: {launchInstance|getInstance|getZone|getPrivateIP|getKey|getAMI|getType|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion|getRole}"
|
||||||
}"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -104,6 +103,24 @@ getRegion() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRole() {
|
||||||
|
#check for iam folder
|
||||||
|
iam=`curl -s http://169.254.169.254/latest/meta-data/ | grep iam`
|
||||||
|
|
||||||
|
if [ -z "$iam" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
Role=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
|
||||||
|
|
||||||
|
if [ -z "$role" ]; then
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $Role
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
getInstance() {
|
getInstance() {
|
||||||
if [ "$instanceName" != "" ]; then
|
if [ "$instanceName" != "" ]; then
|
||||||
echo $instanceName
|
echo $instanceName
|
||||||
@@ -232,49 +249,52 @@ launchInstance() {
|
|||||||
#get group
|
#get group
|
||||||
getGroup >/dev/null 2>&1
|
getGroup >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#get AMI
|
#get AMI
|
||||||
getAMI >/dev/null 2>&1
|
getAMI >/dev/null 2>&1
|
||||||
|
|
||||||
#get Zone
|
#get Zone
|
||||||
getZone >/dev/null 2>&1
|
getZone >/dev/null 2>&1
|
||||||
if [ "$instanceType" = "unassigned" ]; then
|
if [ "$instanceType" = "unassigned" ]; then
|
||||||
#get type
|
#get type
|
||||||
getType >/dev/null 2>&1
|
getType >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
#get AMI Profile
|
|
||||||
getProfile >/dev/null 2>&1
|
|
||||||
|
|
||||||
#get Subnet
|
#get Subnet
|
||||||
getSubnet >/dev/null 2>&1
|
getSubnet >/dev/null 2>&1
|
||||||
|
|
||||||
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default-hvm" ]; then
|
#get IAM Role
|
||||||
if [ "$groupid" != "default" ]; then
|
getRole >/dev/null 2>&1
|
||||||
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ] ; then
|
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --security-group-ids $groupid --query 'Instances[*].InstanceId' --output text`
|
if [ "$Role" = "" ] || [ "$Role" = "default" ]; then
|
||||||
else
|
if [ "$groupid" != "default" ]; then
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ] ; then
|
||||||
fi
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --security-group-ids $groupid --query 'Instances[*].InstanceId' --output text`
|
||||||
else
|
else
|
||||||
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
else
|
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$groupid" != "default" ]; then
|
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
||||||
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
else
|
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
else
|
|
||||||
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $instanceProfile --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
if [ "$groupid" != "default" ]; then
|
||||||
|
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
||||||
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
|
else
|
||||||
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$IPaddress" = "autoassign" ] || [ "$IPaddress" = "unassigned" ]; then
|
||||||
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
|
else
|
||||||
|
newInstance=`$AWSCLI run-instances --region $Region --key-name $key --instance-type $instanceType --placement AvailabilityZone=$zone --iam-instance-profile $Role --subnet-id $subnet --private-ip-address $IPaddress --image-id $ami --query 'Instances[*].InstanceId' --output text`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo $newInstance
|
echo $newInstance
|
||||||
return
|
return
|
||||||
@@ -421,9 +441,11 @@ case "$1" in
|
|||||||
getRegion)
|
getRegion)
|
||||||
getRegion
|
getRegion
|
||||||
;;
|
;;
|
||||||
|
getRole)
|
||||||
|
getRole
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion}"
|
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet|getVpc|getRegion|getRole}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@@ -6,28 +6,20 @@ if [ -f $HOME/.aws/credentials ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#check for iam folder
|
#get IAM Role
|
||||||
iam=`curl -s http://169.254.169.254/latest/meta-data/ | grep iam`
|
Role=`$prefix/mariadb/columnstore/bin/MCSInstanceCmds.sh getRole`
|
||||||
|
|
||||||
|
if [ -z "$Role" ]; then
|
||||||
if [ -z "$iam" ]; then
|
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
instance_profile=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
|
aws_access_key_id=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${Role} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
|
||||||
#
|
|
||||||
|
|
||||||
if [ -z "$instance_profile" ]; then
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
aws_access_key_id=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g'`
|
|
||||||
|
|
||||||
if [ -z "$aws_access_key_id" ]; then
|
if [ -z "$aws_access_key_id" ]; then
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
aws_secret_access_key=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
|
aws_secret_access_key=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${Role} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g'`
|
||||||
|
|
||||||
if [ -z "$aws_secret_access_key" ]; then
|
if [ -z "$aws_secret_access_key" ]; then
|
||||||
exit 1;
|
exit 1;
|
||||||
|
@@ -5967,11 +5967,22 @@ namespace oam
|
|||||||
|
|
||||||
cout << " Create AWS Volume for UM #" << itoa(moduleID) << endl;
|
cout << " Create AWS Volume for UM #" << itoa(moduleID) << endl;
|
||||||
|
|
||||||
volumeName = createEC2Volume(UMVolumeSize, "um");
|
int retry = 0;
|
||||||
if ( volumeName == "failed" ) {
|
for ( ; retry < 5 ; retry++ )
|
||||||
writeLog("addModule: create volume failed", LOG_TYPE_CRITICAL);
|
{
|
||||||
exceptionControl("addUMdisk", API_FAILURE);
|
volumeName = createEC2Volume(UMVolumeSize, "um");
|
||||||
}
|
|
||||||
|
if ( volumeName == "failed" || volumeName.empty() )
|
||||||
|
retry = retry;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( retry >= 5 )
|
||||||
|
{
|
||||||
|
cout << " *** ERROR: Failed to create a Volume for um1 " << moduleID << endl;
|
||||||
|
exceptionControl("addUMdisk", API_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
//attach and format volumes
|
//attach and format volumes
|
||||||
device = "/dev/sdf";
|
device = "/dev/sdf";
|
||||||
@@ -5979,11 +5990,22 @@ namespace oam
|
|||||||
string localInstance = getEC2LocalInstance();
|
string localInstance = getEC2LocalInstance();
|
||||||
|
|
||||||
//attach volumes to local instance
|
//attach volumes to local instance
|
||||||
writeLog("addUMdisk - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
|
writeLog("addUMdisk - Attach new Volume to local instance: " + volumeName, LOG_TYPE_DEBUG);
|
||||||
if (!attachEC2Volume(volumeName, device, localInstance)) {
|
|
||||||
writeLog("addUMdisk: volume failed to attach to local instance", LOG_TYPE_CRITICAL);
|
retry = 0;
|
||||||
exceptionControl("addUMdisk", API_FAILURE);
|
for ( ; retry < 5 ; retry++ )
|
||||||
}
|
{
|
||||||
|
if (!attachEC2Volume(volumeName, device, localInstance))
|
||||||
|
detachEC2Volume(volumeName);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( retry >= 5 )
|
||||||
|
{
|
||||||
|
cout << " *** ERROR: Volume " << volumeName << " failed to attach to local instance" << endl;
|
||||||
|
exceptionControl("addUMdisk", API_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
//format attached volume
|
//format attached volume
|
||||||
writeLog("addUMdisk - Format new Volume for: " + volumeName, LOG_TYPE_DEBUG);
|
writeLog("addUMdisk - Format new Volume for: " + volumeName, LOG_TYPE_DEBUG);
|
||||||
|
Reference in New Issue
Block a user