SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Drupal on IIS with a
SQL Server database
           Alessandro Pilotti
              @alexpilotti
          MVP ASP.NET / IIS




   MCSD, MCAD, MCSE, MCDBA, MCT
      Red Hat Certified Engineer
SQL Server and Drupal
 Drupal offers the option to choose the database backend
   No more limited to MySQL
 Drupal 7 provides great support for SQL Server 2008
   All major modules nowadays use PDO and portable SQL
   Works as well with SQL Server 2008 R2 and 2012
 MS provides a PHP PDO driver for SQL Server
 There’s a free Express edition
   Limited to 10GB per database
 SQL Azure
SQL Server for MySQL devs /
         admins
 SQL Server is a relational database like MySQL
 You can write SQL queries
  (SELECT, INSERT, UPDATE DELETE)
   Like for every other DBMS there are some tricky
    differences
     E.g. MySQL is more forgiving in the GROUP BY clause

 Management tools:
   Management Studio
   sqlcmd.exe
Edition comparison
 Express (free)
   Contains everything you need for the average Drupal site
   Limited to 10GB database size, 1GB memory, 1 socket / 4
     cores

 Web
 Standard
 Enterprise
 Feature comparison charts:
   http://msdn.microsoft.com/en-us/library/cc645993.aspx
SQL Server useful features
 Online backup (included also in express edition!)
    Full
    Differential
    Log

 Replication
    Min. standard edition, web and express only as subscribers

 Mirroring
    Min. standard edition

 Log shipping
    Min. web editition

 Great profiling tools
    UI tools in standard edition
Instances
 You can install multiple isolated instances on the same
  server

 Only one can be the default unnamed instance
 All the others are named
 It means that you connect to the server with a name:
   E.g. yourserverSQLEXPRESS
Databases
 SQL Server instances, like MySQL, contain multiple
  databases

 Every Drupal site has usually a separate database
   Or you can use table_prefix of course
 Databases can be moved to different instances
   detached from one
   Attached to the other
 Databases can be put individually offline
Authentication
 Login
     Credentials needed to connect to the instance
     Windows account (integrated)
       No password, best security approach
     SQL server (mixed mode)
       Classic username and password
     Instance wide roles can be assigned to logins

 Database users
     Specific to each database
     Logins are mapped to database users
     Object level (table, etc) permissions are granted to users

 Roles
     A collection of permissions
     Users can be assigned to roles
Main database roles
 db_owner
   Can do everything on the database (not the instance!)
 db_datareader
   Can run SELECT on any table / view
 db_datawriter
   Can run INSERT, UPDATE, DELETE
 db_ddladmin
   Can run any DDL command (CREATE, DROP, etc)
How to create a database
 Very easily with Management Studio
 Via command line:
  sqlcmd –S .SQLEXPRESS –E

  create database drupal7
  create login drupal7 with password = 'Passw0rd’
  go
  use drupal7
  go
  create user drupal7 for login drupal7
  exec sp_addrolemember db_owner, drupal7
  go
Drupal 7 site with SQL Server
        using WebPi

 With just a few click using WebPi
   Add also:
   SQL Server 2008 R2 Management Studio Express with
     SP1
Drupal 7 site with SQL Server
         w/o WebPi
 Create web site
 Download and install SQL Server PDO driver:
   http://www.microsoft.com/en-
    us/download/details.aspx?id=20098

 Enable PHP extensions php_sqlsrv and
  php_pdo_sqlsrv
   Drush @drupal7 dl sqlsrv
   cd your_drupal_site_path
   xcopy /i sitesallmodulessqlsrvsqlsrv
    includesdatabasesqlsrv
Database management
 Schedule proper backup policy
   With or without transaction log
 Schedule maintenance tasks
   Update statistics
   Reindex
   Shrink database
Backup policy
 Schedule a proper backup policy, e.g.:
   Full database backup every night
   Log every 5’ (or more, depending on your db)
   This way you will not lose more than 5’ of data!
 To be able to backup the transaction log, set the
  database recovery model to
   Full or Bulk-Logged
   Default is Simple
Backup
 Use Management Studio
 or
 BACKUP DATABASE [drupal7] TO DISK =
  N'c:backupdrupal7_backup.bak' WITH INIT, NAME =
  N'drupal7-Full Database Backup’

 Store backups on a remote file share!
   To do that run the SQL service with an ad hoc user
   Create the same user on the server with the network
       share
Set recovery model
 Management Studio (very easy)
 T-SQL (e.g. sqlcmd):
  USE [master]
  GO
  ALTER DATABASE [drupal7] SET RECOVERY FULL
  WITH NO_WAIT
