Home > PostgreSQL, Uncategorized > Add XFS partitiion to be used by PostgreSQL at AWS EC2

Add XFS partitiion to be used by PostgreSQL at AWS EC2

1. Use the AWS Elastick Block Store to create new volume in the same zone as the instance where your PostgreSQL is.
2. Attach the new volume to the instance
When its done, you will see in the dmesg output something like :

[ 5192.466502] blkfront: xvdf: barrier or flush: disabled
[ 5192.469114]  xvdf: unknown partition table

3. Install xfs utilities

root@domU-12-31-39-07-39-AE:[Fri May 11 11:15:37]:[/var/log]$ yum search xfs
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
=============================================================================== N/S Matched: xfs ================================================================================
xfsprogs.i686 : Utilities for managing the XFS filesystem
xfsprogs.x86_64 : Utilities for managing the XFS filesystem
xfsprogs-devel.x86_64 : XFS filesystem-specific static libraries and headers
xfsprogs-qa-devel.x86_64 : XFS QA filesystem-specific static libraries and headers
xorg-x11-xfs.x86_64 : X.Org X11 xfs font server
xorg-x11-xfs-utils.x86_64 : X.Org X11 font server utilities

  Name and summary matches only, use "search all" for everything.
root@domU-12-31-39-07-39-AE:[Fri May 11 11:16:17]:[/var/log]$ yum install xfsprogs* -y 
Loaded plugins: fastestmirror, priorities, security, update-motd
Loading mirror speeds from cached hostfile
 * amzn-main: packages.us-east-1.amazonaws.com
 * amzn-updates: packages.us-east-1.amazonaws.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package xfsprogs.x86_64 0:3.1.3-1.7.amzn1 will be installed
---> Package xfsprogs-devel.x86_64 0:3.1.3-1.7.amzn1 will be installed
---> Package xfsprogs-qa-devel.x86_64 0:3.1.3-1.7.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================
 Package                                        Arch                                Version                                         Repository                              Size
=================================================================================================================================================================================
Installing:
 xfsprogs                                       x86_64                              3.1.3-1.7.amzn1                                 amzn-main                              1.4 M
 xfsprogs-devel                                 x86_64                              3.1.3-1.7.amzn1                                 amzn-main                               29 k
 xfsprogs-qa-devel                              x86_64                              3.1.3-1.7.amzn1                                 amzn-main                               92 k

Transaction Summary
=================================================================================================================================================================================
Install       3 Package(s)

Total download size: 1.5 M
Installed size: 3.6 M
Downloading Packages:
(1/3): xfsprogs-3.1.3-1.7.amzn1.x86_64.rpm                                                                                                                | 1.4 MB     00:00     
(2/3): xfsprogs-devel-3.1.3-1.7.amzn1.x86_64.rpm                                                                                                          |  29 kB     00:00     
(3/3): xfsprogs-qa-devel-3.1.3-1.7.amzn1.x86_64.rpm                                                                                                       |  92 kB     00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                            4.4 MB/s | 1.5 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : xfsprogs-3.1.3-1.7.amzn1.x86_64                                                                                                                               1/3 
  Installing : xfsprogs-devel-3.1.3-1.7.amzn1.x86_64                                                                                                                         2/3 
  Installing : xfsprogs-qa-devel-3.1.3-1.7.amzn1.x86_64                                                                                                                      3/3 

Installed:
  xfsprogs.x86_64 0:3.1.3-1.7.amzn1                    xfsprogs-devel.x86_64 0:3.1.3-1.7.amzn1                    xfsprogs-qa-devel.x86_64 0:3.1.3-1.7.amzn1                   

Complete!
root@domU-12-31-39-07-39-AE:[Fri May 11 11:16:59]:[/var/log]

4. Create the mount point


mkdir /var/lib/pgsql9/xfs.data

5. Format the new volume


mkfs.xfs -f /dev/xvdf

root@domU-12-31-39-07-39-AE:[Fri May 11 11:29:54]:[/var/log]$ mkfs.xfs -f /dev/xvdf
meta-data=/dev/xvdf              isize=256    agcount=4, agsize=1966080 blks
         =                       sectsz=512   attr=2
data     =                       bsize=4096   blocks=7864320, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=3840, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

6. Mount the formatted volume


mount -t xfs -o inode64,nobarrier,noatime /dev/xvdf  /var/lib/pgsql9/xfs.data

7. Make sure the volume will be mounted at boot time :
– get the mount properties


root@domU-12-31-39-07-39-AE:[Fri May 11 11:30:20]:[/var/log]$ cat /proc/mounts | grep /dev/xvdf
/dev/xvdf /var/lib/pgsql9/xfs.data xfs rw,noatime,attr2,delaylog,nobarrier,inode64,noquota 0 0

– add that line to the fstab


echo "/dev/xvdf /var/lib/pgsql9/xfs.data xfs rw,noatime,attr2,delaylog,nobarrier,inode64,noquota 0 0" >> /etc/fstab

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: