Friday, May 26, 2017

how to add swap on EC2


To add this extra space to your instance you type
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo chmod 600 /var/swap.1
sudo /sbin/swapon /var/swap.1

add this line to /etc/fstab:
swap        /var/swap.1 swap    defaults        0   0

Wednesday, May 10, 2017

How to change MySQL table names in Linux server to be case insensitive?

Edit the mysql configuration file
nano /etc/mysql/my.cnf
or any other my.cnf file which is used to configure your mysql.
Under 
[mysqld]
add the line 
lower_case_table_names=1
Run 
sudo service mysqld restart
You might want to reimport your windows database into your linux database. Preferably from scratch, with add table and insert statements.
It's good!

http://stackoverflow.com/questions/11165944/how-to-change-mysql-table-names-in-linux-server-to-be-case-insensitive

Tuesday, May 9, 2017

Change port 8080 to 80 in Tomcat

As previous answers didn't work well (it was good, but not enough) for me on a 14.04 Ubuntu Server, I mention these recommendations (this is a quote). 
Edit: note that as @jason-faust mentioned it in the comments, on 14.04, the authbind package that ships with it does support IPv6 now, so the prefer IPv4 thing isn't needed any longer. 
1) Install authbind
2) Make port 80 available to authbind (you need to be root):

  touch /etc/authbind/byport/80
  chmod 500 /etc/authbind/byport/80
  chown tomcat7 /etc/authbind/byport/80

3) Make IPv4 the default (authbind does not currently support IPv6).
   To do so, create the file TOMCAT/bin/setenv.sh with the following content: 

   CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"

4) Change /usr/share/tomcat7/bin/startup.sh

  exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@"
  # OLD: exec "$PRGDIR"/"$EXECUTABLE" start "$@"
If you already got a setenv.sh file in /usr/share/tomcat7/bin with CATALINA_OPTS, you have to use :
export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"
Now you can change the port to 80 as told in other answers.
If you don't find setenv.sh try to create it.

http://stackoverflow.com/questions/4756039/how-to-change-the-port-of-tomcat-from-8080-to-80

Monday, April 10, 2017

resize EBS

~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  120G  0 disk
`-xvda1 202:1    0    8G  0 part /

~$ sudo parted /dev/xvda resizepart 1
Warning: Partition /dev/xvda1 is being used. Are you sure you want to continue?
Yes/No? yes
End?  [8590MB]? 120G
Information: You may need to update /etc/fstab.

~$ sudo /sbin/resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 7
The filesystem on /dev/xvda1 is now 29296875 (4k) blocks long.


Grow filesystem to match disk size

Compare against and try to let a single page.

First check the partition layout. In the following example we have a 30GB disk with a 15GB partition for /. We have to extend this partition.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 15G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 975M 0 part [SWAP] sr0 11:0 1 46K 0 rom

Then we disable the SWAP partition:

$ sudo swapoff /dev/sda5 $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 15G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 975M 0 part sr0 11:0 1 46K 0 rom

Now we remove all three partitions:

$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.36.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Partition number (1,2,5, default 5): Partition 5 has been deleted. Command (m for help): d Partition number (1,2, default 2): Partition 2 has been deleted. Command (m for help): d Selected partition 1 Partition 1 has been deleted.
Confirm if it is really important to maintain the ext4 signature.
Confirm if it is really needed to perform the following steps in the same fdisk session.

And while still in the same fdisk session, re-create the partitions maintaining the ext4 signature. Determine the size of the first partition (28GB) as the total disk space (30GB) minus ~20% to ~25% of the assigned RAM memory (20% of 10GB is 2GB):

Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-62914559, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62914559, default 62914559): +28G Created a new partition 1 of type 'Linux' and of size 28 GiB. Partition #1 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: N Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): e Partition number (2-4, default 2): 2 First sector (58722304-62914559, default 58722304): Last sector, +/-sectors or +/-size{K,M,G,T,P} (58722304-62914559, default 62914559): Created a new partition 2 of type 'Extended' and of size 2 GiB. Command (m for help): n Adding logical partition 5 First sector (58724352-62914559, default 58724352): Last sector, +/-sectors or +/-size{K,M,G,T,P} (58724352-62914559, default 62914559): Created a new partition 5 of type 'Linux' and of size 2 GiB. Command (m for help): w The partition table has been altered. Syncing disks. $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 28G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 2G 0 part sr0 11:0 1 46K 0 rom

Then re-configure the SWAP:

$ sudo mkswap /dev/sda5 Setting up swapspace version 1, size = 2 GiB (2145382400 bytes) no label, UUID=204fbbfb-79bf-4a72-870d-2a94288da6ba

And update /etc/fstab with the new UUID for the SWAP partition.

Confirm that the following is really needed. https://www.claudiokuenzler.com/blog/1138/update-initramfs-warning-tools-configuration-sets-resume-no-matching-swap-device. It seems it doesn’t happen for the development instances under the “temp_jhablutzel” location. Maybe Veeam related?

Then edit /etc/initramfs-tools/conf.d/resume with the new UUID as well.

Then:

sudo update-initramfs -k all -u sudo update-grub

Then:

sudo resize2fs /dev/sda1

Then reboot.

And finally check the disk layout once again:

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 28G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 2G 0 part [SWAP] sr0 11:0 1 46K 0 rom
Provide instructions on how to set up Veeam backups depending on the specific requirements of this VM.