How to schedule a backup
 The express edition of SQL Server doesn’t have a UI to schedule
   backups and other tasks

 We can use the windows scheduler to schedule:
    Full backup every night
    Log backup every 5’
    Delete of old backups every night

schtasks.exe /create /tn drupal7_db_backup_full /tr "sqlcmd -S
.SQLExpress -E -i c:backupdrupal7_backup_full.sql" /sc DAILY /ru
Administrator /rp /st 02:00:00

 Useful task commands:
     schtasks.exe /run /tn drupal7_db_backup_full

     schtasks.exe /delete /tn drupal7_db_backup_full
To schedule a log backup

 E.g.: every 15’:
   schtasks.exe /create /tn drupal7_dbbackup_log /tr
     "sqlcmd -S .SQLExpress -E -i
     c:backupdrupal7_backup_log.sql" /sc MINUTE /MO 15
     /ru administrator /rp
Restore a database
 Best done via Management Studio
 Or manually (here’s a complete sample):
      RESTORE DATABASE [drupal7] FROM DISK =
       N'c:backupdrupal7_backup_full_2012_05_15_14_53_06_470.bak' WITH FILE =
       1, NORECOVERY
      GO
      RESTORE DATABASE [drupal7] FROM DISK =
       N'c:backupdrupal7_backup_diff_2012_05_15_14_53_09_867.bak' WITH FILE =
       1, NORECOVERY
      GO
      RESTORE LOG [drupal7] FROM DISK =
       N'c:backupdrupal7_backup_log_2012_05_15_14_53_13_913.trn' WITH FILE =
       1, NORECOVERY
      GO
      RESTORE LOG [drupal7] FROM DISK =
       N'c:backupdrupal7_backup_log_2012_05_15_14_53_15_200.trn' WITH FILE = 1
      GO

Weitere ähnliche Inhalte

Andere mochten auch

Create Website In Indian Languages using drupal
Create Website In Indian Languages using drupalCreate Website In Indian Languages using drupal
Create Website In Indian Languages using drupaldrupalindia
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for DrupalWingston
 
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehill
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehillGeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehill
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehillNikhil Deshpande
 
Moving Drupal to the Cloud
Moving Drupal to the CloudMoving Drupal to the Cloud
Moving Drupal to the CloudAri Davidow
 
Drupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureDrupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureFord AntiTrust
 
Data migration to Drupal using the migrate module
Data migration to Drupal using the migrate moduleData migration to Drupal using the migrate module
Data migration to Drupal using the migrate moduleLuc Bézier
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesdrupalindia
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8Dick Olsson
 
Managing Translation Workflows in Drupal 7
Managing Translation Workflows in Drupal 7Managing Translation Workflows in Drupal 7
Managing Translation Workflows in Drupal 7Suzanne Dergacheva
 
Migration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalMigration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalRachel Jaro
 
Internet Information Server (IIS)
Internet Information Server (IIS)Internet Information Server (IIS)
Internet Information Server (IIS)Rosariio92
 

Andere mochten auch (16)

Create Website In Indian Languages using drupal
Create Website In Indian Languages using drupalCreate Website In Indian Languages using drupal
Create Website In Indian Languages using drupal
 
Migrate
MigrateMigrate
Migrate
 
8 Web Practices for Drupal
8  Web Practices for Drupal8  Web Practices for Drupal
8 Web Practices for Drupal
 
Recipes for Drupal distributions
Recipes for Drupal distributionsRecipes for Drupal distributions
Recipes for Drupal distributions
 
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehill
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehillGeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehill
GeorgiaGov's move to Drupal - presentation by Nikhil Deshpande @nikofthehill
 
Moving Drupal to the Cloud
Moving Drupal to the CloudMoving Drupal to the Cloud
Moving Drupal to the Cloud
 
Drupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows AzureDrupal in the Cloud with Windows Azure
Drupal in the Cloud with Windows Azure
 
Data migration to Drupal using the migrate module
Data migration to Drupal using the migrate moduleData migration to Drupal using the migrate module
Data migration to Drupal using the migrate module
 
Migraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sitesMigraine Drupal - syncing your staging and live sites
Migraine Drupal - syncing your staging and live sites
 
Content Staging in Drupal 8
Content Staging in Drupal 8Content Staging in Drupal 8
Content Staging in Drupal 8
 
Managing Translation Workflows in Drupal 7
Managing Translation Workflows in Drupal 7Managing Translation Workflows in Drupal 7
Managing Translation Workflows in Drupal 7
 
Migration from Legacy CMS to Drupal
Migration from Legacy CMS to DrupalMigration from Legacy CMS to Drupal
Migration from Legacy CMS to Drupal
 
IIS
IISIIS
IIS
 
Internet Information Server (IIS)
Internet Information Server (IIS)Internet Information Server (IIS)
Internet Information Server (IIS)
 
Understanding IIS
Understanding IISUnderstanding IIS
Understanding IIS
 
YouTube Powerpoint
YouTube PowerpointYouTube Powerpoint
YouTube Powerpoint
 

Mehr von Alessandro Pilotti

OpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in OcataOpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in OcataAlessandro Pilotti
 
Strategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStackStrategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStackAlessandro Pilotti
 
OpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DOpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DAlessandro Pilotti
 
Building a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologiesBuilding a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologiesAlessandro Pilotti
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsAlessandro Pilotti
 
Interoperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-InitInteroperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-InitAlessandro Pilotti
 
An HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V consoleAn HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V consoleAlessandro Pilotti
 
Hyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeHyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeAlessandro Pilotti
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsAlessandro Pilotti
 
PHP and FastCGI Performance Optimizations
PHP and FastCGI Performance OptimizationsPHP and FastCGI Performance Optimizations
PHP and FastCGI Performance OptimizationsAlessandro Pilotti
 
Managing Drupal on Windows with Drush
Managing Drupal on Windows with DrushManaging Drupal on Windows with Drush
Managing Drupal on Windows with DrushAlessandro Pilotti
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Alessandro Pilotti
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalAlessandro Pilotti
 

Mehr von Alessandro Pilotti (16)

OpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in OcataOpenStack and Windows - What's new in Ocata
OpenStack and Windows - What's new in Ocata
 
Strategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStackStrategies for migrating workloads from VMware to OpenStack
Strategies for migrating workloads from VMware to OpenStack
 
Puppet + Windows Nano Server
Puppet + Windows Nano ServerPuppet + Windows Nano Server
Puppet + Windows Nano Server
 
OpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2DOpenStack + Nano Server + Hyper-V + S2D
OpenStack + Nano Server + Hyper-V + S2D
 
Building a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologiesBuilding a Microsoft cloud with open technologies
Building a Microsoft cloud with open technologies
 
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and WindowsOpenStack Summit 2013 Hong Kong - OpenStack and Windows
OpenStack Summit 2013 Hong Kong - OpenStack and Windows
 
Interoperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-InitInteroperable OpenStack guest provisioning with Cloudbase-Init
Interoperable OpenStack guest provisioning with Cloudbase-Init
 
OpenStack and Windows
OpenStack and WindowsOpenStack and Windows
OpenStack and Windows
 
An HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V consoleAn HTML5 client to connect to the Hyper-V console
An HTML5 client to connect to the Hyper-V console
 
Hyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova ComputeHyper-V OpenStack Nova Compute
Hyper-V OpenStack Nova Compute
 
Drupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on WindowsDrupal, Memcache and Solr on Windows
Drupal, Memcache and Solr on Windows
 
PHP and FastCGI Performance Optimizations
PHP and FastCGI Performance OptimizationsPHP and FastCGI Performance Optimizations
PHP and FastCGI Performance Optimizations
 
Managing Drupal on Windows with Drush
Managing Drupal on Windows with DrushManaging Drupal on Windows with Drush
Managing Drupal on Windows with Drush
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1
 
Windows Loves drupal
Windows Loves drupalWindows Loves drupal
Windows Loves drupal
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
 

Kürzlich hochgeladen

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Kürzlich hochgeladen (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Drupal on IIS with SQL Server

  • 1. Drupal on IIS with a SQL Server database Alessandro Pilotti @alexpilotti MVP ASP.NET / IIS MCSD, MCAD, MCSE, MCDBA, MCT Red Hat Certified Engineer
  • 2. SQL Server and Drupal  Drupal offers the option to choose the database backend  No more limited to MySQL  Drupal 7 provides great support for SQL Server 2008  All major modules nowadays use PDO and portable SQL  Works as well with SQL Server 2008 R2 and 2012  MS provides a PHP PDO driver for SQL Server  There’s a free Express edition  Limited to 10GB per database  SQL Azure
  • 3. SQL Server for MySQL devs / admins  SQL Server is a relational database like MySQL  You can write SQL queries (SELECT, INSERT, UPDATE DELETE)  Like for every other DBMS there are some tricky differences  E.g. MySQL is more forgiving in the GROUP BY clause  Management tools:  Management Studio  sqlcmd.exe
  • 4. Edition comparison  Express (free)  Contains everything you need for the average Drupal site  Limited to 10GB database size, 1GB memory, 1 socket / 4 cores  Web  Standard  Enterprise  Feature comparison charts:  http://msdn.microsoft.com/en-us/library/cc645993.aspx
  • 5. SQL Server useful features  Online backup (included also in express edition!)  Full  Differential  Log  Replication  Min. standard edition, web and express only as subscribers  Mirroring  Min. standard edition  Log shipping  Min. web editition  Great profiling tools  UI tools in standard edition
  • 6. Instances  You can install multiple isolated instances on the same server  Only one can be the default unnamed instance  All the others are named  It means that you connect to the server with a name:  E.g. yourserverSQLEXPRESS
  • 7. Databases  SQL Server instances, like MySQL, contain multiple databases  Every Drupal site has usually a separate database  Or you can use table_prefix of course  Databases can be moved to different instances  detached from one  Attached to the other  Databases can be put individually offline
  • 8. Authentication  Login  Credentials needed to connect to the instance  Windows account (integrated)  No password, best security approach  SQL server (mixed mode)  Classic username and password  Instance wide roles can be assigned to logins  Database users  Specific to each database  Logins are mapped to database users  Object level (table, etc) permissions are granted to users  Roles  A collection of permissions  Users can be assigned to roles
  • 9. Main database roles  db_owner  Can do everything on the database (not the instance!)  db_datareader  Can run SELECT on any table / view  db_datawriter  Can run INSERT, UPDATE, DELETE  db_ddladmin  Can run any DDL command (CREATE, DROP, etc)
  • 10. How to create a database  Very easily with Management Studio  Via command line: sqlcmd –S .SQLEXPRESS –E create database drupal7 create login drupal7 with password = 'Passw0rd’ go use drupal7 go create user drupal7 for login drupal7 exec sp_addrolemember db_owner, drupal7 go
  • 11. Drupal 7 site with SQL Server using WebPi  With just a few click using WebPi  Add also:  SQL Server 2008 R2 Management Studio Express with SP1
  • 12. Drupal 7 site with SQL Server w/o WebPi  Create web site  Download and install SQL Server PDO driver:  http://www.microsoft.com/en- us/download/details.aspx?id=20098  Enable PHP extensions php_sqlsrv and php_pdo_sqlsrv  Drush @drupal7 dl sqlsrv  cd your_drupal_site_path  xcopy /i sitesallmodulessqlsrvsqlsrv includesdatabasesqlsrv
  • 13. Database management  Schedule proper backup policy  With or without transaction log  Schedule maintenance tasks  Update statistics  Reindex  Shrink database
  • 14. Backup policy  Schedule a proper backup policy, e.g.:  Full database backup every night  Log every 5’ (or more, depending on your db)  This way you will not lose more than 5’ of data!  To be able to backup the transaction log, set the database recovery model to  Full or Bulk-Logged  Default is Simple
  • 15. Backup  Use Management Studio  or  BACKUP DATABASE [drupal7] TO DISK = N'c:backupdrupal7_backup.bak' WITH INIT, NAME = N'drupal7-Full Database Backup’  Store backups on a remote file share!  To do that run the SQL service with an ad hoc user  Create the same user on the server with the network share
  • 16. Set recovery model  Management Studio (very easy)  T-SQL (e.g. sqlcmd): USE [master] GO ALTER DATABASE [drupal7] SET RECOVERY FULL WITH NO_WAIT
  • 17. How to schedule a backup  The express edition of SQL Server doesn’t have a UI to schedule backups and other tasks  We can use the windows scheduler to schedule:  Full backup every night  Log backup every 5’  Delete of old backups every night schtasks.exe /create /tn drupal7_db_backup_full /tr "sqlcmd -S .SQLExpress -E -i c:backupdrupal7_backup_full.sql" /sc DAILY /ru Administrator /rp /st 02:00:00  Useful task commands:  schtasks.exe /run /tn drupal7_db_backup_full  schtasks.exe /delete /tn drupal7_db_backup_full
  • 18. To schedule a log backup  E.g.: every 15’:  schtasks.exe /create /tn drupal7_dbbackup_log /tr "sqlcmd -S .SQLExpress -E -i c:backupdrupal7_backup_log.sql" /sc MINUTE /MO 15 /ru administrator /rp
  • 19. Restore a database  Best done via Management Studio  Or manually (here’s a complete sample):  RESTORE DATABASE [drupal7] FROM DISK = N'c:backupdrupal7_backup_full_2012_05_15_14_53_06_470.bak' WITH FILE = 1, NORECOVERY  GO  RESTORE DATABASE [drupal7] FROM DISK = N'c:backupdrupal7_backup_diff_2012_05_15_14_53_09_867.bak' WITH FILE = 1, NORECOVERY  GO  RESTORE LOG [drupal7] FROM DISK = N'c:backupdrupal7_backup_log_2012_05_15_14_53_13_913.trn' WITH FILE = 1, NORECOVERY  GO  RESTORE LOG [drupal7] FROM DISK = N'c:backupdrupal7_backup_log_2012_05_15_14_53_15_200.trn' WITH FILE = 1  GO