Wednesday, October 4, 2017

Debian Stretch: XEN configure & create DomU PV ubuntu xenial part 4

We will use xen-tools to make it easier to create guest. This steps are similiar with create domu pv debian

Configure /etc/xen-tools/xen-tools.conf
# vi /etc/xen-tools/xen-tools.conf
...
# lvm = vg0
lvm = volGroup1
...
install-method = debootstrap
...
debootstrap-cmd = /usr/sbin/debootstrap
...
size   = 80G       # Root disk, suffix (G, M, k) required
memory = 2G # Suffix (G, M, k) required
#maxmem = 2G      # Suffix (G, M, k) optional
swap   = 3G # Suffix (G, M, k) required
# noswap = 1      # Don't use swap at all for new systems.
fs     = ext4     # Default file system for any disk
dist   = `xt-guess-suite-and-mirror --suite`
                  # Default distribution is determined by Dom0's distribution
...
gateway = [your_ip_gateway]
netmask = [your_ip_netmask]
broadcast = [your_ip_broadcast]
...
nameserver = 8.8.8.8
...
bridge = br0
...
passwd = 1
...
pygrub = 1
...
mirror = `xt-guess-suite-and-mirror --mirror`
...


You can create your guest by command
# xen-create-image --hostname=ubuntu1601 --ip=[your_ip] --size=67gb --vcpu=4 --dist=xenial --mirror=http://kambing.ui.ac.id/ubuntu 
...
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done
Logfile produced at:
          /var/log/xen-tools/ubuntu1601.log

Installation Summary
---------------------
Hostname        :  ubuntu1601
Distribution    :  xenial
MAC Address     :  00:16:3E:CC:B3:5E
IP Address(es)  : 
[your_ip]
SSH Fingerprint :  SHA256:lvyAvapyE6Z+NGghQrw2SbqanHuejwqhxpo7u38kw/s (DSA)
SSH Fingerprint :  SHA256:oSZgN9IdMdfQNeOy0pnPk/wcr0JouNEH+1hdvl8hpfM (ECDSA)
SSH Fingerprint :  SHA256:eY/7/FFhMLC6XV4Gk8RmMIbBJBaYLUkBr8yOHno/uXY (ED25519)
SSH Fingerprint :  SHA256:Zc2CIx8fadkEhUN/PXL8M+DADAFXa9g0YMcfBd0dQVE (RSA)
Root Password   :  N/A

Note: you can choose closest ubuntu mirror.

Start your guest
# xl create /etc/xen/ubuntu1601.cfg
# xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0 11815    24     r-----     653.2
ubuntu1601                                  23  2048     4     -b----      16.4

State:

  • r - running
  • b - blocked
  • p - paused
  • s - shutdown
  • c - crashed
  • d - dying


Connect to your guest
# xl connect ubuntu1601

To make your guest start after boot/restart
# mkdir /etc/xen/auto
# ln -s /etc/xen/ubuntu1601.cfg /etc/xen/auto/ubuntu1601.cfg


References:

  1. http://blog.noviantech.com/2010/06/23/debian-kernels-and-tigon-tg3-firmware/
  2. https://wiki.debian.org/Firmware
  3. https://wiki.debian.org/LVM
  4. https://wiki.debian.org/LinuxRaidForAdmins
  5. https://ycnrg.org/xen-install-os-from-iso-pv/
  6. http://hwraid.le-vert.net/


Tuesday, October 3, 2017

Debian Stretch: LAMP apache2, mysql 5.7 community and php 7.0

Note: Install on fresh Debian Stretch (no apache and no database)

1. Install apache2


To install apache2 

# apt-get install apache2

2. Install mysql 5.7 community


Download MySql apt configuration from https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb

# wget --no-check-certificate https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb

Note: File name may change without notice, check latest mysql-apt-config at https://dev.mysql.com/downloads/repo/apt/

Install MySql apt configuration.

# dpkg -i mysql-apt-config_0.8.7-1_all.deb

Choose MySql 5.7 for stable version and continue by click Ok.

Install mysql 5.7 community

# apt-get install mysql-server mysql-client mysql-common

or

# apt-get install mysql-community-server mysql-community-client mysql-common

Note: at the end of installation, system will ask you to set mysql root password (NOT LINUX ROOT USER)

3. Install php 7.0


To install php 7.0:

# apt-get install php7.0 php7.0-gd php7.0-pgsql php7.0-cli php7.0-common php7.0-mcrypt php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0-xml php7.0-xmlrpc php7.0-bz2 php7.0-zip libapache2-mod-php7.0

Bonus: Install webmin


Download webmin

# wget http://prdownloads.sourceforge.net/webadmin/webmin_1.850_all.deb

Note: check http://www.webmin.com/deb.html for latest version

Install require library

# apt-get install libnet-ssleay-perl libauthen-pam-perl  libio-pty-perl  apt-show-versions

Install webmin

# dpkg -i webmin_1.850_all.deb

Note: follow this http://dedetoknotes.blogspot.co.id/2017/10/fixing-webmin-application-configuration.html to fix php.ini location

Done :)

Monday, October 2, 2017

Fixing webmin configuration file in Debian Stretch

PHP 7.0 configuration files

Others -> PHP Configuration -> Module Config:

/etc/php/7.0/apache2/php.ini=Configuration for mod_php
/etc/php/7.0/cgi/php.ini=Configuration for scripts run via CGI
/etc/php/7.0/cli/php.ini=Configuration for command-line scripts


Saturday, September 30, 2017

Debian Stretch: XEN configure & create DomU PV Debian part 3

We will use xen-tools to make it easier to create guest.

Configure /etc/xen-tools/xen-tools.conf
# vi /etc/xen-tools/xen-tools.conf
...
# lvm = vg0
lvm = volGroup1
...
install-method = debootstrap
...
debootstrap-cmd = /usr/sbin/debootstrap
...
size   = 80G       # Root disk, suffix (G, M, k) required
memory = 2G # Suffix (G, M, k) required
#maxmem = 2G      # Suffix (G, M, k) optional
swap   = 3G # Suffix (G, M, k) required
# noswap = 1      # Don't use swap at all for new systems.
fs     = ext4     # Default file system for any disk
dist   = `xt-guess-suite-and-mirror --suite`
                  # Default distribution is determined by Dom0's distribution
...
gateway = [your_ip_gateway]
netmask = [your_ip_netmask]
broadcast = [your_ip_broadcast]
...
nameserver = 8.8.8.8
...
bridge = br0
...
passwd = 1
...
pygrub = 1
...
mirror = `xt-guess-suite-and-mirror --mirror`
...

You can create your guest by command
# xen-create-image --hostname xdebian801 --ip=[your_ip]
...
Setting up root password
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
All done
Logfile produced at:
         /var/log/xen-tools/xdebian801.log

Installation Summary
---------------------
Hostname        :  xdebian801
Distribution    :  stretch
MAC Address     :  00:16:3E:61:28:46
IP Address(es)  :  [your_ip]
SSH Fingerprint :  SHA256:GVI1ri+NA82lDeVEf+pPgSHYFHzLe+SYkCxuTgBfEZw (DSA)
SSH Fingerprint :  SHA256:s5z6k6ek+V43NDG1CX77E81WWCVXZEOYNTEaQTXAaGM (ECDSA)
SSH Fingerprint :  SHA256:FUmWelgtmKtB/sCqrS3P5ZlttVRD/M0IVrArPnUs/8Y (ED25519)
SSH Fingerprint :  SHA256:LvrUnZE3ktnahsWFi+hXZ78+V87YZfmDKi9E01Rn+Zs (RSA)
Root Password   :  N/A

Start your guest
# xl create /etc/xen/xdebian801.cfg
# xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0 11815    24     r-----     653.2
xdebian801                                   5  2048     1     -b----       3.5

State:
  • r - running
  • b - blocked
  • p - paused
  • s - shutdown
  • c - crashed
  • d - dying

Connect to your guest
# xl connect xdebian801

To make your guest start after boot/restart
# mkdir /etc/xen/auto
# ln -s /etc/xen/xdebian801.cfg /etc/xen/auto/xdebian801.cfg

Example command to override default configuration during image creation:
# xen-create-image --hostname myexample --ip=192.168.1.1  --size=40G  --swap=2G --memory=1G --vcpus=2

References:

  1. http://blog.noviantech.com/2010/06/23/debian-kernels-and-tigon-tg3-firmware/
  2. https://wiki.debian.org/Firmware
  3. https://wiki.debian.org/LVM
  4. https://wiki.debian.org/LinuxRaidForAdmins
  5. https://ycnrg.org/xen-install-os-from-iso-pv/
  6. http://hwraid.le-vert.net/

Debian Stretch: XEN configure & create DomU HVM Centos part 2

Get centos iso cd
# mkdir iso/
# cd iso
# mkdir centos7
# cd centos7
# wget http://centos.biz.net.id/7/isos/x86_64/CentOS-7-x86_64-NetInstall-1708.iso
Note: you can choose your closest mirror.

Create logical volume for guest
# lvcreate -L300g -n xcentos701-disk volGroup1
  Logical volume "xcentos701-disk" created.
# lvdisplay
  --- Logical volume ---
  LV Path                /dev/volGroup1/xcentos701-disk
  LV Name                xcentos701-disk
  VG Name                volGroup1
  LV UUID                jmP1d1-9xFo-ruio-eEXx-Vkgi-w1Ah-X4tO7B
  LV Write Access        read/write
  LV Creation host, time server, 2017-09-29 02:29:55 +0700
  LV Status              available
  # open                 0
  LV Size                300.00 GiB
  Current LE             76800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:0

Create guest configuration file /etc/xen/xcentos701.cfg
builder = "hvm"
name = "xcentos701"
memory = 8192
vcpus = 4
vif = [ 'mac=00:16:4f:02:02:15, ip=[your_ip], bridge=br0' ]
# Disk Devices
# A list of `diskspec' entries as described in
# docs/misc/xl-disk-configuration.txt
disk = [
  '/dev/volGroup1/xcentos701-disk,raw,xvda,rw',
  'file:/[your_home]/iso/centos7/centos7.iso,xvdc:cdrom,r'
  ]
boot = "dc"
vnc = 1
vnclisten = "[your_ip]"
vncdisplay = 0
vncpasswd = "password"

You need to use any vnc viewer to finish installation. At the end, set root password and reboot. 

If the reboot is stuck, destroy the instance.
# xl destroy xcentos701

You need to remove cdrom from configuration, edit /etc/xen/xcentos701.cfg 
builder = "hvm"
name = "xcentos701"
memory = 8192
vcpus = 4
vif = [ 'mac=00:16:4f:02:02:15, ip=[your_ip], bridge=br0' ]
# Disk Devices
# A list of `diskspec' entries as described in
# docs/misc/xl-disk-configuration.txt
disk = [
  '/dev/volGroup1/xcentos701-disk,raw,xvda,rw'
  ]
boot = "c"
We don't need vnc anymore, so we remove it (comment it out).

Start your guest
# xl create /etc/xen/xcentos701.cfg 
# xl list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0 11815    24     r-----    5001.7
xcentos701                                   1 12288     4     -b----    9315.6

State:

  • r - running
  • b - blocked
  • p - paused
  • s - shutdown
  • c - crashed
  • d - dying


To connect to your guest
# xl console xencentos701

To make your guest start after boot/restart
# mkdir /etc/xen/auto
# ln -s /etc/xen/xcentos701.cfg /etc/xen/auto/xcentos701.cfg

Add user and allow su/sudo
# adduser [your_user]
# usermod -aG wheel [your_user]

References:

  1. http://blog.noviantech.com/2010/06/23/debian-kernels-and-tigon-tg3-firmware/
  2. https://wiki.debian.org/Firmware
  3. https://wiki.debian.org/LVM
  4. https://wiki.debian.org/LinuxRaidForAdmins
  5. https://ycnrg.org/xen-install-os-from-iso-pv/
  6. http://hwraid.le-vert.net/