stop_server.sh

#!/bin/bash
hostname
uptime
echo ===== arret Oracle =====
echo ----- ps oracle ------
ps -ef | grep listener | grep -v grep
ps -ef | grep smon | grep -v grep
echo ----- uptime
uptime
echo ----- stop database
su -l ora102 -l /exploit/scripts/stop_oracle.sh
echo ===== arret Mysql======
echo ----- ps mysqld ------
ps -ef | grep mysqld | grep -v grep
echo ----- uptime
uptime
echo ----- stop database
/exploit/scripts/my_stop_database.sh
echo ----- tempo 600
sleep 600
echo ----- check process oracle
ps -ef | grep listener | grep -v grep
ps -ef | grep smon | grep -v grep
echo ----- check process mysql
ps -ef | grep mysqld | grep -v grep
echo ----- halt
halt

	

start_server.sh

#!/bin/bash
hostname
echo ===== start Oracle =====
echo ----- start database
su -l ora102 -l /exploit/scripts/start_oracle.sh
echo ----- ps oracle ------
ps -ef | grep lsnr | grep -v grep
ps -ef | grep smon | grep -v grep
echo ===== start Mysql======
echo ----- ps mysqld ------
ps -ef | grep mysqld | grep -v grep
echo ----- uptime
uptime
echo ----- start database
/exploit/scripts/my_start_database.sh
echo ----- check process mysql
ps -ef | grep mysqld | grep -v grep

stop_listener.sh

#!/bin/bash
# ==================================================
# Nom : stop_listener.sh
# Objet : arret du listener
# Cree le : 28/01/2010
# Syntaxe : stop_listener.sh
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0"
}
lsnrctl status
lsnrctl stop

start_listener.sh

#!/bin/bash
# ==================================================
# Nom : start_listener.sh
# Objet : demarrage du listener
# Cree le : 28/01/2010
# Syntaxe : start_listener.sh
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0"
}
lsnrctl start
lsnrctl status

stop_oracle.sh

#!/bin/bash
# ==================================================
# Nom : stop_oracle.sh
# Objet : arret des listeners et bases de donnees
# Cree le : 28/01/2010
# Syntaxe : stop_oracle.sh
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0"
}
/exploit/scripts/stop_listener.sh
/exploit/scripts/stop_database.sh KTP
# /exploit/scripts/stop_database.sh STRPRD
/exploit/scripts/stop_database.sh KTPTST
/exploit/scripts/stop_database.sh HYPDEV
/exploit/scripts/stop_database.sh HYPPROD
/exploit/scripts/stop_database.sh EPS
/exploit/scripts/stop_database.sh BIPROD
/exploit/scripts/stop_database.sh ABEL
/exploit/scripts/stop_database.sh BITEST
/exploit/scripts/stop_database.sh SISDEV

start_oracle.sh

#!/bin/bash
# ==================================================
# Nom : start_oracle.sh
# Objet : demarrage des listeners et bases de donnees
# Cree le : 28/01/2010
# Syntaxe : start_oracle.sh
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0"
}
sh /exploit/scripts/start_listener.sh
sh /exploit/scripts/start_database.sh KTP
# sh /exploit/scripts/start_database.sh STRPRD
sh /exploit/scripts/start_database.sh KTPTST
sh /exploit/scripts/start_database.sh HYPDEV
sh /exploit/scripts/start_database.sh HYPPROD
sh /exploit/scripts/start_database.sh EPS
sh /exploit/scripts/start_database.sh BIPROD
sh /exploit/scripts/start_database.sh ABEL
sh /exploit/scripts/start_database.sh BITEST
sh /exploit/scripts/start_database.sh SISDEV

vtom_ulimit.sh

ulimit -u

modifier le fichier /etc/security/limits.conf

teamedu soft nofile 65536
teamedu hard nofile 1048576
vtom soft nofile 65536
vtom hard nofile 1048576

Relancer l’agent Vtom.


Check that /etc/ssh/sshd_config contains:
UsePAM=yes


vtom@vlpdm57x:~> ulimit -a
core file size (blocks, -c) 1
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 983995
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) 107068208
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 16384
virtual memory (kbytes, -v) 121744080
file locks (-x) unlimited

vtom@vlpdm57x:~> cat /etc/sysctl.conf
# Disable response to broadcasts.
# You don’t want yourself becoming a Smurf amplifier.
net.ipv4.icmp_echo_ignore_broadcasts = 1
# enable route verification on all interfaces
net.ipv4.conf.all.rp_filter = 1
# enable ipV6 forwarding
#net.ipv6.conf.all.forwarding = 1
# increase the number of possible inotify(7) watches
fs.inotify.max_user_watches = 65536
# avoid deleting secondary IPs on deleting the primary IP
net.ipv4.conf.default.promote_secondaries = 1
net.ipv4.conf.all.promote_secondaries = 1
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144

stop_server.sh

#!/bin/bash
hostname
uptime
echo ===== arret Mysql======
echo ----- ps mysqld ------
ps -ef | grep mysqld | grep -v grep
echo ----- uptime
uptime
echo ----- stop database
/exploit/scripts/my_stop_database.sh
echo ----- tempo 600
sleep 600
echo ----- check process
ps -ef | grep mysqld | grep -v grep
echo ----- halt
halt

purge_file.sh

#!/bin/bash
# ==================================================
# Nom : purge_file.sh
# Objet : purge de fichier
# Auteur : FAIVELEY - DIGORA
# Cree le : 01/01/2010
# Modifié par : EF le 23/02/2012
# Syntaxe : purge_file.sh repertoire_cible nb_de_jours
# ==================================================
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 repertoire_cible nb_de_jours"
}
# --------------------------
# Verification de la syntaxe
# --------------------------
if [ $# -ne 3 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
# ----------
# Traitement
# ----------
w_rep_purge=$1
w_jour_purge=$2
w_extension=$3
echo w_rep_purge = $1
echo w_jour_purge = $2
echo w_extension = $3
w_prog=`basename $0 .sh`
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
w_log_dest=/exploit/logs
w_log_file=${w_log_dest}/${w_date}_${w_prog}.log
echo " "
echo fichier log : $w_log_file
w_rep_purge=`dirname ${1}/toto`
{
echo `date +"%Y-%m-%d %H:%M:%S"` "- Debut purge du repertoire [${w_rep_purge}] pour les fichiers modifies il y a [${w_jour_purge}] jours ..."
# Recherche et supression des fichiers dans le rep w_rep_purge et qui ont ete modifies il y a $w_jour_purge jours
#
# ------ Modifié + par : EF le 23/02/2012
# ------ on traite tous les extensions de fichier.
#
#if [ "${w_rep_purge}" = "${w_log_dest}" ]
#then
# for v_fic in `find ${w_rep_purge}/ -type f -mtime ${w_jour_purge} -name "*.e"`
# do
# echo " - Suppression du fichier [${v_fic}] ..."
# rm -f ${v_fic}
# done
# for v_fic in `find ${w_rep_purge}/ -type f -mtime ${w_jour_purge} -name "*.o"`
# do
# echo " - Suppression du fichier [${v_fic}] ..."
# rm -f ${v_fic}
# done
# for v_fic in `find ${w_rep_purge}/ -type f -mtime ${w_jour_purge} -name "*.${w_extension}"`
# do
# echo " - Suppression du fichier [${v_fic}] ..."
# rm -f ${v_fic}
# done
#else
# for v_fic in `find ${w_rep_purge}/ -type f -mtime ${w_jour_purge} -name "*.${w_extension}"`
 for v_fic in `find ${w_rep_purge}/ -type f -mtime ${w_jour_purge} -name "*.*"`
 do
 echo " - Suppression du fichier [${v_fic}] ..."
 rm -f ${v_fic}
 done
#fi
# Modifié - par : EF le 23/02/2012
echo `date +"%Y-%m-%d %H:%M:%S"` "- Fin purge du repertoire [${w_rep_purge}] !"
} >${w_log_file} 2>&1
# Pause de 10 secondes : NE PAS SUPPRIMER
sleep 10
cat $w_log_file

my_imp_database.sh

# ==================================================
# Nom :
# Objet :
# Auteur :
# Cree le :
# Syntaxe : user pwd database_FROM_name database_TO_name
# ==================================================
user=$1
pwd=$2
databasefrom=$3
databaseto=$4
w_date=$(date '+%Y%m%d_%H%M%S')
logpath=/exploit/logs
logfile=my_import_${databaseto}_${w_date}.log
dumpfile=/exploit/dumps/my_exp_${databasefrom}.sql
sqlfile=/exploit/logs/my_imp_${databaseto}_${w_date}.sql
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 $1 user $2 pwd $3 database_FROM_name $4 database_TO_name"
}
# ----------------------------------
# --------------------------
# Verification de la syntaxe
# --------------------------
#if [ $# -ne 3 -a $# -ne 4 ]
if [ $# -lt 3 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
echo "-------------------------------------------------"
echo " DROP and CREATE DATABASE $databaseto;"
echo "-------------------------------------------------"
# tee $logpath/$logfile;
#echo "DROP DATABASE if exists $databaseto;">$sqlfile;
#echo "CREATE DATABASE IF NOT EXISTS $databaseto;">>$sqlfile;
#echo "show databases;">>$sqlfile;
#echo "use $databaseto;">>$sqlfile;
#echo "source $dumpfile;">>$sqlfile;
#echo ""
#cat $sqlfile;
#mysql --show-warnings -u $user -p${pwd} <$sqlfile >$logpath/$logfile;
mysql --show-warnings -u $user -p${pwd} << EOF
 warnings;
 DROP DATABASE if exists $databaseto;
 CREATE DATABASE IF NOT EXISTS $databaseto;
 show databases;
 use $databaseto;
 source $dumpfile;
EOF
echo "-------------------------------------------------"
# cat $logpath/$logfile

my_exp_database.sh

#!/bin/bash
# ==================================================
# Nom : my_exp_database.sh
# Objet : export database
# Auteur : N.LAMOTTE
# Cree le : 08/02/2012
# Syntaxe : my_exp_database.sh user pwd database_name (otheroption1, otheroption2, otheroption1otheroption3 not mandatory)
# ==================================================
user=$1
pwd=$2
database=$3
otheroption1=$4
otheroption2=$5
otheroption3=$6
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
logpath=/exploit/logs
dumppath=/exploit/dumps
logfile=my_exp_${database}_${w_date}.log
dumpfile=my_exp_${database}.sql
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 $1 user $2 pwd $3 database_name ($4 otheroption1 $5 otheroption2 $6 otheroption3 not mandatory)"
}
# ----------------------------------
# --------------------------
# Verification de la syntaxe
# --------------------------
#if [ $# -ne 3 -a $# -ne 4 ]
if [ $# -lt 3 ]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
if [ $# -gt 4 ]
then
 echo "mysql with option $otheroption1 $otheroption2 $otheroption3"
 dumpfile=my_exp_${database}_withoption.sql
 logfile=my_exp_${database}_withoption_${w_date}.log
fi
#mysqldump -u $user -p${pwd} $database $otheroption1 $otheroption2 $otheroption3 --log-error=$logpath/$logfile > $dumppath/$dumpfile
mysqldump -u $user -p${pwd} -v $database $otheroption1 $otheroption2 $otheroption3 > $dumppath/$dumpfile

my_exp_database_host.sh

#!/bin/bash
# ==================================================
# Nom : my_exp_database.sh
# Objet : export database
# Auteur : N.LAMOTTE
# Cree le : 08/02/2012
# Syntaxe : my_exp_database.sh user pwd database_name (otheroption1, otheroption2, otheroption1otheroption3 not mandatory)
# ==================================================
user=$1
pwd=$2
database=$3
host=$4
otheroption1=$5
otheroption2=$6
otheroption3=$7
w_date=$(date '+%Y_%m_%d_%H_%M_%S')
logpath=/exploit/logs
dumppath=/exploit/dumps
logfile=my_exp_${database}_${w_date}.log
dumpfile=my_exp_${database}.sql
# ----------------------------------
# Fonction d'affichage de la syntaxe
# ----------------------------------
syntaxe()
{
 echo "Usage : $0 $1 user $2 pwd $3 database_name $4 host ($5 otheroption1 $6 otheroption2 $7 otheroption3 not mandatory)"
}
# ----------------------------------
# --------------------------
# Verification de la syntaxe
# --------------------------
#if [ $# -ne 3 -a $# -ne 4 ]
if [ $# -lt 4]
then
 echo "=================================================="
 echo "ERREUR : Nombre d'arguments incorrects !"
 syntaxe
 echo "=================================================="
 exit 1
fi
if [ $# -gt 5 ]
then
 echo "mysql with option $otheroption1 $otheroption2 $otheroption3"
 dumpfile=my_exp_${database}_withoption.sql
 logfile=my_exp_${database}_withoption_${w_date}.log
fi
#mysqldump -u $user -p${pwd} $database $otheroption1 $otheroption2 $otheroption3 --log-error=$logpath/$logfile > $dumppath/$dumpfile
mysqldump -h $host -u $user -p${pwd} -v $database $otheroption1 $otheroption2 $otheroption3 > $dumppath/$dumpfile

my_ET_tst.sh

w_date=$(date '+%Y_%m_%d_%H_%M_%S')
nb_jour=$1 # Nombre de jour
cmd=$(mysql -u redsrv -pmotdepasse redmine --skip-column-names << EOF
select concat('RAILS_ENV=production rake redmine:plugins:project_extras:reminder_by_ids issues="',group_concat(t1.id SEPARATOR ' '),'" message="blabla" user="ET"')
from issues t1
where datediff(current_date , t1.updated_on) <= $1;
EOF)
echo $cmd
$cmd

my_backup_database.sh

w_date=$(date '+%Y_%m_%d_%H_%M_%S')
# avec generation log
# su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql" > /exploit/logs/my-backup-${w_date}.log
# sans log pour remonter dans VTOM
su mysql --command="mysqlbackup --user=root --password=motdepasse --ibbackup=/opt/mysql/meb-3.5/bin/ibbackup /etc/mysql/my.cnf /data/backups/mysql"