SlideShare une entreprise Scribd logo
1  sur  14
Proxying DBI with DBD::Gofer
     and App::Staticperl
       San Diego.pm talk
         May 17, 2012
Environment
• Need to connect to Informix IDS servers
• Remote systems with strict firewalls
• Production systems, no configuration change
  possible
• Minimal footprint required for maintenance
• Sounds complicated? Because it is.
Solution: DBD::Gofer
• Stateless DBI proxy
• Works by changing DSN connect string
• Or even setting DBI_AUTOPROXY environment
  variable
• Transparent for DBI applications
• Support different transports
• One of them is “stream” (SSH)
Server side
•   Needs to have Perl with recent enough DBI
•   Needs database specific DBD (DBD::Informix)
•   System Perl is Untouchable, period
•   Custom Perl build litters a lot
•   Maintenance is PITA
•   Answer: App::Staticperl
App::Staticperl
•   Marc Lehmann’s Yet Another brilliant work
•   Allows building all-in-one Perl executable
•   Including pure Perl modules
•   Including XS modules and shared objects (!)
•   Not unlike PAR::Packer, but actually works
•   Unlike PAR, no zips and no write permission
    required
App::Staticperl gotchas
• Not very mature: may or may not work for
  your specific application
• May take extensive Unix/Linux knowledge
• May take some Perl building skills
• In short, you gotta know what you’re doing
• … but even then, some modules Just Don’t
  Work
Case study
•   Building static Perl for Solaris
•   Minimal module list: DBI, DBD::Informix
•   Some dependencies as well
•   Using GCC 4.4
•   Linking against native Informix CSDK
•   Bundling it all including environment startup
    into one fat Perl executable
Step 1: Build App::Staticperl
• Default installation blows up in Solaris (make
  test fails)
• Do forced make install
• Manually edit ~/perl/bin/staticperl
• Lots of small system specific changes
• Try running “staticperl install”, see if it breaks
• Make changes, try running, iterate
Step 2: install CPAN modules
• staticperl instcpan DBI …
• Some modules may fail at first
• A dose of patience and some big wrench is
  required
• Finally all tests should reasonably pass
Step 3: Customizing for Informix
• Add Informix configuration variables right
  there in staticperl
• Most important: PATH, LD_LIBRARY_PATH
• Linking against shared objects in known
  location
• Utmost importance: LD_RUN_PATH (ld -R)
• Prepare bootstrap.pl: set up Informix
  environment variables
Step 4: Customizing for DBI
• Prepare “bundle” file: take bundle.smallperl as
  an example (Remove first line “static”! Almost
  drove me mad!)
• Add DBI, DBD::Gofer::*, DBD::Informix
• Add perl5db.pl and Term::ReadLine for
  debugger (you’ll need it, trust me)
• Add utf8, Encode, whatever
Step 5: Building
• ~/perl/bin/staticperl mkperl -v --boot
  bootstrap.pl gofer.bundle
• -v to see if something goes wrong
• --boot sets bootstrap script, it gets executed
  when static perl starts up
• Don’t use “exit 0” in bootstrap, you’d be much
  surprised (remember perl5db.pl? Invaluable.)
Finita
•   Voila, we’ve got a statically built perl
•   One 5.5M executable file, no dependencies
•   All run time library paths are built in
•   Send it over to remote system and test
•   <Live demo here>
Questions?
• I have working staticperl script for Solaris, with
  DBD::Informix built in
• Not CPAN quality (ugh), so isn’t published
• But if you’re curious, drop me a line:
  Alex Tokarev <tokarev@cpan.org>

Contenu connexe

Tendances

Python to go
Python to goPython to go
Python to go
Weng Wei
 

Tendances (20)

Functional Programming in PHP
Functional Programming in PHPFunctional Programming in PHP
Functional Programming in PHP
 
ASP.NET Core - Phillosophies, Processes and Tooling
ASP.NET Core - Phillosophies, Processes and ToolingASP.NET Core - Phillosophies, Processes and Tooling
ASP.NET Core - Phillosophies, Processes and Tooling
 
YAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl ConferencesYAPC::EU 2015 - Perl Conferences
YAPC::EU 2015 - Perl Conferences
 
Migrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreMigrating .NET Application to .NET Core
Migrating .NET Application to .NET Core
 
About Clack
About ClackAbout Clack
About Clack
 
Scala vs ruby
Scala vs rubyScala vs ruby
Scala vs ruby
 
Symfony vs. Message Brokers
Symfony  vs.  Message BrokersSymfony  vs.  Message Brokers
Symfony vs. Message Brokers
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
 
Crystal
CrystalCrystal
Crystal
 
C#: Past, Present and Future
C#: Past, Present and FutureC#: Past, Present and Future
C#: Past, Present and Future
 
CBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusionCBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusion
 
BuildStuff 2019: Let me handle that for you... Why you need a reverse proxy
BuildStuff 2019: Let me handle that for you... Why you need a reverse proxyBuildStuff 2019: Let me handle that for you... Why you need a reverse proxy
BuildStuff 2019: Let me handle that for you... Why you need a reverse proxy
 
meet.php #11 - Huston, we have an airbrake
meet.php #11 - Huston, we have an airbrakemeet.php #11 - Huston, we have an airbrake
meet.php #11 - Huston, we have an airbrake
 
Getting Started with ASP.net Core 1.0
Getting Started with ASP.net Core 1.0Getting Started with ASP.net Core 1.0
Getting Started with ASP.net Core 1.0
 
Python to go
Python to goPython to go
Python to go
 
Upgrading to rails3
Upgrading to rails3Upgrading to rails3
Upgrading to rails3
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
Que hay de nuevo en Visual Studio 2013 y ASP.NET 5.1
 
Dev objective2015 lets git together
Dev objective2015 lets git togetherDev objective2015 lets git together
Dev objective2015 lets git together
 
Phinx CloudConf 2016 Presentation
Phinx CloudConf 2016 PresentationPhinx CloudConf 2016 Presentation
Phinx CloudConf 2016 Presentation
 

Similaire à Proxying DBI with DBD::Gofer and App::Staticperl

Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
Mandi Walls
 

Similaire à Proxying DBI with DBD::Gofer and App::Staticperl (20)

Packaging perl (LPW2010)
Packaging perl (LPW2010)Packaging perl (LPW2010)
Packaging perl (LPW2010)
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
DCSF 19 Node.js Rocks in Docker for Dev and Ops
DCSF 19 Node.js Rocks in Docker for Dev and OpsDCSF 19 Node.js Rocks in Docker for Dev and Ops
DCSF 19 Node.js Rocks in Docker for Dev and Ops
 
Node.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and OpsNode.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and Ops
 
The Architect Way
The Architect WayThe Architect Way
The Architect Way
 
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
 
Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014Open Source Tools for Leveling Up Operations FOSSET 2014
Open Source Tools for Leveling Up Operations FOSSET 2014
 
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructureDevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
 
Command box, Package Manager, Automation, REPL
Command box, Package Manager, Automation, REPLCommand box, Package Manager, Automation, REPL
Command box, Package Manager, Automation, REPL
 
Creating Perl modules with Dist::Zilla
Creating Perl modules with Dist::ZillaCreating Perl modules with Dist::Zilla
Creating Perl modules with Dist::Zilla
 
Command box
Command boxCommand box
Command box
 
Command box
Command boxCommand box
Command box
 
Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1Managing ejabberd Platforms with Docker - ejabberd Workshop #1
Managing ejabberd Platforms with Docker - ejabberd Workshop #1
 
Introduce iRedMail Open Source Mail Server Solution
Introduce iRedMail Open Source Mail Server SolutionIntroduce iRedMail Open Source Mail Server Solution
Introduce iRedMail Open Source Mail Server Solution
 
ITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLIITB2015 - Go Commando with CommandBox CLI
ITB2015 - Go Commando with CommandBox CLI
 
Mobile Fest 2018. Алексей Лизенко. Make your project great again
Mobile Fest 2018. Алексей Лизенко. Make your project great againMobile Fest 2018. Алексей Лизенко. Make your project great again
Mobile Fest 2018. Алексей Лизенко. Make your project great again
 
Ansible at work
Ansible at workAnsible at work
Ansible at work
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanity
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
 

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Dernier (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Proxying DBI with DBD::Gofer and App::Staticperl

  • 1. Proxying DBI with DBD::Gofer and App::Staticperl San Diego.pm talk May 17, 2012
  • 2. Environment • Need to connect to Informix IDS servers • Remote systems with strict firewalls • Production systems, no configuration change possible • Minimal footprint required for maintenance • Sounds complicated? Because it is.
  • 3. Solution: DBD::Gofer • Stateless DBI proxy • Works by changing DSN connect string • Or even setting DBI_AUTOPROXY environment variable • Transparent for DBI applications • Support different transports • One of them is “stream” (SSH)
  • 4. Server side • Needs to have Perl with recent enough DBI • Needs database specific DBD (DBD::Informix) • System Perl is Untouchable, period • Custom Perl build litters a lot • Maintenance is PITA • Answer: App::Staticperl
  • 5. App::Staticperl • Marc Lehmann’s Yet Another brilliant work • Allows building all-in-one Perl executable • Including pure Perl modules • Including XS modules and shared objects (!) • Not unlike PAR::Packer, but actually works • Unlike PAR, no zips and no write permission required
  • 6. App::Staticperl gotchas • Not very mature: may or may not work for your specific application • May take extensive Unix/Linux knowledge • May take some Perl building skills • In short, you gotta know what you’re doing • … but even then, some modules Just Don’t Work
  • 7. Case study • Building static Perl for Solaris • Minimal module list: DBI, DBD::Informix • Some dependencies as well • Using GCC 4.4 • Linking against native Informix CSDK • Bundling it all including environment startup into one fat Perl executable
  • 8. Step 1: Build App::Staticperl • Default installation blows up in Solaris (make test fails) • Do forced make install • Manually edit ~/perl/bin/staticperl • Lots of small system specific changes • Try running “staticperl install”, see if it breaks • Make changes, try running, iterate
  • 9. Step 2: install CPAN modules • staticperl instcpan DBI … • Some modules may fail at first • A dose of patience and some big wrench is required • Finally all tests should reasonably pass
  • 10. Step 3: Customizing for Informix • Add Informix configuration variables right there in staticperl • Most important: PATH, LD_LIBRARY_PATH • Linking against shared objects in known location • Utmost importance: LD_RUN_PATH (ld -R) • Prepare bootstrap.pl: set up Informix environment variables
  • 11. Step 4: Customizing for DBI • Prepare “bundle” file: take bundle.smallperl as an example (Remove first line “static”! Almost drove me mad!) • Add DBI, DBD::Gofer::*, DBD::Informix • Add perl5db.pl and Term::ReadLine for debugger (you’ll need it, trust me) • Add utf8, Encode, whatever
  • 12. Step 5: Building • ~/perl/bin/staticperl mkperl -v --boot bootstrap.pl gofer.bundle • -v to see if something goes wrong • --boot sets bootstrap script, it gets executed when static perl starts up • Don’t use “exit 0” in bootstrap, you’d be much surprised (remember perl5db.pl? Invaluable.)
  • 13. Finita • Voila, we’ve got a statically built perl • One 5.5M executable file, no dependencies • All run time library paths are built in • Send it over to remote system and test • <Live demo here>
  • 14. Questions? • I have working staticperl script for Solaris, with DBD::Informix built in • Not CPAN quality (ugh), so isn’t published • But if you’re curious, drop me a line: Alex Tokarev <tokarev@cpan.org>