FAQ:NewInstanceMsSql Linux: Difference between revisions

From Wiki_dbSQWare
Jump to navigation Jump to search
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Généralités==
==Generalties==
<br>
<br>
{{Warning | Avant toutes choses, n'allez pas plus loin si vous n'avez pas lu la section [[DbSQWare:Concepts|"Concepts dbSQWare"]] !}}
{{Warning | Before anything, don't go further if you don't have read the first section [[General:Concepts|"dbSQWare Concepts "]] !}}
Dans ce chapitre, on considèrera que SQWareCentral a été installé sur dbsqware@sqwarebox ...


===Limites de cette section===
In this chapter, we will consider that SQWareCentral has been installed on dbsqware@sqwarebox.
Ce chapitre ne traite que de l'ajout d'une nouvelle instance sur un socle déjà paramétré et fonctionnel.<br>
 
<br>
===Limits of this section===
{{Warning | Cette section ne s'applique que pour intégrer des SQL Server fonctionnant sous Linux.
This chapter only deals with adding a new instance to a base that is already configured and functional.<br>
Si vous voulez intégrer un SQL Server fonctionnant sous Linux, utilisez cette FAQ [[Général:FAQ_NouvelleInstanceMsSql| FAQ : Intégration d'une nouvelle instance Sql-Serveur Windows]]}}
Use the portions that apply to your environment, and choose either the automatic or manual method as desired<br>
 
===General operating procedure for integrating a new Sql-Server instance===
There is only the case of remote connection to handle. We make an SQL connection from mssql@sqwarebox via FreeTds (OpenSource TDS connection client).
 
Classic steps:
 
*Setting up the environment
 
*Manual tests
 
*Deployment of the instance
 
You will see that these steps can be handled one by one or in batches!


===MODOP général d'intégration d'une nouvelle instance Sql-Serveur (tournant sous Linux)===
==Integration of an SQL-server instance==
Dans ce cas, on va les traiter comme un MySQL ou un PostgreSQL Linux ...<br/>
On va faire une connexion ssh pour aller sur la machine et utiliser le client "sqlcmd".<br/>
Si vous ne voulez faire que de la "commande à distance", suivez le MODOP Windows.


Etapes classiques :
===Setting up the environment===
*Mise en place de l'environnement
*Tests "manuels"
*Mise en exploitation de l'instance
Vous verrez que ces étapes peuvent être traitée une par une ou par batch !


==Intégration d'une instance Sql-Serveur==
====General====


===Mise en place de l'environnement===
=====Explanation of "DbAlias" (the unique dbSQWare key)=====
====Général====
The dbSQWare key must be unique and must match the entry configured in the freetds.conf file to connect to the instance.
=====Explication du "DbAlias" (la clé unique dbSQWare)=====
Generally, when there is no named instance, we use the name of the Windows host that holds the instance. When there is a named instance, we concatenate the name of the Windows host and the instance name, separated by an underscore (do not use a backslash, we are on Linux!)."<br/>
La clé dbSQWare doit être unique et doit correspondre avec l’entrée paramétrée dans le freetds.conf pour se connecter à l’instance.<br/>
Examples :
En général, quand on n’a pas d’instance nommée on met le nom du host windows qui porte l’instance et quand on a une instance nommée, on concatène le nom du host windows et le nom de l’instance séparé par un underscore (ne pas mettre de backslash, on est sous Linux !).<br/>
<br/>
Exemples :
*WINMSQ => WINMSQ (status ON/LINUX)
*WINMSQ => WINMSQ (status ON/LINUX)
*WINMSQ\INST1 => WINMSQ_INST1 (status ON/LINUX)
*WINMSQ\INST1 => WINMSQ_INST1 (status ON/LINUX)


=====Explication des statuts=====
=====Explanation of statuses=====
*Classiquement, pour Sql-Serveur, le statut est "ON" sous Windows et "LINUX" sous Linux ...<br/>
Classically, for SQL Server, the status is 'ON'<br/>
*Le statut "OFF" fait "disparaître" l’instance de la visu web.<br/>
The 'OFF' status makes the instance disappear from the web view.<br/>
*Le statut "NEW_LINUX" est utilisé comme statut intermédiaire entre le début et la fin du paramétrage d'une nouvelle instance.<br/>
The 'NEW' status is used as an intermediate status between the beginning and the end of setting up a new instance.<br/>
*Tous les autres statuts permettent d’afficher l’instance dans le référentiel (notamment "KEEP") mais ne seront pas pris en compte par les traitements automatiques.<br/>
All other statuses allow the instance to be displayed in the repository (especially 'KEEP'), but they will not be taken into account by the automatic processes."<br/>
<br/>
<br/>
Résumé des statuts :<br/>
Resume of statuses :<br/>
{| align="center" {{Prettytable}}
{| align="center" {{Prettytable}}
|-
|-
| '''Statut'''  
| '''Statut'''  
| '''Description'''  
| '''Description'''  
|-
| ON
| le statut quand l'instance (Windows) est en exploitation
|-
|-
| LINUX
| LINUX
| le statut quand l'instance (Linux) est en exploitation
| locale instance(under Unix only)
|-
|-
| KEEP
| KEEP
| statut temporaire, lors d'une maintenance par exemple ou avant suppression complète
| temporary status, during maintenance for example or before complete deletion
|-
|-
| NEW
| NEW
| statut temporaire, lors du paramétrage (windows)
| temporary status, during configuration
|-
|-
| NEW_LINUX
| NEW_LINUX
| statut temporaire, lors du paramétrage (Linux)
| temporary status, during configuration (under Unix only)
|-
|-
| OFF
| OFF
| suppression visuelle de l'instance (sans suppression de son paramétrage)
| visual removal of the instance (without deleting its configuration)
|-
|-
| XXX
| XXX
| non pris en charge ...
| not supported...
|}
|}


====Déclaration de l'instance dans SQWareRepository avec SQWareWeb====
====Instance declaration in SQWareRepository with SQWareWeb====
Nous allons déclarer la nouvelle instance depuis l'interface d'administration de SQWareWeb.<br/>
We will declare the new instance from the SQWareWeb administration interface.<br/>
[[Fichier:Admin_dbSQWare.png||admin|Lien vers la console d'administration]]<br/>
[[File:Admin dbSQWare.png||admin|Admin dbSQWare]]
 
<br/>


Déclarez la nouvelle instance en statut "NEW_LINUX" (Ajout ou Duplicate)<br/>
Declare the new instance with the status "NEW" (Add or Duplicate).<br/>
[[Fichier:AjoutInstance.png||admin|Ajout d'une instance]]
[[File:AjoutInstance.png||admin|Ajout d'une instance]]
[[Fichier:DuplicateInstance.png||admin|Ajout par duplication d'une instance]]<br/>
[[File:DuplicateInstance.png||admin|Ajout par duplication d'une instance]]<br/>
[[Fichier:DeclarationInstanceMsSqlLinux.png|adminSql-Serveur|Déclaration de la nouvelle instance Sql-Serveur]]
[[File:DeclarationInstanceMsSqlLinux.png|admin|Add a new instance by duplicate an other one.]]<br/>


Explication des champs :<br/>
Explanation of the fields :<br/>
{| align="center" {{Prettytable}}
{| align="center" {{Prettytable}}
|-
|-
| '''Champ'''  
| '''Fields'''  
| '''Description'''  
| '''Description'''  
|-
|-
| Db Alias
| Db Alias
| Clé unique qui identifie l'instance dans dbSQWare
| Unique key that identifies the instance in dbSQWare (no value for MySQL/MariaDB).
|-
|-
| Dbms Name
| Dbms Name
| Type de SGBD
| Type of SGBD
|-
|-
| Virtual Host
| Virtual Host
| Host virtuel (meme que Host)
| Virtual Host (same as Host if not clustered)
|-
|-
| Host Name
| Host Name
| Hostname de l'instance
| Hostname of the instance
|-
|-
| User Name
| User Name
| User qui porte l'instance (ne sert pas pour Sql-Serveur)
| User associated with the instance
|-
|-
| Port
| Port
| Port d'écoute de l'instance (sera utilisé pour la génération du freetds.conf)
| Listening port of the instance.
|-
|-
| Comments
| Comments
| Une courte description de ce que porte l'instance
| A brief description of what the instance hosts
|-
|-
| Status
| Status
| Instance statut (cf plus haut pour les explications)
| Instance status (see above for explanations).
|-
|-
| Contact
| Contact
| Un contact si besoin
| A contact if needed
|-
|-
| Environnement
| Environnement
| Environnement de l'instance (PRD, PPR, REC, DEV, TST, ...)
| Instance environment (PRD, PPR, REC, DEV, TST, ...)
|-
|-
| Client
| Client
| Utilisé uniquement pour filtrer (mettre un nom de client et/ou de département et/ou service ...
| Used only for filtering (enter a client name and/or department and/or service...)
|-
|-
| GlobalHost
| GlobalHost
| Champ libre dans lequel on met souvent l'hôte de hyperviseur par exemple
| Free field in which the hypervisor host is often entered, for example.
|-
|-
| Custom1
| Custom1
| Champ libre 1
| Free field 1
|-
|-
| Custom2
| Custom2
| Champ libre 2
| Free field 2
|}
|}
=====Regénérer les fichiers de référence de SQWareCentral=====
=====Regenerate the reference files of SQWareCentral.=====
Tapez la commande suivante qui va générer les fichiers de référence :
Type the following command which will generate the reference files:
 
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
Line 131: Line 133:
</syntaxhighlight>
</syntaxhighlight>


===Procédure spécifique pour la partie "locale" (statut LINUX)===
====Verification of system prerequisites for the "local" part (bash + rsync)====
/!\ Uniquement que les instances qui seront en statut "LINUX" !<br/>
Since SQWareProduction is mainly written in bash shell and synchronized from SQWareCentral using rsync, we therefore need "bash" and "rsync" to be installed !
 
====Vérification des prérequis système pour la partie "locale" (bash + rsync)====
SQWareProduction étant écrit essentiellement en shell bash et étant synchronisé depuis SQWareCentral avec rsync, il nous faut donc "bash" et "rsync" installés !


=====Vérification=====
=====Verification=====
Adaptez à votre nom de user et nom de machine.<br>
Adapt to your username and machine name.<br>
<br>
<br>
bash:
bash:
Line 144: Line 143:
# From : mssql@my_mssql_host
# From : mssql@my_mssql_host
type bash
type bash
#ou
#or
which bash
which bash
</syntaxhighlight>
</syntaxhighlight>
Line 151: Line 150:
# mssql@my_mssql_host
# mssql@my_mssql_host
type rsync
type rsync
#ou
#or
which rsync
which rsync
</syntaxhighlight>
</syntaxhighlight>


=====Installation=====
=====Installation=====
Adaptez à votre type de machine (sudo si vous n'êtes pas root).<br/>
Adapt to your machine type (use sudo if you are not root).<br/>
<br>
<br>
RedHat / CentOS / ... :
RedHat / CentOS / ... :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line># From : root@my_mssql_host
# From : root@my_mssql_host
yum install -y bash rsync
yum install -y bash rsync
#ou
#or
dnf install -y bash rsync
dnf install -y bash rsync</syntaxhighlight>
</syntaxhighlight>
 
Ubuntu / Debian / ... :
Ubuntu / Debian / ... :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : root@my_mssql_host
# From : root@my_mssql_host
apt install -y bash rsync
apt install -y bash rsync
</syntaxhighlight>
</syntaxhighlight>


====Déploiement de(s) clé(s) ssh de SQWareCentral vers la/les machine(s) cible(s)====
====Deployment of SSH key(s) from SQWareCentral to the target machine(s)====
Il existe deux manières de procéder :
There are two ways to proceed:
*Une automatique (depuis dbsqware@sqwarebox mais vous oblige à connaitre le mdp du compte unix mssql)
*An automatic one (from dbsqware@sqwarebox, but it requires you to know the password of the mssql Unix account)
*Une manuelle que vous appliquez sur chaque compte unix mssql
*A manual one that you apply on each mssql Unix account
/!\ Le mdp de votre compte mssql unix doit avoir été initialisé, si non, la connexion par échange de clé ne fonctionnera pas !
/!\ The password of your mssql Unix account must have been initialized, otherwise key-based authentication will not work!


=====Déploiement de(s) clé(s) ssh : méthode batch=====
=====Deployment of SSH key(s): batch method=====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
menu_msq GenDeplSshKeys_SQWareCentral GenLstInstanceNew
menu_msq GenDeplSshKeys_SQWareCentral GenLstInstanceNew
</syntaxhighlight>
</syntaxhighlight>
Vérifiez que c'est bien la liste que vous souhaitez déployer, puis choix 1 ...<br/>
Verify that this is indeed the list you want to deploy, then choose option 1 ...<br/>
=> Entrez le mdp unix quand il vous est demandé !
=> Enter the Unix password when prompted !


=====Déploiement de(s) clé(s) ssh : méthode manuelle=====
=====Deployment of SSH key(s): manual method=====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : mssql@my_mssql_host
# From : mssql@my_mssql_host
Line 198: Line 195:
chmod 600 $HOME/.ssh/authorized_keys
chmod 600 $HOME/.ssh/authorized_keys
</syntaxhighlight>
</syntaxhighlight>
=> Mettre la bonne clé dans le "echo" (celle de dbsqware@sqwarebox)
=> Put the correct key in the "echo" (the one from dbsqware@sqwarebox)


====Test de connexion ssh depuis SQWareCentral====
====SSH connection test from SQWareCentral====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
menu_msq TestSshConnection GenLstInstanceNew
menu_msq TestSshConnection GenLstInstanceNew
</syntaxhighlight>
</syntaxhighlight>
====Test des prérequis sur l'hote cible (ksh+rsync) ssh depuis SQWareCentral====
 
====Test of prerequisites on the target host (bash+rsync) via SSH from SQWareCentral====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
Line 211: Line 209:
</syntaxhighlight>
</syntaxhighlight>


====Déploiement de SQWareProduction====
====Deployment of SQWareProduction====
Déploiement des scripts génériques et ceux spécifiques à sql server dans le $HOME de l'utilisateur renseigné dans SQWareRepository, par exemple mssql.
Deployment of generic scripts and those specific to SQL Server in the $HOME of the user specified in SQWareRepository, for example mssql.<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
menu_msq DeplScripts GenLstInstanceNew
menu_msq DeplScripts GenLstInstanceNew
</syntaxhighlight>
</syntaxhighlight>


====Ajout de l'environnement dbSQWare dans ~/.profile ou ~/.bash_profile====
====Adding the dbSQWare environment to ~/.profile or ~/.bash_profile====
Une nouvelle fois, il existe deux manières de procéder :
Once again, there are two ways to proceed:
*Une automatique (depuis dbsqware@sqwarebox)
*An automatic one (from dbsqware@sqwarebox)
*Une manuelle que vous appliquez sur chaque compte unix mssql
*A manual one that you apply on each mssql Unix account


=====Ajout de l'environnement dbSQWare : méthode batch=====
=====Adding the dbSQWare environment: batch method=====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
menu_msq AdddbSQWareProfile GenLstInstanceNew
menu_msq AdddbSQWareProfile GenLstInstanceNew
</syntaxhighlight>
</syntaxhighlight>
Vérifiez que c'est bien la liste que vous souhaitez déployer, puis choix 1 ...<br/>
Check that this is indeed the list you want to deploy, then choose 1 ...<br/>  
=> Dans ~/.profile ou ~/.bash_profile, changez la variable suivante avec la valeur adaptée : gvsqw_Env='XXX'
=> In ~/.profile or ~/.bash_profile, change the following variable with the appropriate value: gvsqw_Env='XXX'


=====Ajout de l'environnement dbSQWare : méthode manuelle=====
=====Adding the dbSQWare environment: manual method=====  
Ajoutez les lignes suivantes dans le ~/.profile ou ~/.bash_profile
Add the lvsqw_InstanceParam variable to ~/.profile or ~/.bash_profile
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : mssql@my_mssql_host
# From : mssql@my_mssql_host
Line 247: Line 243:
</syntaxhighlight>
</syntaxhighlight>


=====Ajout de la variable lvsqw_InstanceParam=====
=====Adding the lvsqw_InstanceParam variable=====
'''Quelque soit la méthode utilisée :''' ajoutez la variable lvsqw_InstanceParam dans le ~/.profile ou ~/.bash_profile
'''Regardless of the method used:''' add the lvsqw_InstanceParam variable to ~/.profile or ~/.bash_profile
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : mssql@my_mssql_host
# From : mssql@my_mssql_host
Line 254: Line 250:
</syntaxhighlight>
</syntaxhighlight>


====Création d'un compte Sql-Serveur spécifique dbSQWare====
====Creating the Connection to the SQL Instance====
/!\ Vous pouvez aussi utiliser un compte existant comme "sa" !<br/>
You have two options for connecting dbSQWare to your SQL Server instances:
Exemple d'ordre de création :
* Creating an SQL account within the instance requires that mixed login be enabled.
* Using a service account (declared in Active Directory).
=====Creating a Specific dbSQWare SQL Server Account=====
/!\ SQL access must be authorized on the instances if it is not already enabled!<br/>
Example creation order :
<syntaxhighlight lang="sql" line>
<syntaxhighlight lang="sql" line>
USE [master]
USE [master]
Line 265: Line 265:
GO
GO
</syntaxhighlight>
</syntaxhighlight>
'sysadmin' est obligatoire à cause notamment des commandes "DBCC".
'sysadmin' is mandatory, particularly because of the commands "DBCC".


Vous pouvez mettre le nom et le mot de passe que vous souhaitez !<br/>
You can use any username and password you like!<br/>
Ce compte devra être déclaré sur le compte unix mssql@sqwarebox ...<br/>
This account must be registered under the Unix account mssql@sqwarebox...<br/>
Si une entrée spécifique est trouvée c'est elle sui est prise, si non, on prend l'entrée "DEFAULT".<br/>
If a specific entry is found, it will be used; otherwise, the "DEFAULT" entry will be used.<br/>
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
mssql@my_mssql_host:/home/mssql (NoSID) $ cat .passwd_mssql
mssql@sqwarebox:/home/mssql (NoSID) $ cat .passwd_mssql
DEFAULT;msq_dba;NePasMettreCePassword!
DEFAULT;msq_dba;NePasMettreCePassword!
SPECIFIC_MSSQL;sa;sapass
SPECIFIC_MSSQL;sa;sapass
</syntaxhighlight>
</syntaxhighlight>


====Test sendmail (non obligatoire)====
=====Creating a connection with a specific dbSQWare service account=====
Example of creation order :
<syntaxhighlight lang="sql" line>
USE [master]
GO
CREATE LOGIN [domain\svc-dbsqware] FROM WINDOWS;
GO
EXEC master..sp_addsrvrolemember @loginame = N'domain\svc-dbsqware', @rolename = N'sysadmin'
GO
</syntaxhighlight>
The 'sysadmin' account is mandatory, particularly due to the "DBCC" commands.<br/>
<br/>
This account must be registered under the Unix account mssql@sqwarebox... <br/>
If a specific entry is found, it is used; otherwise, the "DEFAULT" entry is used.<br/>
<syntaxhighlight lang="sh" line>
mssql@sqwarebox:/home/mssql (NoSID) $ cat .passwd_mssql
DEFAULT;domain\svc-dbsqware;DoNotSetThisPassword!
SPECIFIC_MSSQL;sa;sapass
</syntaxhighlight>
 
====Test sendmail (not mandatory)====
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
Line 282: Line 302:
</syntaxhighlight>
</syntaxhighlight>


====Test de connexion "manuel" à l'instance mssqlQL (connexion "locale")====
===Manual Connection Tests to the SQL Server Instance===
/!\ Uniquement que les instances qui seront en statut "LINUX" !
/!\ Only instances that will be in "LINUX" status!
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
Line 289: Line 309:
</syntaxhighlight>
</syntaxhighlight>


==Mise en exploitation de l'instance==
==Instance deployment==
===Génération de la configuration par défaut SQWareProduction===
===Generating the default SQLwareProduction configuration===
/!\ Uniquement que les instances qui seront en statut "LINUX" !
/!\ Only instances that will be in "LINUX" status!
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
Line 297: Line 317:
</syntaxhighlight>
</syntaxhighlight>


===Mise à jour de SQWareRepository===
===Updating SQWareRepository===
Dans le repository dbSQWare via la console d’administration, mettre à jour le statut de la nouvelle instance MsSql (à NEW_LINUX actuellement) avec la valeur LINUX.
In the dbSQWare repository via the administration console, update the status of the new SQL Server instance (currently NEW_LINUX) to '''LINUX'''.


===Test de "reprise" des indicateurs===
===Testing the "recovery" of indicators===
A ce moment là, vous pouvez tester la reprise des indicateurs manquants (en principe, uniquement les instances que vous venez d'intégrer !)
At this point, you can test the recovery of missing indicators (generally, only the instances you just integrated!).
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From : dbsqware@sqwarebox
# From : dbsqware@sqwarebox
## Pour les statuts "LINUX"
## For status "LINUX"
repind_msq
repind_msq
</syntaxhighlight>
</syntaxhighlight>


===Exploitation (stats, backups, …) pour les instance "LINUX"===
===Exploitation (stats, backups, …) LINUX statuses ===
====Génération des conf SQWareProduction====
====Generating SQWareProduction Configurations====
Si vous avez suivi la procédure d’insertion de l’instance, cette partie est déjà fait par l’étape "menu_msq GenDefConf_SQWareProduction GenLstInstanceNew".<br/>
If you followed the instance insertion procedure, this part is already done by the step "menu_msq GenDefConf_SQWareProduction GenLstInstanceNew".<br/>
Vous pouvez vérifier avec le chapitre suivant.<br/>
You can verify this in the following chapter.<br/>
<br/>
<br/> Connect to the central point's Unix machine with the "mssql" account and type the following commands:<br/>
Se connecter à la machine qui porte l'instance « MsSql » et taper les commandes suivantes :<br/>
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
# From dbsqware@vmsqwarebox
# From mssql@vmsqwarebox
c MSSQL_INST1
#Enter the instance name
</syntaxhighlight>
too
 
./sqwmsq_GenerateCreateInstance.ksh -I WINMSQ_INST1
<syntaxhighlight lang="sh" line>
#Source de l'env si multi-instance (from mssql@my_mssql_host)
e MSSQL_INST1
</syntaxhighlight>
</syntaxhighlight>
Verify that the proposed option is correct and type "y" if it is.<br/>
At this point, you have generated the default configuration files for SQWareProduction.


====Explanations====
The previous steps created some default files. ($HOME/admin/WINMSQ_INST1/sqwConfig)
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
too
#Enter the instance name
./sqwmsq_GenerateCreateInstance.ksh -dbsOnly
</syntaxhighlight>
Vérifier que ce qui est proposé est bon et tapez « y » si c’est le cas.<br/>
A ce moment, vous avez généré les fichiers de configuration par défaut de SQWareProduction.
====Explications====
Les étapes précédentes ont créé certains fichiers par défaut. ($HOME/admin/WINMSQ_INST1/sqwConfig)
<syntaxhighlight lang="sh" line>
#Entrez le nom de l’instance
e WINMSQ_INST1
e WINMSQ_INST1
cfg
cfg
Line 366: Line 378:
</syntaxhighlight>
</syntaxhighlight>


C’est un fichier de paramétrage qui est utilisé par le script sqwmsq_RunJob.ksh pour exécuter des actions.<br/>
This is a configuration file used by the sqwmsq_RunJob.ksh script to execute actions.<br/>
<br/>
<br/>  
Fichier pour une cron par défaut $HOME/CrontabRef_WINMSQ_INST1 :
File for a default cron job: $HOME/CrontabRef_WINMSQ_INST1 :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
## mm(0-59) hh(0-23) dd(1-31) MM(0-12) DAY(0-sunday, 1-monday, ...) command
## mm(0-59) hh(0-23) dd(1-31) MM(0-12) DAY(0-sunday, 1-monday, ...) command
Line 380: Line 392:
</syntaxhighlight>
</syntaxhighlight>


====Paramétrage du chemin des backups====
====Setting the backup path====


Test avec backup de master :
Backup test with master :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
#From mssql@my_mssql_host
#From mssql@vmsqwarebox
$gvsqw_MsqBin/sqwmsq_BackupDatabase.ksh -I WINMSQ_INST1 -D master -Type full -Exec
$gvsqw_MsqBin/sqwmsq_BackupDatabase.ksh -I WINMSQ_INST1 -D master -Type full -Exec
</syntaxhighlight>
</syntaxhighlight>


/!\ Faites attention pour cette partie, si vous n'êtes pas sûrs, ne faites rien :
/!\ Be careful with this part; if you're not sure, don't do anything :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
#From mssql@my_mssql_host pour passer toutes les databases en 'RECOVERY SIMPLE'
#From mssql@vmsqwarebox pour passer toutes les databases en 'RECOVERY SIMPLE'
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseRecoverySimple.ksh -I WINMSQ_INST1 -Exec
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseRecoverySimple.ksh -I WINMSQ_INST1 -Exec


#From mssql@my_mssql_host pour modifier l'autogrowth toutes les logs de % en Mo
#From mssql@vmsqwarebox pour modifier l'autogrowth toutes les logs de % en Mo
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseModifyLogGrowth.ksh -I WINMSQ_INST1 -Exec
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseModifyLogGrowth.ksh -I WINMSQ_INST1 -Exec


#From mssql@my_mssql_host faire un SHRINK de toutes les logs
#From mssql@vmsqwarebox faire un SHRINK de toutes les logs
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseShrinkLogs.ksh -I WINMSQ_INST1 -Exec
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseShrinkLogs.ksh -I WINMSQ_INST1 -Exec
</syntaxhighlight>
</syntaxhighlight>


====Mise en exploitation====
====Deployment====
Mise en place de la cron :
Setting up the cron :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
crontab -l > $HOME/CrontabRef
vi $HOME/CrontabRef_WINMSQ_INST1
vi $HOME/CrontabRef_WINMSQ_INST1
cat $HOME/CrontabRef_WINMSQ_INST1 >> $HOME/CrontabRef
cat $HOME/CrontabRef_WINMSQ_INST1 >> $HOME/CrontabRef
Line 410: Line 423:
</syntaxhighlight>
</syntaxhighlight>


Mise à jour du fichier CrontabRef :
Updating the CrontabRef file :
<syntaxhighlight lang="sh" line>
<syntaxhighlight lang="sh" line>
crontab -l > $HOME/CrontabRef
crontab -l > $HOME/CrontabRef
Line 416: Line 429:
</syntaxhighlight>
</syntaxhighlight>


====Commandes utiles====
====Useful commands====
alias intéressants :
Interesting aliases :
  e DBALIAS => source l'env pour l'instance
  e DBALIAS => Load the environment for the instance
  bin, etc, too ... => pour aller dans arbo SQWareProduction standard
  bin, etc, too ... => To navigate to the standard SQWareProduction directory
  cbin, cetc, ctoo ... => pour aller dans arbo SQWareProduction custom
  cbin, cetc, ctoo ... => To navigate to the custom SQWareProduction directory
  log => logs SQWareProduction
  log => logs SQWareProduction


Quelques options des scripts :
Some script options :
  -h => aide en ligne
  -h => online help
  -s => exemples en ligne
  -s => online examples
  -Exec => lorsque elle est présente, si non settée ne sort que les commandes sans les exécuter
  -Exec => when present, executes the commands; if not set, only shows the commands without executing them.


Exemples :
Examples :
  mssql@my_mssql_host:$HOME/admin/WINMSQ_INST1/logs/StatisticsDatabase (WINMSQ_INST1) $ bin
  mssql@HOSTCENTRAL:$HOME/admin/WINMSQ_INST1/logs/StatisticsDatabase (WINMSQ_INST1) $ bin
  total 112
  total 112
  drwxr-x---  2 dbsqware dba  4096 Sep 25 21:22 .
  drwxr-x---  2 dbsqware dba  4096 Sep 25 21:22 .
Line 439: Line 452:
  ...
  ...


  mssql@my_mssql_host:$HOME/SQWareProduction/mssql/bin (WINMSQ_INST1) $  
  mssql@HOSTCENTRAL:$HOME/SQWareProduction/mssql/bin (WINMSQ_INST1) $  
  ./sqwmsq_StatisticsAllDatabases.ksh -h
  ./sqwmsq_StatisticsAllDatabases.ksh -h
   
   

Latest revision as of 15:51, 8 December 2025

Generalties


Warning:
Before anything, don't go further if you don't have read the first section "dbSQWare Concepts " !.

In this chapter, we will consider that SQWareCentral has been installed on dbsqware@sqwarebox.

Limits of this section

This chapter only deals with adding a new instance to a base that is already configured and functional.
Use the portions that apply to your environment, and choose either the automatic or manual method as desired

General operating procedure for integrating a new Sql-Server instance

There is only the case of remote connection to handle. We make an SQL connection from mssql@sqwarebox via FreeTds (OpenSource TDS connection client).

Classic steps:

  • Setting up the environment
  • Manual tests
  • Deployment of the instance

You will see that these steps can be handled one by one or in batches!

Integration of an SQL-server instance

Setting up the environment

General

Explanation of "DbAlias" (the unique dbSQWare key)

The dbSQWare key must be unique and must match the entry configured in the freetds.conf file to connect to the instance. Generally, when there is no named instance, we use the name of the Windows host that holds the instance. When there is a named instance, we concatenate the name of the Windows host and the instance name, separated by an underscore (do not use a backslash, we are on Linux!)."
Examples :

  • WINMSQ => WINMSQ (status ON/LINUX)
  • WINMSQ\INST1 => WINMSQ_INST1 (status ON/LINUX)
Explanation of statuses

Classically, for SQL Server, the status is 'ON'
The 'OFF' status makes the instance disappear from the web view.
The 'NEW' status is used as an intermediate status between the beginning and the end of setting up a new instance.
All other statuses allow the instance to be displayed in the repository (especially 'KEEP'), but they will not be taken into account by the automatic processes."

Resume of statuses :

Statut Description
LINUX locale instance(under Unix only)
KEEP temporary status, during maintenance for example or before complete deletion
NEW temporary status, during configuration
NEW_LINUX temporary status, during configuration (under Unix only)
OFF visual removal of the instance (without deleting its configuration)
XXX not supported...

Instance declaration in SQWareRepository with SQWareWeb

We will declare the new instance from the SQWareWeb administration interface.
Admin dbSQWare


Declare the new instance with the status "NEW" (Add or Duplicate).
Ajout d'une instance Ajout par duplication d'une instance
Add a new instance by duplicate an other one.

Explanation of the fields :

Fields Description
Db Alias Unique key that identifies the instance in dbSQWare (no value for MySQL/MariaDB).
Dbms Name Type of SGBD
Virtual Host Virtual Host (same as Host if not clustered)
Host Name Hostname of the instance
User Name User associated with the instance
Port Listening port of the instance.
Comments A brief description of what the instance hosts
Status Instance status (see above for explanations).
Contact A contact if needed
Environnement Instance environment (PRD, PPR, REC, DEV, TST, ...)
Client Used only for filtering (enter a client name and/or department and/or service...)
GlobalHost Free field in which the hypervisor host is often entered, for example.
Custom1 Free field 1
Custom2 Free field 2
Regenerate the reference files of SQWareCentral.

Type the following command which will generate the reference files:

# From : dbsqware@sqwarebox
gen_all

Verification of system prerequisites for the "local" part (bash + rsync)

Since SQWareProduction is mainly written in bash shell and synchronized from SQWareCentral using rsync, we therefore need "bash" and "rsync" to be installed !

Verification

Adapt to your username and machine name.

bash:

# From : mssql@my_mssql_host
type bash
#or
which bash

rsync:

# mssql@my_mssql_host
type rsync
#or
which rsync
Installation

Adapt to your machine type (use sudo if you are not root).

RedHat / CentOS / ... :

# From : root@my_mssql_host
yum install -y bash rsync
#or
dnf install -y bash rsync

Ubuntu / Debian / ... :

# From : root@my_mssql_host
apt install -y bash rsync

Deployment of SSH key(s) from SQWareCentral to the target machine(s)

There are two ways to proceed:

  • An automatic one (from dbsqware@sqwarebox, but it requires you to know the password of the mssql Unix account)
  • A manual one that you apply on each mssql Unix account

/!\ The password of your mssql Unix account must have been initialized, otherwise key-based authentication will not work!

Deployment of SSH key(s): batch method
# From : dbsqware@sqwarebox
menu_msq GenDeplSshKeys_SQWareCentral GenLstInstanceNew

Verify that this is indeed the list you want to deploy, then choose option 1 ...
=> Enter the Unix password when prompted !

Deployment of SSH key(s): manual method
# From : mssql@my_mssql_host
if [ ! -r $HOME/.ssh/id_rsa ]
then
ssh-keygen -t rsa -N '' -f $HOME/.ssh/id_rsa
fi
chmod go-w $HOME
echo "ssh-rsa AAAAB......XSPpdV11 dbsqware@sqwarebox" >>$HOME/.ssh/authorized_keys
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys

=> Put the correct key in the "echo" (the one from dbsqware@sqwarebox)

SSH connection test from SQWareCentral

# From : dbsqware@sqwarebox
menu_msq TestSshConnection GenLstInstanceNew

Test of prerequisites on the target host (bash+rsync) via SSH from SQWareCentral

# From : dbsqware@sqwarebox
menu_msq TestSysPrerequisites GenLstInstanceNew

Deployment of SQWareProduction

Deployment of generic scripts and those specific to SQL Server in the $HOME of the user specified in SQWareRepository, for example mssql.

# From : dbsqware@sqwarebox
menu_msq DeplScripts GenLstInstanceNew

Adding the dbSQWare environment to ~/.profile or ~/.bash_profile

Once again, there are two ways to proceed:

  • An automatic one (from dbsqware@sqwarebox)
  • A manual one that you apply on each mssql Unix account
Adding the dbSQWare environment: batch method
# From : dbsqware@sqwarebox
menu_msq AdddbSQWareProfile GenLstInstanceNew

Check that this is indeed the list you want to deploy, then choose 1 ...
=> In ~/.profile or ~/.bash_profile, change the following variable with the appropriate value: gvsqw_Env='XXX'

Adding the dbSQWare environment: manual method

Add the lvsqw_InstanceParam variable to ~/.profile or ~/.bash_profile

# From : mssql@my_mssql_host

#dbSQWare
export gvsqw_MsqBin=$HOME/SQWareProduction/mssql/bin
export gvsqw_Env='PRD'
lvsqw_IsTerminal=$(tty 2>&1 >/dev/null;echo $?)
if [ "$lvsqw_IsTerminal" = "0" ] && [ -r $gvsqw_MsqBin/../etc/.profile_confort ]
then
   . $gvsqw_MsqBin/../etc/.profile_confort
fi
Adding the lvsqw_InstanceParam variable

Regardless of the method used: add the lvsqw_InstanceParam variable to ~/.profile or ~/.bash_profile

# From : mssql@my_mssql_host
export lvsqw_InstanceParam=MSSQL_INST1

Creating the Connection to the SQL Instance

You have two options for connecting dbSQWare to your SQL Server instances:

  • Creating an SQL account within the instance requires that mixed login be enabled.
  • Using a service account (declared in Active Directory).
Creating a Specific dbSQWare SQL Server Account

/!\ SQL access must be authorized on the instances if it is not already enabled!
Example creation order :

USE [master]
GO
CREATE LOGIN [msq_dba] WITH PASSWORD=N'NePasMettreCePassword!', DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
GO
EXEC master..sp_addsrvrolemember @loginame = N'msq_dba', @rolename = N'sysadmin'
GO

'sysadmin' is mandatory, particularly because of the commands "DBCC".

You can use any username and password you like!
This account must be registered under the Unix account mssql@sqwarebox...
If a specific entry is found, it will be used; otherwise, the "DEFAULT" entry will be used.

mssql@sqwarebox:/home/mssql (NoSID) $ cat .passwd_mssql
DEFAULT;msq_dba;NePasMettreCePassword!
SPECIFIC_MSSQL;sa;sapass
Creating a connection with a specific dbSQWare service account

Example of creation order :

USE [master]
GO
CREATE LOGIN [domain\svc-dbsqware] FROM WINDOWS;
GO
EXEC master..sp_addsrvrolemember @loginame = N'domain\svc-dbsqware', @rolename = N'sysadmin'
GO

The 'sysadmin' account is mandatory, particularly due to the "DBCC" commands.

This account must be registered under the Unix account mssql@sqwarebox...
If a specific entry is found, it is used; otherwise, the "DEFAULT" entry is used.

mssql@sqwarebox:/home/mssql (NoSID) $ cat .passwd_mssql
DEFAULT;domain\svc-dbsqware;DoNotSetThisPassword!
SPECIFIC_MSSQL;sa;sapass

Test sendmail (not mandatory)

# From : dbsqware@sqwarebox
menu_msq TestSendmail GenLstInstanceNew

Manual Connection Tests to the SQL Server Instance

/!\ Only instances that will be in "LINUX" status!

# From : dbsqware@sqwarebox
menu_msq TestInstConnectionOnNoMail GenLstInstanceNew

Instance deployment

Generating the default SQLwareProduction configuration

/!\ Only instances that will be in "LINUX" status!

# From : dbsqware@sqwarebox
menu_msq GenDefConf_SQWareProduction GenLstInstanceNew

Updating SQWareRepository

In the dbSQWare repository via the administration console, update the status of the new SQL Server instance (currently NEW_LINUX) to LINUX.

Testing the "recovery" of indicators

At this point, you can test the recovery of missing indicators (generally, only the instances you just integrated!).

# From : dbsqware@sqwarebox
## For status "LINUX"
repind_msq

Exploitation (stats, backups, …) LINUX statuses

Generating SQWareProduction Configurations

If you followed the instance insertion procedure, this part is already done by the step "menu_msq GenDefConf_SQWareProduction GenLstInstanceNew".
You can verify this in the following chapter.

Connect to the central point's Unix machine with the "mssql" account and type the following commands:

# From mssql@vmsqwarebox
#Enter the instance name
too
./sqwmsq_GenerateCreateInstance.ksh -I WINMSQ_INST1

Verify that the proposed option is correct and type "y" if it is.
At this point, you have generated the default configuration files for SQWareProduction.

Explanations

The previous steps created some default files. ($HOME/admin/WINMSQ_INST1/sqwConfig)

#Enter the instance name
e WINMSQ_INST1
cfg
cat sqwmsq_Jobs.cfg
#############################################
#IndicDba: Gather DBAs indicators
IndicDba:$gvsqw_MsqBin/sqwmsq_GatherIndicators.ksh -I WINMSQ_INST1

#RotateErrorLog: Rotate error log
RotateErrorLog:$gvsqw_MsqBin/sqwmsq_RotateErrorLog.ksh -I WINMSQ_INST1 -Exec

#BackupAll: backup all databases
BackupAll:$gvsqw_MsqBin/sqwmsq_BackupAllDatabases.ksh -I WINMSQ_INST1 -Exec

#BackupAllRep: run failed backups from BackupAll
BackupAllRep:$gvsqw_MsqBin/sqwmsq_BackupAllDatabases.ksh -I WINMSQ_INST1 -REP -Exec

#StatisticsAll : update statistics tables for all databases
StatisticsAll:$gvsqw_MsqBin/sqwmsq_StatisticsAllDatabases.ksh -I WINMSQ_INST1 -Exec

#RebuildAll : Rebuild indexes tables for all databases
RebuildAll:$gvsqw_MsqBin/sqwmsq_RebuildIndexAllDatabases.ksh -I WINMSQ_INST1 -Exec

#RestoreParfile : restore list of databases content in parfile
RestoreParfile:$gvsqw_MsqBin/sqwmsq_RestoreAllDatabases.ksh -I WINMSQ_INST1 -PAR $Parfile -Exec

#CheckdbAll : DBCC CheckDB for all databases
CheckdbAll:$gvsqw_MsqBin/sqwmsq_CheckdbAllDatabases.ksh -I WINMSQ_INST1 -Exec

This is a configuration file used by the sqwmsq_RunJob.ksh script to execute actions.

File for a default cron job: $HOME/CrontabRef_WINMSQ_INST1 :

## mm(0-59) hh(0-23) dd(1-31) MM(0-12) DAY(0-sunday, 1-monday, ...) command
## WINMSQ_INST1
# Backup all databases
00 22 * * 1-6  bash -c '. $HOME/.profile ;$gvsqw_MsqBin/sqwmsq_RunJob.ksh -I WINMSQ_INST1 -A BackupAll > $HOME/tmp/BackupAll_WINMSQ_INST1.log 2>&1'
# Rebuild all databases
30 07 * * 6  bash -c '. $HOME/.profile ;$gvsqw_MsqBin/sqwmsq_RunJob.ksh -I WINMSQ_INST1 -A RebuildAll > $HOME/tmp/RebuildAll_WINMSQ_INST1.log 2>&1'
# Stats all databases
00 07 * * 0  bash -c '. $HOME/.profile ;$gvsqw_MsqBin/sqwmsq_RunJob.ksh -I WINMSQ_INST1 -A StatisticsAll > $HOME/tmp/StatisticsAll_WINMSQ_INST1.log 2>&1'

Setting the backup path

Backup test with master :

#From mssql@vmsqwarebox
$gvsqw_MsqBin/sqwmsq_BackupDatabase.ksh -I WINMSQ_INST1 -D master -Type full -Exec

/!\ Be careful with this part; if you're not sure, don't do anything :

#From mssql@vmsqwarebox pour passer toutes les databases en 'RECOVERY SIMPLE'
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseRecoverySimple.ksh -I WINMSQ_INST1 -Exec

#From mssql@vmsqwarebox pour modifier l'autogrowth toutes les logs de % en Mo
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseModifyLogGrowth.ksh -I WINMSQ_INST1 -Exec

#From mssql@vmsqwarebox faire un SHRINK de toutes les logs
$gvsqw_MsqBin/../tools/sqwmsq_AlterDatabaseShrinkLogs.ksh -I WINMSQ_INST1 -Exec

Deployment

Setting up the cron :

crontab -l > $HOME/CrontabRef
vi $HOME/CrontabRef_WINMSQ_INST1
cat $HOME/CrontabRef_WINMSQ_INST1 >> $HOME/CrontabRef
vi $HOME/CrontabRef
crontab $HOME/CrontabRef
crontab -l

Updating the CrontabRef file :

crontab -l > $HOME/CrontabRef
cat $HOME/CrontabRef

Useful commands

Interesting aliases :

e DBALIAS => Load the environment for the instance
bin, etc, too ... => To navigate to the standard SQWareProduction directory
cbin, cetc, ctoo ... => To navigate to the custom SQWareProduction directory
log => logs SQWareProduction

Some script options :

-h => online help
-s => online examples
-Exec => when present, executes the commands; if not set, only shows the commands without executing them.

Examples :

mssql@HOSTCENTRAL:$HOME/admin/WINMSQ_INST1/logs/StatisticsDatabase (WINMSQ_INST1) $ bin
total 112
drwxr-x---  2 dbsqware dba  4096 Sep 25 21:22 .
drwxr-x--- 15 dbsqware dba  4096 Sep 25 21:22 ..
-rwxr-x---  1 dbsqware dba 10858 Sep 25 21:22 sqwmsq_BackupAllDatabases.ksh
-rwxr-x---  1 dbsqware dba  6013 Sep 25 21:22 sqwmsq_BackupDatabase.ksh
-rwxr-x---  1 dbsqware dba  7663 Sep 25 21:22 sqwmsq_CheckdbAllDatabases.ksh
-rwxr-x---  1 dbsqware dba  4809 Sep 25 21:22 sqwmsq_CheckdbDatabase.ksh
...
mssql@HOSTCENTRAL:$HOME/SQWareProduction/mssql/bin (WINMSQ_INST1) $ 
./sqwmsq_StatisticsAllDatabases.ksh -h

Sourcing sqwmsq_Global.lib v2021.02 SQWareProduction for MsSql ...

Usage: sqwmsq_StatisticsAllDatabases.ksh [-h] -S|-I <FreeTdsAlias> [+ options]

DESCRIPTION
   sqwmsq_StatisticsAllDatabases.ksh update Statistics databases in //
SUPPORT
   MsSql supported versions: 2000 <= v <= 2019

PARAMETERS
     -S|-I  Instance    : Target instance (freeTds alias).
OPTIONS
     -h   help          : Display the full usage.
     -s                 : Display samples of usage.
     -P   Nb_threads    : Number of threads in parallel (by default 4).
     -ID  listdb        : Databases list to include.
     -ED  listdb        : Databases list to exclude.
     -IL  likeclause    : Like clause to generate databases list (example: 'db%').
     -EL  likeclause    : Like clause to exclude databases (example: 'nodb%').
     -WCD whereclause   : Where clause to generate databases list.
     -FRT return_code   : Force return code value on error.
     -AddMail email     : Email Address to add at 'xxx'.
     -SendReport        : Send execution log report.
     -PAR parfile       : Parfile file for databases list.
     -AGR Nb_sec        : Nb of seconds between two run (by default 5s).
     -AGE Nb_sec        : Nb of seconds between two check of end (by default 5s).
     -NoMail            : Desactivate sendmail on error xxx (by default, send on error).
     -Exec              : Execute commands (default, display generated commands)

Enjoy !