1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-07 09:01:10 +03:00
This commit is contained in:
David Hill
2018-09-24 11:50:56 -05:00
parent 72f514ca54
commit 681cfd34eb
20 changed files with 292 additions and 1245 deletions

View File

@ -100,6 +100,8 @@ using namespace querytele;
#include "threadpool.h"
#include "crashtrace.h"
#include "installdir.h"
namespace
{
@ -1320,7 +1322,7 @@ void setupSignalHandlers()
void setupCwd(ResourceManager* rm)
{
string workdir = rm->getScWorkingDir();
string workdir = startup::StartUp::tmpDir();
(void)chdir(workdir.c_str());
if (access(".", W_OK) != 0)

View File

@ -1,44 +0,0 @@
#! /bin/sh
# IDBCloudGetIP.sh
# Get IP Address from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#get instance name from called
instanceName="$1"
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
echo "stopped"
exit 1
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get x509 Certification and Private Key
x509Cert=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonX509Certificate`
x509PriKey=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonX509PrivateKey`
#get instance info
ec2-describe-instances -C $x509Cert -K $x509PriKey $instanceName > /tmp/instanceInfo 2> /dev/null
#check if running
cat /tmp/instanceInfo | grep running > /tmp/instanceStatus
if [ `cat /tmp/instanceStatus | wc -c` -eq 0 ]; then
echo "stopped"
exit 1
fi
#get priviate IP Address
IpAddr=`cat /tmp/instanceInfo | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $15}'`
echo $IpAddr
exit 0

View File

@ -1,574 +0,0 @@
#! /bin/sh
# IDBInstanceCmds.sh
# get-local-instance-ID, get-zone, getPrivateIP from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {launchInstance|getInstance|getZone|getPrivateIP|getKey|getAMI|getType|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet}
}"
exit 1
fi
if [ "$1" = "getPrivateIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "launchInstance" ]; then
if [ "$2" = "" ]; then
IPaddress="unassigned"
else
IPaddress="$2"
fi
if [ "$3" = "" ]; then
instanceType="unassigned"
else
instanceType="$3"
fi
if [ "$4" = "" ]; then
group="unassigned"
else
group="$4"
fi
fi
if [ "$1" = "terminateInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "stopInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "startInstance" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$2"
fi
if [ "$1" = "assignElasticIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Instance Name"
exit 1
else
instanceName="$2"
fi
if [ "$3" = "" ]; then
echo "Enter Elastic IP Address"
exit 1
else
IPAddress="$3"
fi
fi
if [ "$1" = "deassignElasticIP" ]; then
if [ "$2" = "" ]; then
echo "Enter Elastic IP Address"
exit 1
else
IPAddress="$2"
fi
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
if [ "$1" = "getPrivateIP" ]; then
echo "stopped"
exit 1
else
echo "unknown"
exit 1
fi
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get Keys and region
AmazonAccessKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonAccessKey`
if [ $AmazonAccessKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile"
exit 1
fi
AmazonSecretKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSecretKey`
if [ $AmazonSecretKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonSecretKeyFile : $AmazonSecretKeyFile"
exit 1
fi
AmazonAccessKey=`cat $AmazonAccessKeyFile`
AmazonSecretKey=`cat $AmazonSecretKeyFile`
Region=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonRegion`
subnet=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSubNetID`
if test ! -f $AmazonAccessKeyfile ; then
echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile"
exit 1
fi
if test ! -f $AmazonSecretKeyfile ; then
echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile"
exit 1
fi
#default instance to null
instance=""
describeInstanceFile="/tmp/describeInstance.txt"
touch $describeInstanceFile
describeInstance() {
ec2-describe-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region > $describeInstanceFile 2>&1
}
#call at start up
describeInstance
getInstance() {
if [ "$instance" != "" ]; then
echo $instance
return
fi
# first get local IP Address
localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'`
#get local Instance ID
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$instance" == "" ]; then
describeInstance
fi
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
echo $instance
return
}
getInstancePrivate() {
if [ "$instance" != "" ]; then
echo $instance
return
fi
# first get local IP Address
localIP=`ifconfig eth0 | grep "inet addr:" | awk '{print substr($2,6,20)}'`
#get local Instance ID
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$instance" == "" ]; then
describeInstance
fi
instance=`cat $describeInstanceFile | grep -m 1 -w $localIP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
return
}
getZone() {
#get from Columnstore.xml if it's there, if not, get from instance then store
zone=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonZone`
if [ "$zone" = "unassigned" ] || [ "$zone" = "" ]; then
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get zone
if [ "$subnet" == "unassigned" ]; then
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
if [ "$zone" == "" ]; then
describeInstance
fi
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
else
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
if [ "$zone" == "" ]; then
describeInstance
fi
zone=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $11}'`
fi
$prefix/mariadb/columnstore/bin/setConfig Installation AmazonZone $zone
fi
echo $zone
return
}
getPrivateIP() {
#get instance info
grep -B1 -A4 -m 1 $instanceName $describeInstanceFile > /tmp/instanceInfo_$instanceName 2>&1
if [ `cat /tmp/instanceInfo_$instanceName | wc -c` -eq 0 ]; then
describeInstance
fi
grep -B1 -A4 -m 1 $instanceName $describeInstanceFile > /tmp/instanceInfo_$instanceName 2>&1
#check if running or terminated
cat /tmp/instanceInfo_$instanceName | grep running > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -eq 0 ]; then
# not running
cat /tmp/instanceInfo_$instanceName | grep pending > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
describeInstance
echo "stopped"
exit 1
else
cat /tmp/instanceInfo_$instanceName | grep terminated > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
echo "terminated"
exit 1
else
cat /tmp/instanceInfo_$instanceName | grep shutting-down > /tmp/instanceStatus_$instanceName
if [ `cat /tmp/instanceStatus_$instanceName | wc -c` -ne 0 ]; then
echo "terminated"
exit 1
else
echo "stopped"
exit 1
fi
fi
fi
fi
#running, get priviate IP Address
if [ "$subnet" == "unassigned" ]; then
IpAddr=`head -n 2 /tmp/instanceInfo_$instanceName | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $15}'`
else
IpAddr=`head -n 2 /tmp/instanceInfo_$instanceName | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $14}'`
fi
echo $IpAddr
exit 0
}
getType() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Type
if [ "$subnet" == "unassigned" ]; then
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
if [ "$instanceType" == "" ]; then
describeInstance
fi
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
else
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
if [ "$instanceType" == "" ]; then
describeInstance
fi
instanceType=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $9}'`
fi
echo $instanceType
return
}
getKey() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Key
if [ "$subnet" == "unassigned" ]; then
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
if [ "$key" == "" ]; then
describeInstance
fi
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
else
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
if [ "$key" == "" ]; then
describeInstance
fi
key=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $7}'`
fi
echo $key
return
}
getAMI() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get AMI
ami=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'`
if [ "$ami" == "" ]; then
describeInstance
fi
ami=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $3}'`
echo $ami
return
}
getGroup() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get group
if [ "$subnet" == "unassigned" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
if [ "$group" == "" ]; then
describeInstance
fi
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 RESERVATION | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
if [ "$group" == "" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
fi
else
group=`grep -B1 -A6 -m 1 $instance $describeInstanceFile | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$group" == "" ]; then
describeInstance
fi
group=`grep -B1 -A6 -m 1 $instance $describeInstanceFile | grep -m 1 GROUP | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
if [ "$group" == "" ]; then
group=`grep -B1 -A4 -m 1 $instance $describeInstanceFile | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $21}'`
fi
fi
echo $group
return
}
getProfile() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Type
if [ "$subnet" == "unassigned" ]; then
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'`
if [ "$instanceProfile" == "" ]; then
describeInstance
fi
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $23}'`
else
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
if [ "$instanceProfile" == "" ]; then
describeInstance
fi
instanceProfile=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $22}'`
fi
echo $instanceProfile
return
}
launchInstance() {
#get publickey
getKey >/dev/null 2>&1
if [ "$group" = "unassigned" ]; then
#get group
getGroup >/dev/null 2>&1
fi
#get AMI
getAMI >/dev/null 2>&1
#get Zone
getZone >/dev/null 2>&1
if [ "$instanceType" = "unassigned" ]; then
#get type
getType >/dev/null 2>&1
fi
#get AMI Profile
getProfile >/dev/null 2>&1
if [ "$subnet" == "unassigned" ]; then
#NOT VPC
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else # VPC
if [ "$instanceProfile" = "" ] || [ "$instanceProfile" = "default" ]; then
if [ "$group" != "default" ]; then
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances --O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
fi
else
if [ "$group" != "default" ]; then
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -g $group -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
else
if [ "$IPaddress" = "autoassign" ]; then
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
newInstance=`ec2-run-instances -O $AmazonAccessKey -W $AmazonSecretKey -k $key -t $instanceType -z $zone -p $instanceProfile --region $Region -s $subnet --private-ip-address $IPaddress $ami | grep -m 1 INSTANCE | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
fi
fi
fi
echo $newInstance
return
}
terminateInstance() {
#terminate Instance
ec2-terminate-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/termInstanceInfo_$instanceName 2>&1
return
}
stopInstance() {
#terminate Instance
ec2-stop-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/stopInstanceInfo_$instanceName 2>&1
return
}
startInstance() {
#terminate Instance
ec2-start-instances -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $instanceName > /tmp/startInstanceInfo_$instanceName 2>&1
cat /tmp/startInstanceInfo_$instanceName | grep INSTANCE > /tmp/startInstanceStatus_$instanceName
if [ `cat /tmp/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/startInstanceInfo_$instanceName"
exit 1
fi
echo "Success"
exit 0
}
assignElasticIP() {
#terminate Instance
if [ "$subnet" == "unassigned" ]; then
ec2-associate-address -O $AmazonAccessKey -W $AmazonSecretKey -i $instanceName $IPAddress > /tmp/assignElasticIPInfo_$IPAddress 2>&1
else
EIP=`ec2-describe-addresses -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $IPAddress | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $4}'`
ec2-associate-address -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -i $instanceName -a $EIP > /tmp/assignElasticIPInfo_$IPAddress 2>&1
fi
cat /tmp/assignElasticIPInfo_$IPAddress | grep ADDRESS > /tmp/assignElasticIPStatus_$IPAddress
if [ `cat /tmp/assignElasticIPStatus_$IPAddress | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/assignElasticIPInfo_$IPAddress"
exit 1
fi
echo "Success"
exit 0
}
deassignElasticIP() {
#terminate Instance
ec2-disassociate-address -O $AmazonAccessKey -W $AmazonSecretKey $IPAddress > /tmp/deassignElasticIPInfo_$IPAddress 2>&1
cat /tmp/deassignElasticIPInfo_$IPAddress | grep ADDRESS > /tmp/deassignElasticIPStatus_$IPAddress
if [ `cat /tmp/deassignElasticIPStatus_$IPAddress | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/deassignElasticIPStatus_$IPAddress"
exit 1
fi
echo "Success"
exit 0
}
getSubnet() {
#get local Instance ID
getInstancePrivate >/dev/null 2>&1
#get Subnet
subnet=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $16}'`
if [ "$subnet" == "" ]; then
describeInstance
fi
subnet=`cat $describeInstanceFile | grep -m 1 $instance | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $16}'`
if [[ $subnet == *"subnet"* ]]
then
echo $subnet
else
echo "failed"
fi
return
}
case "$1" in
getInstance)
getInstance
;;
getZone)
getZone
;;
getPrivateIP)
getPrivateIP
;;
getKey)
getKey
;;
getAMI)
getAMI
;;
getType)
getType
;;
launchInstance)
launchInstance
;;
terminateInstance)
terminateInstance
;;
stopInstance)
stopInstance
;;
startInstance)
startInstance
;;
assignElasticIP)
assignElasticIP
;;
deassignElasticIP)
deassignElasticIP
;;
getProfile)
getProfile
;;
getGroup)
getGroup
;;
getSubnet)
getSubnet
;;
*)
echo $"Usage: $0 {launchInstance|getInstance|getZone|getPrivateIP|getType|getKey|getAMI|terminateInstance|startInstance|assignElasticIP|deassignElasticIP|getProfile|stopInstance|getGroup|getSubnet}"
exit 1
esac
exit $?

View File

@ -1,337 +0,0 @@
#! /bin/sh
# IDBVolumeCmds.sh
# describe, detach and attach Volume Storage from a Cloud environment
#
# 1. Amazon EC2
prefix=/usr/local
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {create|describe|detach|attach|delete|createTag}"
exit 1
fi
if [ "$1" = "create" ]; then
if [ "$2" = "" ]; then
echo "Enter size of the volume, in GiB (1-1024)"
exit 1
fi
volumeSize="$2"
#get module-type
if [ "$3" = "" ]; then
echo "Enter Module Type"
exit 1
fi
moduleType="$3"
fi
if [ "$1" = "describe" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "detach" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "attach" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
#get instance-name and device-name
if [ "$3" = "" ]; then
echo "Enter Instance Name"
exit 1
fi
instanceName="$3"
if [ "$4" = "" ]; then
echo "Enter Device Name"
exit 1
fi
deviceName="$4"
fi
if [ "$1" = "delete" ]; then
if [ "$2" = "" ]; then
echo "Enter Volume Name"
exit 1
fi
volumeName="$2"
fi
if [ "$1" = "createTag" ]; then
if [ "$2" = "" ]; then
echo "Enter Resource Name"
exit 1
fi
resourceName="$2"
if [ "$3" = "" ]; then
echo "Enter Tag Name"
exit 1
fi
tagName="$3"
if [ "$4" = "" ]; then
echo "Enter Tag Value"
exit 1
fi
tagValue="$4"
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
ec2=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_HOME`
if [ $ec2 == "unassigned" ]; then
STATUS="unknown"
RETVAL=1
fi
java=`$prefix/mariadb/columnstore/bin/getConfig Installation JAVA_HOME`
path=`$prefix/mariadb/columnstore/bin/getConfig Installation EC2_PATH`
export PATH=$path
export EC2_HOME=$ec2
export JAVA_HOME=$java
# get Keys and region
AmazonAccessKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonAccessKey`
if [ $AmazonAccessKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonAccessKey : $AmazonAccessKeyfile"
exit 1
fi
AmazonSecretKeyFile=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonSecretKey`
if [ $AmazonSecretKeyFile == "unassigned" ]; then
echo "FAILED: missing Config Setting AmazonSecretKeyFile : $AmazonSecretKeyFile"
exit 1
fi
AmazonAccessKey=`cat $AmazonAccessKeyFile`
AmazonSecretKey=`cat $AmazonSecretKeyFile`
if test ! -f $AmazonAccessKeyfile ; then
echo "FAILED: missing AmazonAccessKeyfile : $AmazonAccessKeyfile"
exit 1
fi
if test ! -f $AmazonSecretKeyfile ; then
echo "FAILED: missing AmazonSecretKeyfile : $AmazonSecretKeyfile"
exit 1
fi
Region=`$prefix/mariadb/columnstore/bin/getConfig Installation AmazonRegion`
checkInfostatus() {
#check if attached
cat /tmp/volumeInfo_$volumeName | grep attached > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attached"
RETVAL=0
return
fi
#check if available
cat /tmp/volumeInfo_$volumeName | grep available > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="available"
RETVAL=0
return
fi
#check if detaching
cat /tmp/volumeInfo_$volumeName | grep detaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="detaching"
RETVAL=0
return
fi
#check if attaching
cat /tmp/volumeInfo_$volumeName | grep attaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attaching"
RETVAL=0
return
fi
#check if doesn't exist
cat /tmp/volumeInfo_$volumeName | grep "does not exist" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="does-not-exist"
RETVAL=1
return
fi
#check if reports already attached from attach command
cat /tmp/volumeInfo_$volumeName | grep "already attached" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="already-attached"
RETVAL=1
return
fi
#any other, unknown error
STATUS="unknown"
RETVAL=1
return
}
createvolume() {
# get zone
zone=`$prefix/mariadb/columnstore/bin/IDBInstanceCmds.sh getZone`
if [ $moduleType == "um" ]; then
# get type
volumeType=`$prefix/mariadb/columnstore/bin/getConfig Installation UMVolumeType`
if [ $volumeType == "io1" ]; then
# get IOPS
volumeIOPS=`$prefix/mariadb/columnstore/bin/getConfig Installation UMVolumeIOPS`
fi
else # pm
# get type
volumeType=`$prefix/mariadb/columnstore/bin/getConfig Installation PMVolumeType`
if [ $volumeType == "io1" ]; then
# get IOPS
volumeIOPS=`$prefix/mariadb/columnstore/bin/getConfig Installation PMVolumeIOPS`
fi
fi
#create volume
if [ $volumeType == "io1" ]; then
volume=`ec2-create-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -z $zone -s $volumeSize -t $volumeType -iops $volumeIOPS | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
else
volume=`ec2-create-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region -z $zone -s $volumeSize -t $volumeType | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print $2}'`
fi
echo $volume
return
}
describevolume() {
#describe volume
ec2-describe-volumes -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
echo $STATUS
return
}
detachvolume() {
#detach volume
ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "detaching" ]; then
retries=1
while [ $retries -ne 60 ]; do
#retry until it's attached
ec2-detach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "available" ]; then
echo "available"
exit 0
fi
((retries++))
sleep 1
done
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "detachvolume failed: $STATUS"
echo "failed"
exit 1
fi
if [ $STATUS == "available" ]; then
echo "available"
exit 0
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "detachvolume failed status: $STATUS"
echo $STATUS
exit 1
}
attachvolume() {
#detach volume
ec2-attach-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName -i $instanceName -d $deviceName > /tmp/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "attaching" -o $STATUS == "already-attached" ]; then
retries=1
while [ $retries -ne 60 ]; do
#check status until it's attached
describevolume
if [ $STATUS == "attached" ]; then
echo "attached"
exit 0
fi
((retries++))
sleep 1
done
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "attachvolume failed: $STATUS"
echo "failed"
exit 1
fi
if [ $STATUS == "attached" ]; then
echo "attached"
exit 0
fi
test -f /usr/local/mariadb/columnstore/post/functions && . /usr/local/mariadb/columnstore/post/functions
cplogger -w 100 "attachvolume failed: $STATUS"
echo $STATUS
exit 1
}
deletevolume() {
#delete volume
ec2-delete-volume -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $volumeName > /tmp/deletevolume_$volumeName 2>&1
return
}
createTag() {
#create tag
ec2-create-tags -O $AmazonAccessKey -W $AmazonSecretKey --region $Region $resourceName --tag $tagName=$tagValue > /tmp/createTag_$volumeName 2>&1
return
}
case "$1" in
create)
createvolume
;;
describe)
describevolume
;;
detach)
detachvolume
;;
attach)
attachvolume
;;
delete)
deletevolume
;;
createTag)
createTag
;;
*)
echo $"Usage: $0 {create|describe|detach|attach|delete|}"
exit 1
esac
exit $?

View File

@ -10,6 +10,8 @@ fi
export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR
#get temp directory
tmpDir=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig SystemConfig SystemTempFileDir`
#check command
if [ "$1" = "" ]; then
@ -310,7 +312,7 @@ terminateInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI terminate-instances --instance-ids $instanceName --region $Region > /tmp/termInstanceInfo_$instanceName 2>&1
$AWSCLI terminate-instances --instance-ids $instanceName --region $Region > ${tmpdir}/termInstanceInfo_$instanceName 2>&1
return
}
@ -319,7 +321,7 @@ stopInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI stop-instances --instance-ids $instanceName --region $Region > /tmp/stopInstanceInfo_$instanceName 2>&1
$AWSCLI stop-instances --instance-ids $instanceName --region $Region > ${tmpdir}/stopInstanceInfo_$instanceName 2>&1
return
}
@ -328,11 +330,11 @@ startInstance() {
getRegion >/dev/null 2>&1
#terminate Instance
$AWSCLI start-instances --instance-ids $instanceName --region $Region > /tmp/startInstanceInfo_$instanceName 2>&1
$AWSCLI start-instances --instance-ids $instanceName --region $Region > ${tmpdir}/startInstanceInfo_$instanceName 2>&1
cat /tmp/startInstanceInfo_$instanceName | grep InstanceId > /tmp/startInstanceStatus_$instanceName
if [ `cat /tmp/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check /tmp/startInstanceInfo_$instanceName"
cat ${tmpdir}/startInstanceInfo_$instanceName | grep InstanceId > ${tmpdir}/startInstanceStatus_$instanceName
if [ `cat ${tmpdir}/startInstanceStatus_$instanceName | wc -c` -eq 0 ]; then
echo "Failed, check ${tmpdir}/startInstanceInfo_$instanceName"
exit 1
fi
echo "Success"
@ -345,11 +347,11 @@ assignElasticIP() {
EIP=`$AWSCLI describe-addresses --region $Region --public-ips $IPAddress --query 'Addresses[*].AllocationId' --output text`
$AWSCLI associate-address --region $Region --instance-id $instanceName --allocation-id $EIP > /tmp/assignElasticIPInfo_$IPAddress 2>&1
$AWSCLI associate-address --region $Region --instance-id $instanceName --allocation-id $EIP > ${tmpdir}/assignElasticIPInfo_$IPAddress 2>&1
cat /tmp/assignElasticIPInfo_$IPAddress | grep error > /tmp/assignElasticIPStatus_$IPAddress
if [ `cat /tmp/assignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check /tmp/assignElasticIPInfo_$IPAddress"
cat ${tmpdir}/assignElasticIPInfo_$IPAddress | grep error > ${tmpdir}/assignElasticIPStatus_$IPAddress
if [ `cat ${tmpdir}/assignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check ${tmpdir}/assignElasticIPInfo_$IPAddress"
exit 1
fi
@ -363,10 +365,10 @@ deassignElasticIP() {
EIP=`$AWSCLI describe-addresses --region $Region --public-ips $IPAddress --query 'Addresses[*].AssociationId' --output text`
$AWSCLI disassociate-address --region $Region --association-id $EIP > /tmp/deassignElasticIPInfo_$IPAddress 2>&1
cat /tmp/deassignElasticIPInfo_$IPAddress | grep error > /tmp/deassignElasticIPStatus_$IPAddress
if [ `cat /tmp/deassignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check /tmp/deassignElasticIPStatus_$IPAddress"
$AWSCLI disassociate-address --region $Region --association-id $EIP > ${tmpdir}/deassignElasticIPInfo_$IPAddress 2>&1
cat ${tmpdir}/deassignElasticIPInfo_$IPAddress | grep error > ${tmpdir}/deassignElasticIPStatus_$IPAddress
if [ `cat ${tmpdir}/deassignElasticIPStatus_$IPAddress | wc -c` -ne 0 ]; then
echo "Failed, check ${tmpdir}/deassignElasticIPStatus_$IPAddress"
exit 1
fi

View File

@ -10,6 +10,9 @@ fi
export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR
#get temp directory
tmpDir=`$COLUMNSTORE_INSTALL_DIR/bin/getConfig SystemConfig SystemTempFileDir`
#check command
if [ "$1" = "" ]; then
echo "Enter Command Name: {create|describe|detach|attach|delete|createTag}"
@ -108,43 +111,43 @@ Region=`$COLUMNSTORE_INSTALL_DIR/bin/MCSInstanceCmds.sh getRegion`
checkInfostatus() {
#check if attached
cat /tmp/volumeInfo_$volumeName | grep attached > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep attached > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attached"
RETVAL=0
return
fi
#check if available
cat /tmp/volumeInfo_$volumeName | grep available > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep available > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="available"
RETVAL=0
return
fi
#check if detaching
cat /tmp/volumeInfo_$volumeName | grep detaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep detaching > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="detaching"
RETVAL=0
return
fi
#check if attaching
cat /tmp/volumeInfo_$volumeName | grep attaching > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}volumeInfo_$volumeName | grep attaching > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="attaching"
RETVAL=0
return
fi
#check if doesn't exist
cat /tmp/volumeInfo_$volumeName | grep "does not exist" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep "does not exist" > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="does-not-exist"
RETVAL=1
return
fi
#check if reports already attached from attach command
cat /tmp/volumeInfo_$volumeName | grep "already attached" > /tmp/volumeStatus_$volumeName
if [ `cat /tmp/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
cat ${tmpdir}/volumeInfo_$volumeName | grep "already attached" > ${tmpdir}/volumeStatus_$volumeName
if [ `cat ${tmpdir}/volumeStatus_$volumeName | wc -c` -ne 0 ]; then
STATUS="already-attached"
RETVAL=1
return
@ -188,7 +191,7 @@ createvolume() {
describevolume() {
#describe volume
$AWSCLI describe-volumes --volume-ids $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI describe-volumes --volume-ids $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
echo $STATUS
@ -197,14 +200,14 @@ describevolume() {
detachvolume() {
#detach volume
$AWSCLI detach-volume --volume-id $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI detach-volume --volume-id $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "detaching" ]; then
retries=1
while [ $retries -ne 10 ]; do
#retry until it's attached
$AWSCLI detach-volume --volume-id $volumeName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI detach-volume --volume-id $volumeName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "available" ]; then
@ -234,7 +237,7 @@ detachvolume() {
attachvolume() {
#detach volume
$AWSCLI attach-volume --volume-id $volumeName --instance-id $instanceName --device $deviceName --region $Region > /tmp/volumeInfo_$volumeName 2>&1
$AWSCLI attach-volume --volume-id $volumeName --instance-id $instanceName --device $deviceName --region $Region > ${tmpdir}/volumeInfo_$volumeName 2>&1
checkInfostatus
if [ $STATUS == "attaching" -o $STATUS == "already-attached" ]; then
@ -268,13 +271,13 @@ attachvolume() {
deletevolume() {
#delete volume
$AWSCLI delete-volume --volume-id $volumeName --region $Region > /tmp/deletevolume_$volumeName 2>&1
$AWSCLI delete-volume --volume-id $volumeName --region $Region > ${tmpdir}/deletevolume_$volumeName 2>&1
return
}
createTag() {
#create tag
$AWSCLI create-tags --resources $resourceName --tags Key=$tagName,Value=$tagValue --region $Region > /tmp/createTag_$volumeName 2>&1
$AWSCLI create-tags --resources $resourceName --tags Key=$tagName,Value=$tagValue --region $Region > ${tmpdir}/createTag_$volumeName 2>&1
return
}

View File

@ -269,6 +269,7 @@
-->
<hdfsRdwrScratch>/rdwrscratch</hdfsRdwrScratch> <!-- Do not set to an hdfs file path -->
<TempFileDir>/columnstore_tmp_files</TempFileDir>
<SystemTempFileDir>/tmp/columnstore_tmp_files</SystemTempFileDir>
</SystemConfig>
<SystemModuleConfig>
<ModuleType1>dm</ModuleType1>

View File

@ -260,7 +260,8 @@
<Arg3>Optional: Module-name and Parameter-name will display the Module Name Configuration parameter</Arg3>
</Cmd38>
<Cmd39>
<Name>AVAILABLE</Name>
<Name>getSystemDirectories</Name>
<Desc1>Get System Installation and Temporary Logging Directories</Desc1>
</Cmd39>
<Cmd40>
<Name>AVAILABLE</Name>

View File

@ -8,13 +8,13 @@
# check log for error
checkForError() {
grep ERROR /tmp/disable-rep-status.log > /tmp/error.check
if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: /tmp/disable-rep-status.log"
rm -f /tmp/error.check
grep ERROR ${tmpdir}/disable-rep-status.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file:${tmpdir}/disable-rep-status.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f /tmp/error.check
rm -f ${tmpdir}/error.check
}
prefix=/usr/local
@ -30,42 +30,44 @@ for arg in "$@"; do
elif [ `expr -- "$arg" : '--installdir='` -eq 13 ]; then
installdir="`echo $arg | awk -F= '{print $2}'`"
prefix=`dirname $installdir`
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
test -f $installdir/post/functions && . $installdir/post/functions
>/tmp/disable-rep-status.log
>${tmpdir}/disable-rep-status.log
#
# Run stop slave command
#
echo "Run stop slave command" >>/tmp/disable-rep-status.log
cat >/tmp/idb_disable-rep.sql <<EOD
echo "Run stop slave command" >>${tmpdir}/disable-rep-status.log
cat >${tmpdir}/idb_disable-rep.sql <<EOD
stop slave;
EOD
cat /tmp/idb_disable-rep.sql >>/tmp/disable-rep-status.log
cat ${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \
calpontsys </tmp/idb_disable-rep.sql >>/tmp/disable-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log 2>&1
checkForError
#
# Run reset slave command
#
echo "Run reset slave command" >>/tmp/disable-rep-status.log
cat >/tmp/idb_disable-rep.sql <<EOD
echo "Run reset slave command" >>${tmpdir}/disable-rep-status.log
cat >${tmpdir}/idb_disable-rep.sql <<EOD
reset slave;
EOD
cat /tmp/idb_disable-rep.sql >>/tmp/disable-rep-status.log
cat ${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root $pwprompt \
calpontsys </tmp/idb_disable-rep.sql >>/tmp/disable-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_disable-rep.sql >>${tmpdir}/disable-rep-status.log 2>&1
checkForError

View File

@ -8,13 +8,13 @@
# check log for error
checkForError() {
grep ERROR /tmp/master-rep-status-$hostipaddr.log > /tmp/error.check
if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: /tmp/master-rep-status-$hostipaddr.log"
rm -f /tmp/error.check
grep ERROR ${tmpdir}/master-rep-status-$hostipaddr.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: ${tmpdir}/master-rep-status-$hostipaddr.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f /tmp/error.check
rm -f ${tmpdir}/error.check
}
prefix=/usr/local
@ -29,6 +29,8 @@ for arg in "$@"; do
prefix=`dirname $installdir`
elif [ `expr -- "$arg" : '--hostIP='` -eq 9 ]; then
hostipaddr="`echo $arg | awk -F= '{print $2}'`"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
done
@ -37,69 +39,69 @@ test -f $installdir/post/functions && . $installdir/post/functions
repUser="idbrep"
password="Calpont1"
>/tmp/master-rep-status-$hostipaddr.log
>${tmpdir}/master-rep-status-$hostipaddr.log
#
# Create Replication User
#
echo "Create Replication User $repUser for node $hostipaddr" >>/tmp/master-rep-status-$hostipaddr.log
cat >/tmp/idb_master-rep.sql <<EOD
echo "Create Replication User $repUser for node $hostipaddr" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
CREATE USER IF NOT EXISTS '$repUser'@'$hostipaddr' IDENTIFIED BY '$password';
GRANT REPLICATION SLAVE ON *.* TO '$repUser'@'$hostipaddr';
EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
#
# Grant table access for created user
#
echo "Grant table access for $repUser for node $hostipaddr" >>/tmp/master-rep-status-$hostipaddr.log
cat >/tmp/idb_master-rep.sql <<EOD
echo "Grant table access for $repUser for node $hostipaddr" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
use mysql
grant all on *.* to '$repUser'@'$hostipaddr' identified by 'Calpont1';
grant REPLICATION SLAVE on *.* to '$repUser'@'$hostipaddr' identified by 'Calpont1';
EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
#
# Run SHOW MASTER STATUS
#
echo "Run SHOW MASTER STATUS to node log" >>/tmp/master-rep-status-$hostipaddr.log
cat >/tmp/idb_master-rep.sql <<EOD
echo "Run SHOW MASTER STATUS to node log" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
SHOW MASTER STATUS
EOD
cat /tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log
cat ${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/master-rep-status-$hostipaddr.log 2>&1
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/master-rep-status-$hostipaddr.log 2>&1
checkForError
echo "Run SHOW MASTER STATUS to master status log /tmp/show-master-status.log" >>/tmp/master-rep-status-$hostipaddr.log
cat >/tmp/idb_master-rep.sql <<EOD
echo "Run SHOW MASTER STATUS to master status log ${tmpdir}/show-master-status.log" >>${tmpdir}/master-rep-status-$hostipaddr.log
cat >${tmpdir}/idb_master-rep.sql <<EOD
SHOW MASTER STATUS
EOD
cat /tmp/idb_master-rep.sql >/tmp/show-master-status.log
cat ${tmpdir}/idb_master-rep.sql >${tmpdir}/show-master-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_master-rep.sql >>/tmp/show-master-status.log
calpontsys <${tmpdir}/idb_master-rep.sql >>${tmpdir}/show-master-status.log
#alls good, 'OK' for success

View File

@ -167,16 +167,20 @@ mkdir -p $installdir/data/bulk/rollback >/dev/null 2>&1
mkdir -p $installdir/data/bulk/tmpjob >/dev/null 2>&1
rm -f $installdir/data/bulk/tmpjob/* >/dev/null 2>&1
#get temp directory
#get temp base directory
tmpDir="/tmp"
if [ $user != "root" ]; then
tmpDir=$HOME"./tmp"
mkdir $tmpDir >/dev/null 2>&1
fi
#get columnstore temp file directory name
TempFileDir=`$installdir/bin/getConfig SystemConfig TempFileDir`
tmpDir=$tmpDir+$TempFileDir
#set base columnstore temp file directory
$installdir/bin/setConfig -d SystemConfig SystemTempFileDir $tmpDir
#create columnstore temp file directory
mkdir -p $tmpDir >/dev/null 2>&1

View File

@ -7,16 +7,16 @@
# check log for error
checkForError() {
# check for password error
grep "ERROR 1045" ${tmpdir}/mysql_install.log > /tmp/error.check
if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then
grep "ERROR 1045" ${tmpdir}/mysql_install.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "MySQL Password file missing or incorrect, check .my.cnf file"
rm -f /tmp/error.check
rm -f ${tmpdir}/error.check
$installdir/mysql/mysql-Columnstore stop
sleep 2
exit 2;
fi
rm -f /tmp/error.check
rm -f ${tmpdir}/error.check
#---------------------------------------------------------------------------
# See if engine columnstore exist

View File

@ -73,14 +73,7 @@ rm -rf $installdir/mysql/db/columnstore_log_archive > /dev/null 2>&1\
$installdir/bin/clearShm > /dev/null 2>&1
#get temp directory
tmpDir="/tmp"
if [ $user != "root" ]; then
tmpDir=$HOME"./tmp"
mkdir $tmpDir >/dev/null 2>&1
fi
TempFileDir=`$installdir/bin/getConfig SystemConfig TempFileDir`
tmpDir=$tmpDir+$TempFileDir
tmpDir=`$installdir/bin/getConfig SystemConfig SystemTempFileDir`
# delete tmp files
rm -rf $tmpDir

View File

@ -8,13 +8,13 @@
# check log for error
checkForError() {
grep ERROR /tmp/slave-rep-status.log > /tmp/error.check
if [ `cat /tmp/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: /tmp/slave-rep-status.log"
rm -f /tmp/error.check
grep ERROR ${tmpdir}/slave-rep-status.log > ${tmpdir}/error.check
if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then
echo "ERROR: check log file: ${tmpdir}/slave-rep-status.log"
rm -f ${tmpdir}/error.check
exit 1
fi
rm -f /tmp/error.check
rm -f ${tmpdir}/error.check
}
prefix=/usr/local
@ -35,6 +35,10 @@ for arg in "$@"; do
masterlogpos="`echo $arg | awk -F= '{print $2}'`"
elif [ `expr -- "$arg" : '--port='` -eq 7 ]; then
port="`echo $arg | awk -F= '{print $2}'`"
elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then
tmpdir="$(echo $arg | awk -F= '{print $2}')"
fi
fi
done
@ -43,29 +47,29 @@ test -f $installdir/post/functions && . $installdir/post/functions
repUser="idbrep"
password="Calpont1"
>/tmp/slave-rep-status.log
>${tmpdir}/slave-rep-status.log
#
# Run stop slave command
#
echo "Run stop slave command" >>/tmp/slave-rep-status.log
cat >/tmp/idb_slave-rep.sql <<EOD
echo "Run stop slave command" >>${tmpdir}slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
stop slave;
EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run Change Master Command
#
echo "Run Change Master Command" >>/tmp/slave-rep-status.log
cat >/tmp/idb_slave-rep.sql <<EOD
echo "Run Change Master Command" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
CHANGE MASTER TO
MASTER_HOST='$masteripaddr',
MASTER_USER='$repUser',
@ -76,43 +80,43 @@ CHANGE MASTER TO
EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run start slave command
#
echo "Run start slave command" >>/tmp/slave-rep-status.log
cat >/tmp/idb_slave-rep.sql <<EOD
echo "Run start slave command" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
start slave;
EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError
#
# Run SHOW SLAVE STATUS
#
echo "Run SHOW SLAVE STATUS to node log" >>/tmp/slave-rep-status.log
cat >/tmp/idb_slave-rep.sql <<EOD
echo "Run SHOW SLAVE STATUS to node log" >>${tmpdir}/slave-rep-status.log
cat >${tmpdir}/idb_slave-rep.sql <<EOD
SHOW SLAVE STATUS\G
EOD
cat /tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log
cat ${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log
$installdir/mysql/bin/mysql \
--defaults-extra-file=$installdir/mysql/my.cnf \
--user=root \
calpontsys </tmp/idb_slave-rep.sql >>/tmp/slave-rep-status.log 2>&1
calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1
checkForError

View File

@ -81,6 +81,8 @@ using namespace oam;
using namespace logging;
using namespace BRM;
string tmpdir;
namespace oam
{
// flag to tell us ctrl-c was hit
@ -160,6 +162,8 @@ Oam::Oam()
if ( USER != "root")
userDir = "home/" + USER;
tmpdir = startup::StartUp::tmpDir();
}
Oam::~Oam()
@ -3570,19 +3574,19 @@ void Oam::getLogFile(const std::string moduleName, const std::string loglevel, c
logFile = path + logFile;
string tempLogFile = "/tmp/logs";
string tempLogFile = tmpdir +"/logs";
//make 1 log file made up of archive and current *.log
(void)system("touch /tmp/logs");
(void)system(tempLogFile.c_str());
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpdir;
string cmd = "ls " + path + logdir + "/archive | grep '" + logFileName + "' > /tmp/logfiles";
string cmd = "ls " + path + logdir + "/archive | grep '" + logFileName + "' > " + tmpdir + "/logfiles";
(void)system(cmd.c_str());
string fileName = "/tmp/logfiles";
string fileName = tmpdir + "/logfiles";
ifstream oldFile (fileName.c_str());
@ -3594,7 +3598,7 @@ void Oam::getLogFile(const std::string moduleName, const std::string loglevel, c
while (oldFile.getline(line, 400))
{
buf = line;
cmd = "cat " + path + logdir + "/archive/" + buf + " >> /tmp/logs";
cmd = "cat " + path + logdir + "/archive/" + buf + " >> " + tempLogFile;
(void)system(cmd.c_str());
}
@ -3602,7 +3606,7 @@ void Oam::getLogFile(const std::string moduleName, const std::string loglevel, c
unlink (fileName.c_str());
}
cmd = "cat " + logFile + " >> /tmp/logs";
cmd = "cat " + logFile + " >> " + tempLogFile;
(void)system(cmd.c_str());
//validate and get mm / dd from incoming date
@ -3720,7 +3724,7 @@ void Oam::getLogFile(const std::string moduleName, const std::string loglevel, c
unlink (tempLogFile.c_str());
}
fileName = "/tmp/logsByDate";
fileName = tmpdir + "/logsByDate";
ofstream newFile (fileName.c_str());
//create new file
@ -6747,7 +6751,7 @@ void Oam::addDbroot(const int dbrootNumber, DBRootConfigList& dbrootlist, string
int user;
user = getuid();
cmd = "mkfs.ext2 -F " + amazonDeviceName + " > /tmp/format.log 2>&1";
cmd = "mkfs.ext2 -F " + amazonDeviceName + " > " + tmpdir + "/format.log 2>&1";
writeLog("addDbroot format cmd: " + cmd, LOG_TYPE_DEBUG );
@ -7801,17 +7805,19 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
string command;
string pidtmp = tmpdir + "/mysql.pid";
switch (action)
{
case MYSQL_START:
{
command = "start > /tmp/actionMysqlCalpont.log 2>&1";
command = "start > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
break;
}
case MYSQL_STOP:
{
command = "stop > /tmp/actionMysqlCalpont.log 2>&1";
command = "stop > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
//set process status
try
@ -7826,25 +7832,25 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
case MYSQL_RESTART:
{
command = "restart > /tmp/actionMysqlCalpont.log 2>&1";
command = "restart > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
break;
}
case MYSQL_RELOAD:
{
command = "reload > /tmp/actionMysqlCalpont.log 2>&1";
command = "reload > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
break;
}
case MYSQL_FORCE_RELOAD:
{
command = "force-reload > /tmp/actionMysqlCalpont.log 2>&1";
command = "force-reload > " + tmpdir + "/actionMysqlCalpont.log 2>&1";
break;
}
case MYSQL_STATUS:
{
command = "status > /tmp/mysql.status";
command = "status > " + tmpdir + "/mysql.status";
break;
}
@ -7862,9 +7868,9 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
if (action == MYSQL_START || action == MYSQL_RESTART)
{
//get pid
cmd = "cat " + InstallDir + "/mysql/db/*.pid > /tmp/mysql.pid";
cmd = "cat " + InstallDir + "/mysql/db/*.pid > " + pidtmp;
system(cmd.c_str());
ifstream oldFile ("/tmp/mysql.pid");
ifstream oldFile (pidtmp);
//fail if file size 0
oldFile.seekg(0, std::ios::end);
@ -7915,14 +7921,15 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
int state = procstat.ProcessOpState;
pid_t pidStatus = procstat.ProcessID;
if (checkLogStatus("/tmp/mysql.status", "MySQL running"))
string mysqlStatus = tmpdir + "/mysql.status";
if (checkLogStatus(mysqlStatus, "MySQL running"))
{
if ( state != ACTIVE )
{
//get pid
cmd = "cat " + InstallDir + "/mysql/db/*.pid > /tmp/mysql.pid";
cmd = "cat " + InstallDir + "/mysql/db/*.pid > " + pidtmp;
system(cmd.c_str());
ifstream oldFile ("/tmp/mysql.pid");
ifstream oldFile (pidtmp);
char line[400];
string pid;
@ -7947,9 +7954,9 @@ void Oam::actionMysqlCalpont(MYSQLCALPONT_ACTION action)
else
{
//check if pid has changed
cmd = "cat " + InstallDir + "/mysql/db/*.pid > /tmp/mysql.pid";
cmd = "cat " + InstallDir + "/mysql/db/*.pid > " + pidtmp;
system(cmd.c_str());
ifstream oldFile ("/tmp/mysql.pid");
ifstream oldFile (pidtmp);
char line[400];
string pid;
@ -8224,19 +8231,19 @@ int Oam::validateModule(const std::string name)
std::string Oam::getEC2InstanceIpAddress(std::string instanceName)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getPrivateIP " + instanceName + " > /tmp/getCloudIP_" + instanceName;
string tmplog = tmpdir + "/getCloudIP_" + instanceName;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getPrivateIP " + instanceName + " > " + tmplog;
system(cmd.c_str());
if (checkLogStatus("/tmp/getCloudIP_" + instanceName, "stopped") )
if (checkLogStatus(tmplog, "stopped") )
return "stopped";
if (checkLogStatus("/tmp/getCloudIP_" + instanceName, "terminated") )
if (checkLogStatus(tmplog, "terminated") )
return "terminated";
// get IP Address
string IPAddr;
string file = "/tmp/getCloudIP_" + instanceName;
ifstream oldFile (file.c_str());
ifstream oldFile (tmplog.c_str());
char line[400];
while (oldFile.getline(line, 400))
@ -8263,7 +8270,8 @@ std::string Oam::getEC2InstanceIpAddress(std::string instanceName)
std::string Oam::getEC2LocalInstance(std::string name)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getInstance > /tmp/getInstanceInfo_" + name;
string file = tmpdir + "/getInstanceInfo_" + name;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getInstance > " + file;
int status = system(cmd.c_str());
if (WEXITSTATUS(status) != 0 )
@ -8271,7 +8279,6 @@ std::string Oam::getEC2LocalInstance(std::string name)
// get Instance Name
string instanceName;
string file = "/tmp/getInstanceInfo_" + name;
ifstream oldFile (file.c_str());
char line[400];
@ -8297,7 +8304,8 @@ std::string Oam::getEC2LocalInstance(std::string name)
std::string Oam::getEC2LocalInstanceType(std::string name)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getType > /tmp/getInstanceType_" + name;
string file = tmpdir + "/getInstanceType_" + name;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getType > " + file;
int status = system(cmd.c_str());
if (WEXITSTATUS(status) != 0 )
@ -8305,7 +8313,6 @@ std::string Oam::getEC2LocalInstanceType(std::string name)
// get Instance Name
string instanceType;
string file = "/tmp/getInstanceType_" + name;
ifstream oldFile (file.c_str());
char line[400];
@ -8331,7 +8338,8 @@ std::string Oam::getEC2LocalInstanceType(std::string name)
std::string Oam::getEC2LocalInstanceSubnet(std::string name)
{
// run script to get Instance Subnet
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getSubnet > /tmp/getInstanceSubnet_" + name;
string file = tmpdir + "/getInstanceSubnet_" + name;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getSubnet > " + file;
int status = system(cmd.c_str());
if (WEXITSTATUS(status) != 0 )
@ -8339,7 +8347,6 @@ std::string Oam::getEC2LocalInstanceSubnet(std::string name)
// get Instance Name
string instanceSubnet;
string file = "/tmp/getInstanceSubnet_" + name;
ifstream oldFile (file.c_str());
char line[400];
@ -8366,18 +8373,18 @@ std::string Oam::getEC2LocalInstanceSubnet(std::string name)
std::string Oam::launchEC2Instance( const std::string name, const std::string IPAddress, const std::string type, const std::string group)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh launchInstance " + IPAddress + " " + type + " " + group + " > /tmp/getInstance_" + name;
string file = tmpdir + "/getInstance_" + name;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh launchInstance " + IPAddress + " " + type + " " + group + " > " + file;
int status = system(cmd.c_str());
if (WEXITSTATUS(status) != 0 )
return "failed";
if (checkLogStatus("/tmp/getInstance", "Required") )
if (checkLogStatus(file, "Required") )
return "failed";
// get Instance ID
string instance;
string file = "/tmp/getInstance_" + name;
ifstream oldFile (file.c_str());
char line[400];
@ -8411,7 +8418,7 @@ std::string Oam::launchEC2Instance( const std::string name, const std::string IP
void Oam::terminateEC2Instance(std::string instanceName)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh terminateInstance " + instanceName + " > /tmp/terminateEC2Instance_" + instanceName;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh terminateInstance " + instanceName + " > " + tmpdir + "/terminateEC2Instance_" + instanceName;
system(cmd.c_str());
return;
@ -8428,7 +8435,7 @@ void Oam::terminateEC2Instance(std::string instanceName)
void Oam::stopEC2Instance(std::string instanceName)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh stopInstance " + instanceName + " > /tmp/stopEC2Instance_" + instanceName;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh stopInstance " + instanceName + " > " + tmpdir + "/stopEC2Instance_" + instanceName;
system(cmd.c_str());
return;
@ -8445,7 +8452,7 @@ void Oam::stopEC2Instance(std::string instanceName)
bool Oam::startEC2Instance(std::string instanceName)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh startInstance " + instanceName + " > /tmp/startEC2Instance_" + instanceName;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh startInstance " + instanceName + " > " + tmpdir + "/startEC2Instance_" + instanceName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8465,7 +8472,7 @@ bool Oam::startEC2Instance(std::string instanceName)
bool Oam::assignElasticIP(std::string instanceName, std::string IpAddress)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh assignElasticIP " + instanceName + " " + IpAddress + " > /tmp/assignElasticIP_" + instanceName;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh assignElasticIP " + instanceName + " " + IpAddress + " > " + tmpdir + "/assignElasticIP_" + instanceName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8485,7 +8492,7 @@ bool Oam::assignElasticIP(std::string instanceName, std::string IpAddress)
bool Oam::deassignElasticIP(std::string IpAddress)
{
// run script to get Instance status and IP Address
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh deassignElasticIP " + IpAddress + " > /tmp/deassignElasticIP_" + IpAddress;
string cmd = InstallDir + "/bin/MCSInstanceCmds.sh deassignElasticIP " + IpAddress + " > " + tmpdir + "/deassignElasticIP_" + IpAddress;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8505,7 +8512,7 @@ bool Oam::deassignElasticIP(std::string IpAddress)
std::string Oam::getEC2VolumeStatus(std::string volumeName)
{
// run script to get Volume Status
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh describe " + volumeName + " > /tmp/getVolumeStatus_" + volumeName;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh describe " + volumeName + " > " + tmpdir + "/getVolumeStatus_" + volumeName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8513,7 +8520,7 @@ std::string Oam::getEC2VolumeStatus(std::string volumeName)
// get status
string status;
string file = "/tmp/getVolumeStatus_" + volumeName;
string file = tmpdir + "/getVolumeStatus_" + volumeName;
ifstream oldFile (file.c_str());
char line[400];
@ -8539,7 +8546,8 @@ std::string Oam::getEC2VolumeStatus(std::string volumeName)
std::string Oam::createEC2Volume(std::string size, std::string name)
{
// run script to get Volume Status
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh create " + size + " " + name + " > /tmp/createVolumeStatus_" + name;
string file = tmpdir + "/createVolumeStatus_" + name;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh create " + size + " " + name + " > " + file;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8547,7 +8555,6 @@ std::string Oam::createEC2Volume(std::string size, std::string name)
// get status
string volumeName;
string file = "/tmp/createVolumeStatus_" + name;
ifstream oldFile (file.c_str());
char line[400];
@ -8587,7 +8594,7 @@ bool Oam::attachEC2Volume(std::string volumeName, std::string deviceName, std::s
for ( int retry = 0 ; retry < 2 ; retry++ )
{
// run script to attach Volume
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh attach " + volumeName + " " + instanceName + " " + deviceName + " > /tmp/attachVolumeStatus_" + volumeName;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh attach " + volumeName + " " + instanceName + " " + deviceName + " > " + tmpdir + "/attachVolumeStatus_" + volumeName;
ret = system(cmd.c_str());
if (WEXITSTATUS(ret) == 0 )
@ -8614,7 +8621,7 @@ bool Oam::attachEC2Volume(std::string volumeName, std::string deviceName, std::s
bool Oam::detachEC2Volume(std::string volumeName)
{
// run script to attach Volume
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh detach " + volumeName + " > /tmp/detachVolumeStatus_" + volumeName;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh detach " + volumeName + " > " + tmpdir + "/detachVolumeStatus_" + volumeName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8634,7 +8641,7 @@ bool Oam::detachEC2Volume(std::string volumeName)
bool Oam::deleteEC2Volume(std::string volumeName)
{
// run script to delete Volume
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh delete " + volumeName + " > /tmp/deleteVolumeStatus_" + volumeName;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh delete " + volumeName + " > " + tmpdir + "/deleteVolumeStatus_" + volumeName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -8654,7 +8661,7 @@ bool Oam::deleteEC2Volume(std::string volumeName)
bool Oam::createEC2tag(std::string resourceName, std::string tagName, std::string tagValue)
{
// run script to create a tag
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh createTag " + resourceName + " " + tagName + " " + tagValue + " > /tmp/createTagStatus_" + resourceName;
string cmd = InstallDir + "/bin/MCSVolumeCmds.sh createTag " + resourceName + " " + tagName + " " + tagValue + " > " + tmpdir + "createTagStatus_" + resourceName;
int ret = system(cmd.c_str());
if (WEXITSTATUS(ret) != 0 )
@ -9009,7 +9016,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
}
sleep(5);
command = glustercmd + "peer status " + " >> /tmp/glusterCommands.txt 2>&1";
command = glustercmd + "peer status " + " >> " + tmpdir + "/glusterCommands.log 2>&1";
status = system(command.c_str());
if (WEXITSTATUS(status) != 0 )
@ -9042,7 +9049,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
pmnextbrick[pm]++;
}
command += "force >> /tmp/glusterCommands.txt 2>&1";
command += "force >> " + tmpdir + "/glusterCommands.log 2>&1";
cout << "Gluster create and start volume dbroot" << itoa(newDbrootID) << "...";
status = system(command.c_str());
@ -9054,7 +9061,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
if (user != 0)
{
command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-uid " + itoa(user) + " >> /tmp/glusterCommands.txt 2>&1";;
command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-uid " + itoa(user) + " >> " + tmpdir + "/glusterCommands.log 2>&1";;
status = system(command.c_str());
if (WEXITSTATUS(status) != 0 )
@ -9063,7 +9070,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
exceptionControl("GLUSTER_ADD", API_FAILURE);
}
command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-gid " + itoa(group) + " >> /tmp/glusterCommands.txt 2>&1";;
command = "gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-gid " + itoa(group) + " >> " + tmpdir + "/glusterCommands.log 2>&1";;
status = system(command.c_str());
if (WEXITSTATUS(status) != 0 )
@ -9073,7 +9080,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
}
}
command = glustercmd + "volume start dbroot" + itoa(newDbrootID) + " >> /tmp/glusterCommands.txt 2>&1";
command = glustercmd + "volume start dbroot" + itoa(newDbrootID) + " >> " + tmpdir + "/glusterCommands.log 2>&1";
status = system(command.c_str());
if (WEXITSTATUS(status) != 0 )
@ -9120,7 +9127,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
int status;
writeLog("glusterctl: GLUSTER_DELETE: dbroot = " + dbrootID, LOG_TYPE_DEBUG );
command = glustercmd + "--mode=script volume stop dbroot" + dbrootID + " >> /tmp/glusterCommands.txt 2>&1";
command = glustercmd + "--mode=script volume stop dbroot" + dbrootID + " >> " + tmpdir + "/glusterCommands.log 2>&1";
status = system(command.c_str());
@ -9133,7 +9140,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
// give time for transaction to finish after stopping
sleep(10);
command = glustercmd + " --mode=script volume delete dbroot" + dbrootID + " >> /tmp/glusterCommands.txt 2>&1";
command = glustercmd + " --mode=script volume delete dbroot" + dbrootID + " >> " + tmpdir + "/glusterCommands.log 2>&1";
status = system(command.c_str());
@ -9153,7 +9160,7 @@ int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string
string command = "";
int status;
command = glustercmd + "peer probe " + ipAddress + " >> /tmp/glusterCommands.txt 2>&1";
command = glustercmd + "peer probe " + ipAddress + " >> " + tmpdir + "/glusterCommands.log 2>&1";
cout << "gluster peer probe " + ipAddress << endl;
status = system(command.c_str());
@ -9309,7 +9316,7 @@ int Oam::checkGlusterLog(std::string logFile, std::string& msg)
{
if (checkLogStatus(logFile, "OK"))
{
if ( logFile == "/tmp/gluster_howhas.log" )
if ( logFile == tmpdir + "/gluster_howhas.log" )
{
ifstream File(logFile.c_str());
@ -9364,7 +9371,7 @@ int Oam::checkGlusterLog(std::string logFile, std::string& msg)
writeLog("checkGlusterLog: FAILURE", LOG_TYPE_ERROR);
if ( logFile == "/tmp/gluster_howhas.log" )
if ( logFile == tmpdir + "/gluster_howhas.log" )
return 2;
else
exceptionControl("glusterctl", API_FAILURE);
@ -10875,8 +10882,6 @@ int Oam::readHdfsActiveAlarms(AlarmList& alarmList)
bool Oam::checkSystemRunning()
{
// string cmd = startup::StartUp::installDir() + "/bin/columnstore status > /tmp/status.log";
// system(cmd.c_str());
struct stat st;
string lockFileDir = "/var/subsys/lock";

View File

@ -188,9 +188,6 @@ int main(int argc, char* argv[])
string ccHistoryFile = HOME + "/.cc_history";
cout << startup::StartUp::installDir() << endl;
cout << startup::StartUp::tmpDir() << endl;
string cf = startup::StartUp::installDir() + "/etc/" + ConsoleCmdsFile;
fConfig = Config::makeConfig(cf);
@ -4919,8 +4916,12 @@ int processCommand(string* arguments)
}
break;
case 39:
case 39: // getSystemDirectories
{
cout << "System Installation and Temporary Logging Directories" << endl << endl;
cout << "System Installation Directory = " << startup::StartUp::installDir() << endl;
cout << "System Temporary Logging Directory = " << startup::StartUp::tmpDir() << endl;
}
break;

View File

@ -61,6 +61,8 @@ bool HDFS = false;
string localHostName;
string PMwithUM = "n";
string MySQLRep = "n";
string tmpLogDir;
// pushing the ACTIVE_ALARMS_FILE to all nodes every 10 seconds.
const int ACTIVE_ALARMS_PUSHING_INTERVAL = 10;
@ -256,6 +258,9 @@ int main(int argc, char** argv)
freeifaddrs(addrs);
log.writeLog(__LINE__, "Main Ethernet Port = " + iface_name, LOG_TYPE_DEBUG);
//get tmp log directory
tmpLogDir = startup::StartUp::tmpDir();
//
//start a thread to ping all system modules
//

View File

@ -56,6 +56,7 @@ extern bool HDFS;
extern string localHostName;
extern string PMwithUM;
extern string AmazonPMFailover;
extern string tmpLogDir;
typedef map<string, int> moduleList;
extern moduleList moduleInfoList;
@ -2727,7 +2728,7 @@ void processMSG(messageqcpp::IOSocket* cfIos)
// Save the BRM. This command presages a system backup. Best to have a current BRM on disk
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string cmd = startup::StartUp::installDir() + "/bin/save_brm > " + logdir + "/save_brm.log1 2>&1";
int rtnCode = system(cmd.c_str());
@ -5134,17 +5135,17 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
continue;
}
string cmd = installDir + "/bin/remote_command.sh " + IPAddr + " " + password + " 'ls' 1 > /tmp/login_test.log";
string loginTmp = tmpLogDir + "/login_test.log";
string cmd = installDir + "/bin/remote_command.sh " + IPAddr + " " + password + " 'ls' 1 > " + loginTmp;
system(cmd.c_str());
if (!oam.checkLogStatus("/tmp/login_test.log", "README"))
if (!oam.checkLogStatus(loginTmp, "README"))
{
//check for RSA KEY ISSUE and fix
if (oam.checkLogStatus("/tmp/login_test.log", "Offending"))
if (oam.checkLogStatus(loginTmp, "Offending"))
{
log.writeLog(__LINE__, "addModule - login failed, Offending key issue, try fixing: " + moduleName, LOG_TYPE_DEBUG);
string file = "/tmp/login_test.log";
oam.fixRSAkey(file);
oam.fixRSAkey(loginTmp);
}
log.writeLog(__LINE__, "addModule - login failed, retry login test: " + moduleName, LOG_TYPE_DEBUG);
@ -5551,7 +5552,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
//set root password
if (amazon)
{
cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '/root/.scripts/updatePassword.sh " + password + "' > /tmp/password_change.log";
cmd = startup::StartUp::installDir() + "/bin/remote_command.sh " + remoteModuleIP + " " + password + " '/root/.scripts/updatePassword.sh " + password + "' > " + tmpLogDir + "/password_change.log";
log.writeLog(__LINE__, "addModule - cmd: " + cmd, LOG_TYPE_DEBUG);
int rtnCode = system(cmd.c_str());
@ -5572,7 +5573,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
//run remote installer script
if ( packageType != "binary" )
{
string logFile = "/tmp/" + remoteModuleName + "_user_installer.log";
string logFile = tmpLogDir + "/" + remoteModuleName + "_user_installer.log";
log.writeLog(__LINE__, "addModule - user_installer run for " + remoteModuleName, LOG_TYPE_DEBUG);
string cmd = installDir + "/bin/package_installer.sh " + remoteModuleName + " " + remoteModuleIP + " " + password + " " + version + " initial " + AmazonInstall + " " + packageType + " --nodeps 1 > " + logFile;
@ -5643,7 +5644,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
else
{
// do a binary package install
string logFile = "/tmp/" + remoteModuleName + "_binary_installer.log";
string logFile = tmpLogDir + "/" + remoteModuleName + "_binary_installer.log";
log.writeLog(__LINE__, "addModule - binary_installer run for " + remoteModuleName, LOG_TYPE_DEBUG);
string binservertype = oam.itoa(config.ServerInstallType());
@ -5723,7 +5724,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
{
if ( packageType != "binary" )
{
string logFile = "/tmp/" + remoteModuleName + "_package_installer.log";
string logFile = tmpLogDir + "/" + remoteModuleName + "_package_installer.log";
log.writeLog(__LINE__, "addModule - package_installer run for " + remoteModuleName, LOG_TYPE_DEBUG);
string cmd = installDir + "/bin/package_installer.sh " + remoteModuleName + " " + remoteModuleIP + " " + password + " " + version + " initial " + AmazonInstall + " " + packageType + + " --nodeps 1 > " + logFile;
log.writeLog(__LINE__, "addModule cmd: " + cmd, LOG_TYPE_DEBUG);
@ -5792,7 +5793,7 @@ int ProcessManager::addModule(oam::DeviceNetworkList devicenetworklist, std::str
else
{
// do a binary package install
string logFile = "/tmp/" + remoteModuleName + "_binary_installer.log";
string logFile = tmpLogDir + "/" + remoteModuleName + "_binary_installer.log";
log.writeLog(__LINE__, "addModule - binary_installer run for " + remoteModuleName, LOG_TYPE_DEBUG);
string binservertype = oam.itoa(config.ServerInstallType());
@ -7038,7 +7039,7 @@ void ProcessManager::saveBRM(bool skipSession, bool clearshm)
Oam oam;
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
log.writeLog(__LINE__, "Running reset_locks", LOG_TYPE_DEBUG);
@ -11096,7 +11097,8 @@ int ProcessManager::mountDBRoot(std::string dbrootID)
//send msg to ProcMon if not local module
if ( config.moduleName() == moduleName )
{
string cmd = "export LC_ALL=C;mount " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/mount.txt";
string tmpMount = tmpLogDir + "/mount.txt";
string cmd = "export LC_ALL=C;mount " + startup::StartUp::installDir() + "/data" + dbrootID + " > " + tmpMount;
system(cmd.c_str());
if ( !rootUser)
@ -11105,14 +11107,14 @@ int ProcessManager::mountDBRoot(std::string dbrootID)
system(cmd.c_str());
}
ifstream in("/tmp/mount.txt");
ifstream in(tmpMount);
in.seekg(0, std::ios::end);
int size = in.tellg();
if ( size != 0 )
{
if (!oam.checkLogStatus("/tmp/mount.txt", "already"))
if (!oam.checkLogStatus(tmpMount, "already"))
{
log.writeLog(__LINE__, "mount failed, dbroot: " + dbrootID);
return API_FAILURE;

View File

@ -61,7 +61,7 @@ bool mainResumeFlag;
string USER = "root";
string PMwithUM = "n";
bool startProcMon = false;
string tmpLogDir;
//extern std::string gOAMParentModuleName;
extern bool gOAMParentModuleFlag;
@ -139,6 +139,9 @@ int main(int argc, char** argv)
setlocale(LC_ALL, systemLang.c_str());
//get tmp log directory
tmpLogDir = startup::StartUp::tmpDir();
// create message thread
pthread_t MessageThread;
int ret = pthread_create (&MessageThread, NULL, (void* (*)(void*)) &messageThread, &config);
@ -196,7 +199,7 @@ int main(int argc, char** argv)
string modType = config.moduleType();
//run the module install script
string cmd = startup::StartUp::installDir() + "/bin/module_installer.sh " + " --installdir=" + startup::StartUp::installDir() + " --module=" + modType + " > /tmp/module_installer.log 2>&1";
string cmd = startup::StartUp::installDir() + "/bin/module_installer.sh " + " --installdir=" + startup::StartUp::installDir() + " --module=" + modType + " > " + tmpLogDir + "/module_installer.log 2>&1";
log.writeLog(__LINE__, "run module_installer.sh", LOG_TYPE_DEBUG);
log.writeLog(__LINE__, cmd, LOG_TYPE_DEBUG);

View File

@ -53,6 +53,7 @@ extern string USER;
extern bool HDFS;
extern string PMwithUM;
extern bool startProcMon;
extern string tmpLogDir;
//std::string gOAMParentModuleName;
bool gOAMParentModuleFlag;
@ -914,7 +915,7 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
{
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string cmd = startup::StartUp::installDir() + "/bin/reset_locks > " + logdir + "/reset_locks.log1 2>&1";
system(cmd.c_str());
@ -1545,14 +1546,15 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
// install mysqld rpms if being reconfigured as a um
if ( reconfigureModuleName.find("um") != string::npos )
{
string cmd = startup::StartUp::installDir() + "/bin/post-mysqld-install >> /tmp/rpminstall";
string cmd = startup::StartUp::installDir() + "/bin/post-mysqld-install >> " + tmpLogDir + "/rpminstall";
system(cmd.c_str());
cmd = startup::StartUp::installDir() + "/bin/post-mysql-install >> /tmp/rpminstall";
cmd = startup::StartUp::installDir() + "/bin/post-mysql-install >> " + tmpLogDir + "/rpminstall";
system(cmd.c_str());
cmd = startup::StartUp::installDir() + "/mysql/mysql-Columnstore start > /tmp/mysqldstart";
cmd = startup::StartUp::installDir() + "/mysql/mysql-Columnstore start > " + tmpLogDir + "/mysqldstart";
system(cmd.c_str());
ifstream file ("/tmp/mysqldstart");
string tmpFile = tmpLogDir + "/mysqldstart";
ifstream file (tmpFile);
if (!file)
{
@ -1752,20 +1754,21 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
{
int retry = 1;
string tmpUmount = tmpLogDir + "/umount.log";
for ( ; retry < 5 ; retry++)
{
string cmd = "export LC_ALL=C;umount " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/umount.txt 2>&1";
string cmd = "export LC_ALL=C;umount " + startup::StartUp::installDir() + "/data" + dbrootID + " > " + tmpUmount + " 2>&1";
system(cmd.c_str());
return_status = API_SUCCESS;
if (!oam.checkLogStatus("/tmp/umount.txt", "busy"))
if (!oam.checkLogStatus(tmpUmount, "busy"))
break;
cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1";
cmd = "lsof " + startup::StartUp::installDir() + "/data" + dbrootID + " >> " + tmpUmount + " 2>&1";
system(cmd.c_str());
cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> /tmp/umount.txt 2>&1";
cmd = "fuser -muvf " + startup::StartUp::installDir() + "/data" + dbrootID + " >> " + tmpUmount + " 2>&1";
system(cmd.c_str());
sleep(2);
@ -1779,7 +1782,8 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
{
log.writeLog(__LINE__, "unmount failed, device busy, DBRoot: " + dbrootID, LOG_TYPE_ERROR);
return_status = API_FAILURE;
system("mv -f /tmp/umount.txt /tmp/umount_failed.txt");
string cmd = "mv -f " + tmpUmount + " " + tmpUmount + "failed";
system(cmd.c_str());
}
}
else
@ -1820,7 +1824,8 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
if (DataRedundancyConfig == "n")
{
string cmd = "export LC_ALL=C;mount " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/mount.txt 2>&1";
string tmpMount = tmpLogDir + "/mount.log";
string cmd = "export LC_ALL=C;mount " + startup::StartUp::installDir() + "/data" + dbrootID + " > " + tmpMount + "2>&1";
system(cmd.c_str());
if ( !rootUser)
@ -1830,18 +1835,19 @@ void ProcessMonitor::processMessage(messageqcpp::ByteStream msg, messageqcpp::IO
}
return_status = API_SUCCESS;
ifstream in("/tmp/mount.txt");
ifstream in(tmpMount);
in.seekg(0, std::ios::end);
int size = in.tellg();
if ( size != 0 )
{
if (!oam.checkLogStatus("/tmp/mount.txt", "already"))
if (!oam.checkLogStatus(tmpMount, "already"))
{
log.writeLog(__LINE__, "mount failed, DBRoot: " + dbrootID, LOG_TYPE_ERROR);
return_status = API_FAILURE;
system("mv -f /tmp/mount.txt /tmp/mount_failed.txt");
string cmd = "mv -f " + tmpMount + " " + tmpMount + "failed";
system(cmd.c_str());
}
}
}
@ -2582,7 +2588,7 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName,
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string cmd = startup::StartUp::installDir() + "/bin/reset_locks > " + logdir + "/reset_locks.log1 2>&1";
system(cmd.c_str());
@ -2654,7 +2660,7 @@ pid_t ProcessMonitor::startProcess(string processModuleType, string processName,
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string outFileName = logdir + "/" + processName + ".out";
string errFileName = logdir + "/" + processName + ".err";
@ -3830,7 +3836,7 @@ int ProcessMonitor::buildSystemTables()
{
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string cmd = startup::StartUp::installDir() + "/bin/dbbuilder 7 > " + logdir + "/dbbuilder.log &";
system(cmd.c_str());
@ -4683,7 +4689,7 @@ int ProcessMonitor::runStartupTest()
//run startup test script
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string cmd = startup::StartUp::installDir() + "/bin/startupTests.sh > " + logdir + "/startupTests.log1 2>&1";
system(cmd.c_str());
@ -4752,7 +4758,7 @@ int ProcessMonitor::runHDFSTest()
string logdir("/var/log/mariadb/columnstore");
if (access(logdir.c_str(), W_OK) != 0) logdir = "/tmp";
if (access(logdir.c_str(), W_OK) != 0) logdir = tmpLogDir;
string hdfslog = logdir + "/hdfsCheck.log1";
@ -5015,48 +5021,6 @@ void ProcessMonitor::checkModuleFailover( std::string processName)
}
}
/******************************************************************************************
* @brief runUpgrade
*
* purpose: run upgrade script
*
******************************************************************************************/
/*int ProcessMonitor::runUpgrade(std::string mysqlpw)
{
Oam oam;
for ( int i = 0 ; i < 10 ; i++ )
{
//run upgrade script
string cmd = startup::StartUp::installDir() + "/bin/upgrade-columnstore.sh doupgrade --password=" +
mysqlpw + " --installdir=" + startup::StartUp::installDir() + " > " + "/tmp/upgrade-columnstore.log 2>&1";
system(cmd.c_str());
cmd = "/tmp/upgrade-columnstore.log";
if (oam.checkLogStatus(cmd, "OK")) {
log.writeLog(__LINE__, "upgrade-columnstore.sh: Successful return", LOG_TYPE_DEBUG);
return oam::API_SUCCESS;
}
else {
if (oam.checkLogStatus(cmd, "ERROR 1045") ) {
log.writeLog(__LINE__, "upgrade-columnstore.sh: Missing Password error, return success", LOG_TYPE_DEBUG);
return oam::API_SUCCESS;
}
log.writeLog(__LINE__, "upgrade-columnstore.sh: Error return, check log /tmp/upgrade-status.log", LOG_TYPE_ERROR);
//restart mysqld and retry
try {
oam.actionMysqlCalpont(MYSQL_RESTART);
}
catch(...)
{}
sleep(1);
}
}
return oam::API_FAILURE;
}
*/
/******************************************************************************************
* @brief changeMyCnf
*
@ -5239,13 +5203,13 @@ int ProcessMonitor::runMariaDBCommandLine(std::string command)
if ( MySQLPort.empty() )
MySQLPort = "3306";
string cmd = startup::StartUp::installDir() + "/bin/mariadb-command-line.sh --installdir=" + startup::StartUp::installDir() + " --command='" + command + "' --port=" + MySQLPort + " > /tmp/mariadb-command-line.sh.log 2>&1";
string cmd = startup::StartUp::installDir() + "/bin/mariadb-command-line.sh --installdir=" + startup::StartUp::installDir() + " --command='" + command + "' --port=" + MySQLPort + " > " + tmpLogDir + "/mariadb-command-line.sh.log 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
string logFile = "/tmp/mariadb-command-line.sh.log";
string logFile = tmpLogDir + "/mariadb-command-line.sh.log";
if (oam.checkLogStatus(logFile, "ERROR 1045") )
{
@ -5261,7 +5225,7 @@ int ProcessMonitor::runMariaDBCommandLine(std::string command)
}
else
{
log.writeLog(__LINE__, "mariadb-command-line.sh: Error return, check log /tmp/mariadb-command-line.sh.log", LOG_TYPE_ERROR);
log.writeLog(__LINE__, "mariadb-command-line.sh: Error return, check log " + tmpLogDir + "/mariadb-command-line.sh.log", LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
}
@ -5349,8 +5313,8 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
{
string ipAddr = (*pt1).IPAddr;
string logFile = "/tmp/master-rep-columnstore-" + moduleName + ".log";
string cmd = startup::StartUp::installDir() + "/bin/master-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --hostIP=" + ipAddr + " --port=" + MySQLPort + " > " + logFile + " 2>&1";
string logFile = tmpLogDir + "/master-rep-columnstore-" + moduleName + ".log";
string cmd = startup::StartUp::installDir() + "/bin/master-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --hostIP=" + ipAddr + " --port=" + MySQLPort + " --tmpdir=" + tmpLogDir + " > " + logFile + " 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
@ -5388,13 +5352,14 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
// File Position Binlog_Do_DB Binlog_Ignore_DB
// mysql-bin.000006 2921
//
// in log - /tmp/show-master-status.log
// in log - show-master-status.log
ifstream file ("/tmp/show-master-status.log");
string masterLog = tmpLogDir + "/show-master-status.log";
ifstream file (masterLog);
if (!file)
{
log.writeLog(__LINE__, "runMasterRep - show master status log file doesn't exist - /tmp/show-master-status.log", LOG_TYPE_ERROR);
log.writeLog(__LINE__, "runMasterRep - show master status log file doesn't exist - " + masterLog, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
else
@ -5439,7 +5404,7 @@ int ProcessMonitor::runMasterRep(std::string& masterLogFile, std::string& master
file.close();
}
log.writeLog(__LINE__, "runMasterRep - 'mysql-bin not found in log file - /tmp/show-master-status.log", LOG_TYPE_ERROR);
log.writeLog(__LINE__, "runMasterRep - 'mysql-bin not found in log file - " + masterLog, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
@ -5491,14 +5456,14 @@ int ProcessMonitor::runSlaveRep(std::string& masterLogFile, std::string& masterL
while (true)
{
string cmd = startup::StartUp::installDir() + "/bin/slave-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --masteripaddr=" + masterIPAddress + " --masterlogfile=" + masterLogFile + " --masterlogpos=" + masterLogPos + " --port=" + MySQLPort + " > /tmp/slave-rep-columnstore.log 2>&1";
string logFile = tmpLogDir + "/slave-rep-columnstore.log";
string cmd = startup::StartUp::installDir() + "/bin/slave-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --masteripaddr=" + masterIPAddress + " --masterlogfile=" + masterLogFile + " --masterlogpos=" + masterLogPos + " --port=" + MySQLPort + " --tmpdir=" + tmpLogDir + " > " + logFile + " 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
string logFile = "/tmp/slave-rep-columnstore.log";
if (oam.checkLogStatus(logFile, "ERROR 1045") )
{
if ( passwordError )
@ -5519,7 +5484,7 @@ int ProcessMonitor::runSlaveRep(std::string& masterLogFile, std::string& masterL
}
else
{
log.writeLog(__LINE__, "slave-rep-columnstore.sh: Error return, check log /tmp/slave-rep-columnstore.log", LOG_TYPE_ERROR);
log.writeLog(__LINE__, "slave-rep-columnstore.sh: Error return, check log " + logFile, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
}
@ -5555,15 +5520,15 @@ int ProcessMonitor::runDisableRep()
if ( MySQLPort.empty() )
MySQLPort = "3306";
string cmd = startup::StartUp::installDir() + "/bin/disable-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " > /tmp/disable-rep-columnstore.log 2>&1";
string logFile = tmpLogDir + "/disable-rep-columnstore.log";
string cmd = startup::StartUp::installDir() + "/bin/disable-rep-columnstore.sh --installdir=" + startup::StartUp::installDir() + " --tmpdir=" + tmpLogDir + " > " + logFile + " 2>&1";
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
cmd = "/tmp/disable-rep-columnstore.log";
if (oam.checkLogStatus(cmd, "OK"))
if (oam.checkLogStatus(logFile, "OK"))
{
log.writeLog(__LINE__, "disable-rep-columnstore.sh: Successful return", LOG_TYPE_DEBUG);
return oam::API_SUCCESS;
@ -5576,7 +5541,7 @@ int ProcessMonitor::runDisableRep()
return oam::API_SUCCESS;
}
log.writeLog(__LINE__, "disable-rep-columnstore.sh: Error return, check log /tmp/disable-rep-columnstore.log", LOG_TYPE_ERROR);
log.writeLog(__LINE__, "disable-rep-columnstore.sh: Error return, check log " + logFile, LOG_TYPE_ERROR);
return oam::API_FAILURE;
}
@ -5647,12 +5612,12 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
{
string ipAddr = (*pt1).IPAddr;
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > /tmp/master-dist_" + moduleName + ".log";
string logFile = tmpLogDir + "/master-dist_" + moduleName + ".log";
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > " + logFile;
log.writeLog(__LINE__, "cmd = " + cmd, LOG_TYPE_DEBUG);
system(cmd.c_str());
string logFile = "/tmp/master-dist_" + moduleName + ".log";
if (!oam.checkLogStatus(logFile, "FAILED"))
{
@ -5686,10 +5651,10 @@ int ProcessMonitor::runMasterDist(std::string& password, std::string& slaveModul
HostConfigList::iterator pt1 = moduleconfig.hostConfigList.begin();
string ipAddr = (*pt1).IPAddr;
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > /tmp/master-dist_" + slaveModule + ".log";
system(cmd.c_str());
string logFile = tmpLogDir + "/master-dist_" + slaveModule + ".log";
string logFile = "/tmp/master-dist_" + slaveModule + ".log";
string cmd = startup::StartUp::installDir() + "/bin/rsync.sh " + ipAddr + " " + password + " " + startup::StartUp::installDir() + " 1 > " + logFile;
system(cmd.c_str());
if (!oam.checkLogStatus(logFile, "FAILED"))
log.writeLog(__LINE__, "runMasterDist: Success rsync to module: " + slaveModule, LOG_TYPE_DEBUG);
@ -5722,7 +5687,8 @@ bool ProcessMonitor::amazonIPCheck()
log.writeLog(__LINE__, "amazonIPCheck function called", LOG_TYPE_DEBUG);
// delete description file so it will create a new one
unlink("/tmp/describeInstance.txt");
string tmpLog = tmpLogDir + "/describeInstance.log";
unlink(tmpLog.c_str());
//
// Get Module Info
@ -5949,8 +5915,8 @@ bool ProcessMonitor::amazonVolumeCheck(int dbrootID)
if ( status == "attached" )
{
string cmd;
cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > /tmp/um_mount.log";
string mountLog = tmpLogDir + "/um_mount.log";
cmd = "mount " + deviceName + " " + startup::StartUp::installDir() + "/mysql/db -t ext2 -o defaults > " + mountLog;
system(cmd.c_str());
log.writeLog(__LINE__, "mount cmd: " + cmd, LOG_TYPE_DEBUG);
@ -6318,7 +6284,7 @@ int ProcessMonitor::checkDataMount()
if ( DataRedundancyConfig == "n" )
{
//remove any local check flag for starters
string cmd = "umount " + dbroot + " > /tmp/umount.txt 2>&1";
string cmd = "umount " + dbroot + " > " + tmpLogDir + "/umount.log 2>&1";
system(cmd.c_str());
unlink(fileName.c_str());
@ -6331,17 +6297,18 @@ int ProcessMonitor::checkDataMount()
if (WEXITSTATUS(status) != 0 )
{
// not mounted, mount
cmd = "export LC_ALL=C;mount " + dbroot + " > /tmp/mount.txt 2>&1";
string mountLog = tmpLogDir + "/mount.log";
cmd = "export LC_ALL=C;mount " + dbroot + " > " + mountLog + " 2>&1";
system(cmd.c_str());
ifstream in("/tmp/mount.txt");
ifstream in(mountLog);
in.seekg(0, std::ios::end);
int size = in.tellg();
if ( size != 0 )
{
if (!oam.checkLogStatus("/tmp/mount.txt", "already"))
if (!oam.checkLogStatus(mountLog, "already"))
{
log.writeLog(__LINE__, "checkDataMount: mount failed, DBRoot: " + dbroot, LOG_TYPE_ERROR);
@ -6533,8 +6500,8 @@ int ProcessMonitor::glusterAssign(std::string dbrootID)
moduleIPAddr = sysConfig->getConfig("SystemModuleConfig", dataDupIPaddr);
}
command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" +
dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterAssign.txt 2>&1";
string tmpLog = tmpLogDir + "/glusterAssign.log";
command = "mount -tglusterfs -odirect-io-mode=enable " + moduleIPAddr + ":/dbroot" + dbrootID + " " + startup::StartUp::installDir() + "/data" + dbrootID + " > " + tmpLog + " 2>&1";
int ret = system(command.c_str());
@ -6542,16 +6509,17 @@ int ProcessMonitor::glusterAssign(std::string dbrootID)
{
log.writeLog(__LINE__, "glusterAssign mount failure: dbroot: " + dbrootID + " error: " + oam.itoa(WEXITSTATUS(ret)), LOG_TYPE_ERROR);
ifstream in("/tmp/glusterAssign.txt");
ifstream in(tmpLog);
in.seekg(0, std::ios::end);
int size = in.tellg();
if ( size != 0 )
{
if (!oam.checkLogStatus("/tmp/glusterAssign.txt", "already"))
if (!oam.checkLogStatus(tmpLog, "already"))
{
log.writeLog(__LINE__, "glusterAssign failed.", LOG_TYPE_ERROR);
system("mv -f /tmp/glusterAssign.txt /tmp/glusterAssign_failed.txt");
string cmd = "mv -f " + tmpLog + " " + tmpLog + "failed";
system(cmd.c_str());
return oam::API_FAILURE;
}
}
@ -6576,7 +6544,9 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID)
log.writeLog(__LINE__, "glusterUnassign called: " + dbrootID, LOG_TYPE_DEBUG);
command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > /tmp/glusterUnassign.txt 2>&1";
string tmpLog = tmpLogDir + "/glusterUnassign.log";
command = "umount -f " + startup::StartUp::installDir() + "/data" + dbrootID + " > " + tmpLog + " 2>&1";
int ret = system(command.c_str());
@ -6584,16 +6554,18 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID)
{
log.writeLog(__LINE__, "glusterUnassign mount failure: dbroot: " + dbrootID + " error: " + oam.itoa(WEXITSTATUS(ret)), LOG_TYPE_ERROR);
ifstream in("/tmp/glusterUnassign.txt");
ifstream in(tmpLog);
in.seekg(0, std::ios::end);
int size = in.tellg();
if ( size != 0 )
{
if (!oam.checkLogStatus("/tmp/glusterUnassign.txt", "not mounted"))
if (!oam.checkLogStatus(tmpLog, "not mounted"))
{
log.writeLog(__LINE__, "glusterUnassign failed.", LOG_TYPE_ERROR);
system("mv -f /tmp/glusterUnassign.txt /tmp/glusterUnassign_failed.txt");
string cmd = "mv -f " + tmpLog + " " + tmpLog + "failed";
system(cmd.c_str());
return oam::API_FAILURE;
}
}