Friday 6 February 2015

MySQL Workbench - Data export

- In MySQL Workbench click on Data Export and set the export options according to the following screen shot:


- Click Start Export

References

Evernote helps you remember everything and get organized effortlessly. Download Evernote.

Thursday 5 February 2015

Migrate MS SQL Apelon content to MySQL

Download Microsoft® SQL Server® 2008 R2 Service Pack 1
http://www.microsoft.com/en-gb/download 

Run installer
open terminal

sqlcmd -S \SQLExpress

restore filelistonly from disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak';
GO

- Note: In order to avoid the following error:
Msg 3201, Level 16, State 2, Server WIN-1VMUV8AJRHG\SQLEXPRESS, Line 1
Cannot open backup device 'C:\Users\Administrator\Downloads\dts_20150112_ 20000.
bak'. Operating system error 5(Access is denied.).
Msg 3013, Level 16, State 1, Server WIN-1VMUV8AJRHG\SQLEXPRESS, Line 1
RESTORE FILELIST is terminating abnormally.

- you must allow read/write permissions to SQL Server on the folder where you have placed the .bak file or you can use the Backup folder of the sql server (e.g., C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\) 

- the terminal will show the content of the backup.  Yow need the first fields that tell you the logical names :


Teminal:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Administrator>sqlcmd -S \SQLExpress
1> restore filelistonly from disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak';
2> GO
LogicalName
                                                 PhysicalName


                                                                      Type FileG
roupName
                                            Size                 MaxSize
      FileId               CreateLSN                   DropLSN
   UniqueId                             ReadOnlyLSN                 ReadWriteLSN
                BackupSizeInBytes    SourceBlockSize FileGroupId LogGroupGUID
                      DifferentialBaseLSN         DifferentialBaseGUID
       IsReadOnly IsPresent TDEThumbprint
--------------------------------------------------------------------------------
------------------------------------------------ -------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------- ---- -----
--------------------------------------------------------------------------------
------------------------------------------- -------------------- ---------------
----- -------------------- --------------------------- -------------------------
-- ------------------------------------ --------------------------- ------------
--------------- -------------------- --------------- ----------- ---------------
--------------------- --------------------------- ------------------------------
------ ---------- --------- ------------------------------------------
dts
                                                 c:\Program Files\Microsoft SQL
Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts.mdf


                                                                      D    PRIMA
RY
                                                         9437184       351843720
80640                    1                           0
0 0F1FD1EB-8A12-4679-A531-F8FB9D3DBB66                           0
              0              9437184             512           1 NULL
                               217000000005800037 EA55F188-39C9-46F4-889B-AC8AD2
763D23          0         1 NULL
dts_log
                                                 c:\Program Files\Microsoft SQL
Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts_1.ldf


                                                                      L    NULL

                                                         1048576        21990232
55552                    2                           0
0 61A7EBA2-5D83-41DC-9A0E-5C8BDBFBA107                           0
              0                    0             512           0 NULL
                                                0 00000000-0000-0000-0000-000000
000000          0         1 NULL

(2 rows affected)
1>



Restore database

RESTORE DATABASE dts FROM disk='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak'
WITH 
   MOVE 'dts' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts.mdf', 
   MOVE 'dts_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\dts_1.ldf';
GO



Teminal:

1> RESTORE DATABASE dts FROM disk='C:\Program Files\Microsoft SQL Server\MSSQL10
_50.SQLEXPRESS\MSSQL\Backup\dts_20150112_ 20000.bak'
2> WITH
3>    MOVE 'dts' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS
\MSSQL\DATA\dts.mdf',
4>    MOVE 'dts_log' TO 'c:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXP
RESS\MSSQL\DATA\dts_1.ldf';
5> GO
Processed 1152 pages for database 'dst', file 'dts' on file 1.
Processed 1 pages for database 'dst', file 'dts_log' on file 1.
RESTORE DATABASE successfully processed 1153 pages in 0.372 seconds (24.214 MB/s
ec).
1>



MySQL Workbench migration

- Check if you have an OBDC driver for SQL server


Open the migration wizard on MySQL Workbench and select on Stored Connection (Local Instance M


- leave the use and password empty
- test connection

define the connection details of your local mysql server


- Click on Store in ... and set the password of your mysql database
- Test connection 


- Select schematas to migrate




- Click next
- Select all objects
- Modify the following sql script

- and set COLLATE utf8_bin :


- Click apply








References

Evernote helps you remember everything and get organized effortlessly. Download Evernote.

Tuesday 3 February 2015

Docker notes

What is docker?
- "an open platform for developers and sysadmins to build, ship, and run distributed applications" https://www.docker.com/whatisdocker/
- analogous to shipping containers where the goods are loaded in standard containers and ship to different locations
- It leverages LXC (Linux Containers). 
- It uses Linux Kernel facilities such as cGroups, namaspaces and SElinux to provide isolation between containers

Advantages
- portable deployments
     - containers are portable
     - applications can be bundled into single units
     - applications can be deployed on different linux environments without making changes
- fast application delivery
     - easy for developers and admins to collaborate and deploy applications on production
     - standard container format (developers only worry about the applications)
     - admin only worry about deploying containers into the servers
     - building a containers takes seconds
     - containers can be deployed on cloud environments, physical servers, virtual machines, etc
- use of less resources
     - containers do not use a full operational system
     - resources are lesser as compared to virtual machines     

Difference between VM and containers




Docker components
- Images
     - e.g., ubuntu or centos and with some applications already installed.  It is a read-only template
- Registries 
     - repository for Docker images (e.g., Docker hub)
- Containers 
     - execution environment for applications
     - applications and services are packaged into containers
- Docker client and server

Supported platforms
- Mac and Windows requires special wrappers such as boot2Docker and vagrant can be used for Docker deployments
- Debian
- RHEL
- SUSE
- Microsoft Azure
- Gentoo
- Amazon EC2
- Google Cloud Platform
- Arch Linux
- Rackspace
- IBM Softlayer
- Digital ocean
- FrugalWare
- CRUX Linux
- Ubuntu

Docker architecture
- Docker daemon 
     - Runs on the host machine
- Docker client
     - user interface with docker

References

Evernote helps you remember everything and get organized effortlessly. Download Evernote.