Friday, April 29, 2016

Increase the size of a Redhat 6.5 LVM disk in virtual machine Hyper-V

Increase the size of a Redhat 6.5 LVM disk in virtual machine Hyper-V


1. Introduction:

This post will show you how to increase the disk space for a Hyper-v virtual machine running Linux that is using logical volume manager (LVM). First we need to increase the size of the actual disk on the Hyper-v virtual machine. Once this is complete we will get into the virtual machine and make the changes through the operating system in order to take advantage of the additional space that has been provided by the hard drive being extended. This will involve creating a new partition with the new space, expanding the volume group and logical group, then resizing the file system.

Important Note: follow the commands and the screenshot.

2. Identifying the partition type:

we will first confirm that our partition type is actually Linux LVM by running the below command.

fdisk -l


Below is the disk information showing that our initial setup only has the one 60GB disk currently, which is under the logical volume named /dev/mapper/vg_redhatserver-lv_root  this is what we will be expanding with the new disk.


3. Increasing the virtual hard disk:

First we increase the allocated disk space on the virtual machine itself. This is done by getting to 'Hyper-v Manager', in the right side click on 'Edit Disk


Choose the virtual machine disk

Select 'Expand'

Specify the size you want to expand. In this example the current size is 60GB so will increase it to 100GB

Click 'Finish'

4. Detect the new disk space:

A screenshot after performing this and confirming that the new space is displaying.


5. Partition the new disk space:

As outlined in the previous step the disk in my example that I am working with is /dev/sda. use 'fdisk' to create a new primary partition to make use of the new expanded disk space.

fdisk /dev/sda

Using fdisk to create a new partition, 'n' was selected for adding a new partition.


'p' is selected as we are making a primary partition.


As we already have /dev/sda1 and /dev/sda2 as shown in previous step, I will use '3' for this new partition which will be created as /dev/sda3


Press enter twice above as by default the first and last cylinders of the unallocated space should be correct. After this the partition is then ready.


't' is selected to change to a partition’s system ID, in this case we change to '3' which is the one we just created.


The hex code '8e' was entered as this is the code for a Linux LVM which is what we want this partition to be


'w' is used to write the table to disk and exit, basically all the changes that have been done will be saved and then you will be exited from fdisk.


A screenshot for all commands


Checking the partition /dev/sda3


That’s all for partitioning, we now have a new partition which is making use of the previously unallocated disk space from the increase in Hyper-v.

6. Increasing the logical volume:

Launch pvcreate command which creates a physical volume for later use by the logical volume manager (LVM). In this case the physical volume will be our new /dev/sda3 partition.


root@redhat-server:~# pvcreate /dev/sda3
  Device /dev/sda3 not found (or ignored by filtering).


In order to get around this you can either reboot, as in this instance the disk does not appear to be there correctly despite showing in “fdisk -l”. After a reboot use the same command which will succeed.

After a reboot


Next we need to confirm the name of the current volume group using the vgdisplay command. vgdisplay provides lots of information on the volume group.

root@redhat-server:~# vgdisplay
  --- Volume group ---
  VG Name               Mega
...
VG Size               59.51GiB 


Now we extend the 'vg_redhatserver' volume group by adding in the physical volume of /dev/sda3 which we created using the pvcreate command earlier.

root@redhat-server:~# vgextend Mega /dev/sda3


Using the 'pvscan' command we scan all disks for physical volumes, this should confirm the original /dev/sda2 partition and the newly created physical volume /dev/sda3

root@redhat-server:~# pvscan


Increase the logical volume which basically means we will be taking our original logical volume and extending it over our new partition/physical volume of /dev/sda3.
Confirm the path of the logical volume using 'lvdisplay'.

root@redhat-server:~# lvdisplay


The logical volume is then extended using the 'lvextend' command.

root@redhat-server:~# lvextend /dev/vg_redhatserver/lv_root /dev/sda3


The final step which is to resize the file system so that it can take advantage of this additional space, this is done using the 'resize2fs' command for ext based file systems. It took about 30 seconds or less depending to the disk's speed.

root@redhat-server:~# resize2fs /dev/vg_redhatserver/lv_root


Now with the 'df' command we can see that the total available disk space has been increased.






Wednesday, April 27, 2016

Configuring Tomcat-Connector for IIS 8

Configuring Tomcat-Connector for IIS 8

1. Introduction:

This page is an installation guide for the Apache tomcat 8. It tells you how to configure access to tomcat website via IIS.
This section of the guide describes the steps necessary to set up tomcat server as a windows service and then forward the website to IIS via port 80. You will do this by installing a custom ISAPI filter in IIS that understands how to use the AJP protocol (Apache JServ Protocol) to communicate with tomcat.

2. Installation:

2.1. Installation tomcat as a Windows service:

Download apache tomcat https://tomcat.apache.org/download-80.cgi
Extract the files, in this example I extracted tomcat folder under the local disk C:


Execute a command cmd and go the bin directory  

Launch service.bat command with parametres above:
service.bat install Tomacat


Checking the services for apache tomcat service


Start the service

In internet explorer, open http://localhost:8080 to check the tomcat server is running 


http://localhost:8080/examples is a tomcat simple


2.2. Install and Configure the AJP Connector:

Tomcat Connector ISAPI Filter binaries: tomcat_iis_connector.zip
  • Download the tomcat_iis_connector.zip file attached to this page. It contains the configuration files necessary for the ISAPI filter to run and communicate with your tomcat server.
  • Extract the downloaded zip file and place the contents in a folder alongside the downloaded binary file in a convenient location on your server. In this example is C:\tomcat_iis_connector.
  • If your Tomcat server is not running on the same server as IIS (for example, if tomcat is running on a non-Windows server), then edit the worker.properties.minimal file in the conf directory so that the worker.worker1.host property points to the IP address or host name of your tomcat server.
  • If you wish to change the default port for tomcat's AJP Connector, then edit the worker.properties.minimal file in the conf directory and change the worker.worker1.port property to specify the required port number. The default port used in this guide for tomcat's AJP Connector is 8009.


2.3. Add ISAPI Filter:

Open the Internet Information Services (IIS) Manager.
In the 'Connections' panel, ensure that the IIS Web Site is selected.
Double-click the 'ISAPI Filters' icon in 'Features View'.



In the 'Actions' panel on the right, select 'Add'.
Set the 'Filter name' to 'tomcat' and set the 'Executable' to the isapi_redirect.dll that you downloaded.


Click 'OK'


2.4. Add Virtual Directory

In the 'Connections' panel, ensure that the correct IIS Web Site is selected. Right-click the IIS Web Site and select 'Add Virtual Directory'


Set the 'Alias' to 'jakarta'.
Set the 'Physical Path' to the directory where you extracted the ISAPI Filter  (such as, C:\tomcat_iis_connector).
Click 'OK'


Next, select the 'jakarta' virtual directory in the 'Connections' panel.Double-click the 'Handler Mappings' icon in 'Features View'.
Click the 'Edit Feature Permissions' link in the 'Actions' panel.
Ensure that the 'Execute' option is selected.
 
In the 'Connections' panel, ensure that the local IIS Server is selected


Double-click the 'ISAPI and CGI Restrictions' icon in 'Features View'.
Click 'Add' in the 'Actions' panel.
Set the 'ISAPI or CGI path' to the isapi_redirect.dll you downloaded.
Set the 'Description' to 'tomcat'.
Ensure that the 'Allow extension path to execute' is selected.


Click 'OK'.


2.5. Pool Application configuration:

In 'Internet Information Services (IIS) Manager', go to 'Application Pools'. Select 'DefaultAppPool'
In 'Actions' click on 'Advanced Settings'

Change 'Enable 32-Bit Applications' to 'True'

    

Click 'OK'

2.6. Allow Double Escaping:

In the 'Connections' panel, ensure that the IIS Web Site that will be used is selected.
Double-click the 'Request Filtering' icon in 'Features View'.



Click the 'Edit Feature Settings' link in the 'Actions' panel. Ensure that the 'Allow double escaping' option is selected

    

Click 'OK'.

2.7. Configuration tomcat:

Modify the 'server.xml' tomcat under the conf folder
 

 Modify the 'connector' line to:

<Connector port="8009" address="127.0.0.1" enableLookups="false" redirectPort="8443" protocol="AJP/1.3" tomcatAuthentication="false" URIEncoding="UTF-8" />
 
Save 'server.xml'

3. Testing:

I have a website on IIS works on port 80 and another tomcat websit(examples) works on port 8080. I need to make sure that /examples works with IIS.

http://localhost/itgration (an IIS website)

http://localhost:8080/examples (a tomcat website)


Now, let's try to access to /examples with IIS (Port 80)