Problema na execução de Script

1. Problema na execução de Script

Ronald Misson J[unior
ronaldjr

(usa CentOS)

Enviado em 18/06/2015 - 11:38h

Bom dia,

Estou fazendo a instalação do MariaDB Cluster no Centos 7. No site do MariaDB entrei com as informações dos meus servidores e me foi enviado um script para instalação do banco de dados. Dei uma pesquisada aqui no fórum e encontrei diversas explicações sobre permissões de execução. Porem nenhum surtiu efeito pra mim. Quando executo o script aparece a seguinte mensagem.
" You are running as 'ronald' but the scripts were configured for 'root' - regen ate the scripts with correct user"
Já tentei com meu usuário e tbm como root e da o msm erro. Alguém poderia me ajudar?


  


2. Re: Problema na execução de Script

thinomar
thinomar

(usa Linux Mint)

Enviado em 18/06/2015 - 12:40h

Se você mostrar o script, fica mais fácil de encontrarmos o problema :)
--
sudo make me a sandwich


3. Script em questão

Ronald Misson J[unior
ronaldjr

(usa CentOS)

Enviado em 18/06/2015 - 12:46h

#!/bin/bash
# All files in this package is subject to the GPL v2 license
# More information is in the COPYING file in the top directory of this package.
# Copyright (C) 2011 severalnines.com

hostnames=`cat .s9s/hostnames | grep -v "#"`
source .s9s/help_func
source .s9s/config
if [ "$USER" != "$os_user" ]; then
echo "You are running as '$USER' but the scripts were configured for '$os_user' - regenerate the scripts with the correct user"
exit 1
fi
if [ "$os_user" != "root" ]; then
echo ""
echo "*** IMPORTANT !!!!***"
echo "Can you run 'sudo' without typing password?"
echo "If you are not sure, open a new terminal to $cmon_monitor and run:"
test_host=`cat .s9s/hostnames | grep -v "#" | head -n 1`
echo ""
echo "ssh $IDENTITY3 $os_user@$test_host 'sudo ls /usr/'"
echo ""
echo "- Answer YES if you can run 'sudo' without typing your password."
echo "- Answer NO if you need to specify a password when running 'sudo'."
echo "- If the terminal later on hangs, you have answered wrong on this question. Kill the terminal, login again, and retry."
echo "Can you run 'sudo' without typing passwords (YES/NO)?"
if [ $interactive = "1" ]; then
read answer
else
answer="YES"
if [ "$OS" = "redhat" ]; then
homedir="home/"
if [ "${os_user}" = "root" ]; then
homedir="/"
fi
if [ -f "/${homedir}${os_user}/.ssh/id_rsa_s9s" ]; then
sed -i.bak "s#IDENTITY=.*#IDENTITY='-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
sed -i.bak "s#IDENTITY2=.*#IDENTITY2='-q -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
sed -i.bak "s#IDENTITY3=.*#IDENTITY3='-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
IDENTITY="-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22"
IDENTITY2="-q -i/${homedir}${os_user}/.ssh/id_rsa_s9s -P22"
IDENTITY3="-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22"
fi
fi
fi
if [ $answer = "YES" ] || [ $answer = "NO" ]; then
if [ $answer = "NO" ]; then
echo "You must enter the password (we assume it is the same on _all_ servers in the cluster) for $os_user"
echo "[sudo] password for $os_user:"
read password
sed -i.bak "s#SUDO=.*#SUDO='echo $password | sudo 2>/dev/null -S '#g" .s9s/config
echo "Added to .s9s/config the following:"
echo "SUDO='echo $password | sudo 2>/dev/null -n -S'"
source .s9s/config
echo "At the end of the install you will need to type the password once again."
sleep 1
fi
else
echo "You must answer YES or NO"
exit 1
fi
else
if [ $interactive = "0" -a "$OS" = "redhat" ]; then
SUDO=
sed -i.bak "s#SUDO=.*#SUDO=#g" .s9s/config
fi
fi
validate_cmon_ip "192.168.1.112"
start=`date +%s`
hostnames=`cat .s9s/hostnames | grep -v "#"`
echo "Firewalls must accept $galera_port (galera), $galera_port+1 (galera IST), $ssh_port (ssh), $rsync_port (rsync), $mysql_port (mysql), ping (icmp)."
if [ $firewall -eq 0 ]; then
echo "**** firewall will be disabled! (change in .s9s/config)"
else
echo "**** firewall will be left untouched (you manage the ports)! (change in .s9s/config)"
fi
echo "Starting installation. You will need to answer a few y/n questions."
if [ $interactive = "0" ]; then
homedir="home/"
if [ "${os_user}" = "root" ]; then
homedir="/"
fi
if [ -f "/${homedir}${os_user}/.ssh/id_rsa_s9s" ]; then
sed -i.bak "s#IDENTITY=.*#IDENTITY='-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
sed -i.bak "s#IDENTITY2=.*#IDENTITY2='-q -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
sed -i.bak "s#IDENTITY3=.*#IDENTITY3='-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22'#g" .s9s/config
IDENTITY="-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22"
IDENTITY2="-q -i/${homedir}${os_user}/.ssh/id_rsa_s9s -P22"
IDENTITY3="-qt -t -i/${homedir}${os_user}/.ssh/id_rsa_s9s -p22"
fi
fi
echo "** You may have to enter passwords for ssh now since passwordless ssh may not have been setup yet. **"
echo "SELinux must be set to disabled or targeted before passwordless keys can be setup."
echo "Adding hosts to known hosts and pinging them"
for host in $hostnames
do
check_host $host 1
check_ssh $host
done
check_ssh $cmon_monitor
echo ""
echo ""
echo "Redhat/Centos/Fedora detected - do you want to set SELinux to Permissive mode."
echo "** IF YOU HAVE SELinux == disabled ON ALL HOSTS PRESS 'n' AND IGNORE THE WARNING. **"
echo "(you can set SELinux to Enforcing again later if you want) - 'y' is recommended (y/n): "
if [ $interactive = "1" ]; then
read answer
else
answer="y"
fi
while [ 1 ]; do
if [ "$answer" == "y" ] || [ "$answer" == "n" ]; then break; fi
echo "You must answer y or n: "
read answer
done
if [ "$answer" = "y" ] || [ "$answer" = "n" ]; then
if [ "$answer" = "y" ]; then
echo "You may have to enter passwords now since passwordless ssh has not been setup yet."
echo "SELinux must be disabled before passwordless keys can be setup."
sleep 1
hostnames=`cat .s9s/hostnames | grep -v "#"`
for host in $hostnames
do
remote_cmd2 $host "/usr/sbin/setenforce 0"
remote_cmd2 $host "echo '0' > /selinux/enforce "
remote_cmd2 $host "sed -i.bak 's#SELINUX=enforcing#SELINUX=permissive#g' /etc/selinux/config"
done
remote_cmd2 $cmon_monitor "/usr/sbin/setenforce 0"
remote_cmd2 $cmon_monitor "echo '0' > /selinux/enforce "
remote_cmd2 $cmon_monitor "sed -i.bak 's#SELINUX=enforcing#SELINUX=permissive#g' /etc/selinux/config"
else
echo "Installing with ENFORCING SELinux - the installation may fail. "
echo "Symptoms will be "
echo " - failure to connect to MySQL Servers "
echo " - failure to start Cluster "
echo " - failure to ssh without passwords (passwordless ssh setup later) "
echo " - on CENTOS 6 there is a bug: http://bugs.centos.org/print_bug_page.php?bug_id=4959 "
sleep 2
fi
else
echo "You must answer y or n !"
exit 1
fi
echo ""
echo "Can you SSH from this host to all other hosts without password?"
echo "Choosing 'n' will allow you to setup shared keys. (y/n): "
if [ $interactive = "1" ]; then
read answer
else
answer="y"
fi
while [ 1 ]; do
if [ "$answer" == "y" ] || [ "$answer" == "n" ]; then break; fi
echo "You must answer y or n: "
read answer
done
if [ "$answer" = "y" ] || [ "$answer" = "n" ]; then
if [ "$answer" != "y" ]; then
bash ./shared-ssh-keys.sh
ret=$?
if [ $ret -eq 1 ]; then
exit 1
fi
fi
else
echo "You must answer y or n !"
exit 1
fi
echo "Testing password-less ssh:"
for host in $hostnames
do
test_ssh $host
done
test_ssh $cmon_monitor
for host in $hostnames
do
check_platform $host
done
check_platform $cmon_monitor
echo "Preparing nodes by installing perl, libaio, netcat and rsync"
for host in $hostnames
do
remote_cmd $host "yum -y install perl rsync libaio"
remote_cmd2 $host "yum -y install nc"
remote_cmd2 $host "yum -y install netcat"
remote_cmd2 $host "yum -y install socat"
remote_cmd2 $host "yum -y install pigz"
remote_cmd2 $host "yum -y install perl-Data-Dumper-Names"
done
remote_cmd $cmon_monitor "yum -y install perl rsync libaio wget unzip bind-utils"
remote_cmd2 $cmon_monitor "yum -y install netcat"
remote_cmd2 $cmon_monitor "yum -y install nc"
remote_cmd2 $cmon_monitor "yum -y install socat"
remote_cmd2 $cmon_monitor "yum -y install pigz"
remote_cmd2 $cmon_monitor "yum -y install perl-Data-Dumper-Names"
remote_cmd2 $cmon_monitor "yum -y install psmisc"
echo "Tuning OS"
for host in $hostnames
do
remote_cmd2 $host "sysctl -w vm.swappiness=1"
remote_cmd2 $host "sed -i '/^vm.swappiness/d' /etc/sysctl.conf"
remote_cmd2 $host "/bin/sh -c 'echo vm.swappiness=1 >> /etc/sysctl.conf'"
done
remote_cmd2 $cmon_monitor "sysctl -w vm.swappiness=1"
remote_cmd2 $cmon_monitor "sed -i '/^vm.swappiness/d' /etc/sysctl.conf"
remote_cmd2 $cmon_monitor "/bin/sh -c 'echo vm.swappiness=1 >> /etc/sysctl.conf'"
echo "Creating $S9S_TMPDIR"
for host in $hostnames
do
remote_cmd $host "mkdir -p $S9S_TMPDIR"
remote_cmd $host "chown ${os_user}:${os_user} -R $S9S_TMPDIR"
done
remote_cmd $cmon_monitor "mkdir -p $S9S_TMPDIR"
remote_cmd $cmon_monitor "chown ${os_user}:${os_user} -R $S9S_TMPDIR"
echo "*** REMOVE EXISTING MYSQL PACKAGES"
echo "Do you want to remove existing mysql packages?"
test_host=`cat .s9s/hostnames | grep -v "#" | head -n 1`
echo ""
echo "- Answer YES if you want to remove potentially existing MySQL packages (RECOMMENDED)."
echo "- Answer NO if you don't - installation may FAIL because of dependency problems."
echo -n "Type YES or NO and press ENTER: "
if [ $interactive = "1" ]; then
read answer
else
answer="YES"
fi
while [ 1 ]; do
if [ "$answer" == "YES" ] || [ "$answer" == "NO" ]; then break; fi
echo "You must answer YES or NO: "
read answer
done
if [ $answer = "YES" ]; then
sleep 1
./uninstall-rpm.sh
fi
mkdir -p ../../repo/
wget -c --no-check-certificate --tries=5 -O../../repo/epel-release-6-8.noarch.rpm http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
if [ $? -ne 0 ]; then
echo "download failed - check link and/or that EPEL version."
exit 1
else
for host in $hostnames $cmon_monitor
do
remote_copy ../../repo/epel-release-6-8.noarch.rpm $host $S9S_TMPDIR
remote_cmd2 $host sync
remote_cmd2 $host "rpm -Uvh --force ${S9S_TMPDIR}/epel-release-6-8.noarch.rpm"
remote_cmd $host 'yum install -y socat'
done
fi
sed -ibak "s#wsrep_sst_auth=.*#wsrep_sst_auth=root:${mysql_password}#g" ../../config/my.cnf
bash ./install-rpm.sh
ret=$?
if [ $ret -eq 1 ]; then
exit 1
fi
bash ./bootstrap.sh
ret=$?
if [ $ret -eq 1 ]; then
exit 1
fi
bash ./install-cmon.sh -s
ret=$?
if [ $ret -eq 1 ]; then
exit 1
fi
#bash /usr/bin/s9s_galera --install-notifycc -i1
cd ..
./list-servers.sh
cd install
stop=`date +%s`
total=`expr $stop - $start`
echo "Installation completed in $total seconds"
cat .s9s/greetings



4. Re: Problema na execução de Script

thinomar
thinomar

(usa Linux Mint)

Enviado em 18/06/2015 - 14:23h

Vc ta entrando no primeiro IF. Loga como root e dá um echo $USER, ae mostra aqui a saída.
O script te obriga a executar como root. Se não tá rodando, provavelmente você não está o executando como root ou está usando sudo e seu usuário não está configurado para dar sudo pra root no /etc/sudoers.
--
sudo make me a sandwich


5. Re: Problema na execução de Script

Ronald Misson J[unior
ronaldjr

(usa CentOS)

Enviado em 24/06/2015 - 14:53h

Obrigado pela ajuda,

Estou usando o centoOS 7 com interface gráfica. E mesmo no terminal logado como root, ao dar o comando echo retornava outro usuário. Basto dar logoff de minha conta e acessar como root na interface.

Agradeço novamente






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts