" Real coders don't blog, or at least not very often! " A.R.

CentOS installation on VMware esxi


Notes concernant l'installation et la configuration de CentOS sur une machine virtuelle sur VMware esxi.
La machine virtuelle est d'abord créée à la main en fonction de paramètres pré-définis.
Ensuite l'OS est installé sur la machine virtuelle avec des options de base et afin de pouvoir recevoir un datadisk externe et de permettre plus tard l'installation d'application specifiques...
(ce type d'installation peut être fait sur un autre type de machine virtuelle en adaptant les premières instructions)


Preparation


  • create virtual machine on ESXi

    start the vSphere client and connect to the target ESXi server
    create new VM with typical settings, 2GB ram, 5GB disk, 2 cpu, RHEL5 64
    remove floppy disk
    add second disk for swap (2048MB)
    use thin disks

  • install Centos 5.x or 6.x on VM

    attach CentOs CD 1 iso (should be enough with most versions) and make available at boot
    boot the VM and start installation (BIOS of VM may need to be updated to boot on CD)
    create custom layout for disks: 1st disk: OS, 2nd disk: SWAP
    force all partitions to be primary
    for /dev/sda:
    create partition 1 for /boot (100 MB, ext3, force primary)
    create partition 2 as LVM physical (fill to max size, force primary)
    create LVM layout (volume group name "lg0", add logical volume name "lv0" using max space, ext3)
    for /dev/sdb:
    use as swap partition (use a separate disk to be able to exclude from virtual disk later and exclude from backups)

    edit network device: disable ipv6 support
    set the hostname
    disable Desktop-Gnome
    select "customize now" and unselect all packages except "base"


    Configuration

    login as root
    save list of installed rpms
    rpm -qa >allrpminit.log

    install useful packages
    yum install tcsh slocate logrotate man vim-enhanced which telnet wget mc sudo system-config-firewall-tui bind-utils traceroute

    create first user
    adduser alreg
    passwd alreg
      => enter password

    add this user to sudo file (after line starting with 'root')
    visudo
        alreg ALL=(ALL) ALL

    update shell for new user (replace bash with tcsh)
    vim /etc/passwd
        ...:/bin/tcsh

    specific for centos6
    yum install openssh-clients mlocate

    disable ipv6 the official way
    vi /etc/sysctl.conf
        net.ipv6.conf.all.disable_ipv6 = 1

    login as new user
    retrieve .tcshrc from known server
    scp alreg@XXXXX.com:/home/alreg/.tcshrc .

    login as root
    update computer name
    vim /etc/sysconfig/network
        HOSTNAME=<full qualified hostname>

    update selinux configuration to be nicer
    vim /etc/selinux/config
        SELINUX=permissive

    or even better disable it
    vim /etc/selinux/config
        SELINUX=disabled


    Centos 6 special steps

    after cloning a VM, the new network interface may be named eth1 as interfaces name increases if the mac address change
    verify new mac address in VM configuration or using ifconfig
    ifconfig -a

    update udev rule by setting eth0 as the name for the corresponding mac address and removing other entries
    vi /etc/udev/rules.d/70-persistent-net.rules
        SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:0C:29:11:22:33", ATTR{type}==”1", KERNEL==”eth*”, NAME=”eth0"

    update network configuration and verify mac address in that file
    vi /etc/sysconfig/network-scripts/ifcfg-eth0

    reboot


    Cleanup

    disable services that are not useful
    apmd: replaced by acpid
    avahi: mdns support
    bluetooth: hidd for bluetooth
    cups: for printing support
    mdmonitord: only if software raid
    pcscd: for smartcard support
    portmap rpcgssd rpcidmapd : for NIS or NFS (RPC)
    chkconfig --level 2345 apmd off
    chkconfig --level 2345 avahi-daemon off
    chkconfig --level 2345 bluetooth off
    chkconfig --level 2345 hidd off
    chkconfig --level 2345 cups off
    chkconfig --level 2345 mdmonitor off
    chkconfig --level 2345 pcscd off
    chkconfig --level 2345 sendmail off

    also if needed
    chkconfig --level 2345 portmap off
    chkconfig --level 2345 rpcgssd off
    chkconfig --level 2345 rpcidmapd off

    how to check what service is running?
    chkconfig --list |grep "3:on" |awk '{print $1}' |sort

    how to uninstall non necessary packages?
    yum remove apmd* samba* cups* nfs*
    yum remove gnome* bluez* avahi*

    how to check the current levels of a service? : 'chkconfig --list <servicename>'
    chkconfig --list apmd

    how to start a service?
    service <servicename> start

    how to stop a service?
    service <servicename> stop

    update kernel to latest available version
    yum update kernel*

    (don't worry about possible "end_request: I/O error, dev fd0, sector 0"
    it just means that you don't have a floppy attached)

    reboot
    shutdown -r now

    update packages
    yum update

    update search database
    updatedb


  • backup vm

    using the vSphere client, connect to the local datastore on the ESXi server
    create a backup folder under "bu/centos_64_orig")
    enter the VM folder, then press refresh to update the list of files
    select all the files and right-click "copy"
    go inside the new backup folder and right-click "paste"
    the status of the files copy can be seen at the bottom of the vSphere client screen
    wait until all copies have reached 100% before doing anything else

    copy vmdk files using vmkfstools.pl from administration virtual appliance (specify -d "" for thick because of a bug in the script)
    vmkfstools.pl -i /vmfs/volumes/datastore1/centos_64/centos_64.vmdk /vmfs/volumes/datastore1/bu/centos_64_orig/centos_64.vmdk -d "" -a lsiLogic


  • install VMWare tools (rpm VERSION)

    from vSphere client, right-click VM and select install/upgrade tools (tools iso will then be attached as /dev/cdrom)

    retrieve VMWare tools rpm
    cd /mnt
    mkdir cdrom
    mount /dev/cdrom /mnt/cdrom
    cd /mnt/cdrom
    cp VMwareTools*.rpm /tmp
    umount /mnt/cdrom

    install rpm
    cd /tmp
    rpm -Uvh VMwareTools*.rpm

    configure VMWare tools
    vmware-config-tools.pl


  • install VMWare tools (tar.gz VERSION)

    from vSphere client, right-click VM and select install/upgrade tools (tools iso will then be attached as /dev/cdrom)

    retrieve VMWare tools tar.gz
    cd /mnt
    mkdir cdrom
    mount /dev/cdrom /mnt/cdrom
    cd /mount/cdrom
    cp VMwareTools*.gz /tmp
    umount /mnt/cdrom

    install rpm
    cd /tmp
    tar xvfz VMwareTools*.gz
    cd vmware-tools-distrib/
    ./vmware-install.pl

    accept everything

  • install extra repositories

    install yum-priorities
    yum install yum-priorities

    check that it's activated
    vim /etc/yum/pluginconf.d/priorities.conf
        [main]
        enabled=1

    update repository files with the following settings
    (in each section, add a line "priority=n" with n the value)
    [base], [updates], [addons], [extras] ... priority=1
    [centosplus], [contrib] ... priority=2
    third party repositories such as rpmforge ... priority=N (with N > 10 based on your preferences)
    cd /etc/yum.repos.d
    vim CentOS-Base.repo

    add a priority line as defined above in each section

  • install rpmforge repository (based on architecture)

    mkdir /goinfre
    cd /goinfre
    wget http://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

    or
    wget http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

    install key
    rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

    verify package
    rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm

    install the package
    rpm -ivh rpmforge-release-0.3.6-1.el5.rf.*.rpm

    update priority for rpmforge repository
    vim /etc/yum.repos.d/rpmforge.repo
        priority=20

    check priorities are working
    (should say "Loading "priorities" and give a number of packages "excluded due tu repository priority")
    yum check-update


    install fluxbox and vncserver

    (optional)

    update list of packages we want to retrieve from rpmforge
    vim /etc/yum.repos.d/rpmforge.repo
        includepkgs= fluxbox* artwiz* imlib2* iftop* libid3tag* python-xdg* clam* rrdtool perl-rrdtool
        

    install vnc server
    yum install vnc-server xorg-x11-twm xterm

    install fluxbox
    yum install fluxbox

    as alreg, start vncserver (always run vnc as a regular user)
    vncserver -depth 16 -geometry 1280x1024 :9

    stop vncserver
    vncserver -kill :9

    update vnc configuration to use fluxbox
    vim /home/alreg/.vnc/xstartup
        #twm &
        fluxbox &

    as root, add firewall entry to let vnc traffic go through (click customize and add port 5909 to other ports: "tcp:5909")
    system-config-securitylevel-tui


  • fixed IP

    it is probably better to have a fixed ip address
    vim /etc/sysconfig/network-scripts/ifcfg-eth0
        BROADCAST=216.XXX.XXX.191
        NETWORK=216.XXX.XXX.160
        DEVICE=eth0
        ONBOOT=yes
        HWADDR=00:0c:29:11:22:33
        IPADDR=172.30.4.8
        NETMASK=255.255.255.0
        GATEWAY=172.30.4.1
        Type=Ethernet

    ATTENTION: once you do that you will most likely lose network access
    service network restart

    update nameserver
    vim /etc/resolv.conf
        nameserver <<<nameserverip>>>


  • BIND - as caching nameserver

    install named for faster local query: first chrooted named, then caching nameserver
    yum install bind-chroot bind-utils
    yum install caching-nameserver
    service named start
    chkconfig --levels 2345 named on

    update resolv.conf to use local nameserver as first choice (insert at top)
    vim /etc/resolv.conf
        nameserver 127.0.0.1
        



    OK
  • October 23, 2011
    1200 words


    Categories
    Tags
    centos esxi vmware

    Connect. Socialize.