This page shows how to install the Linux distribution CentOS 6 64bit. CentOS is a free clone of Red Hat Enterprise Linux.
For the purposes of this page, we will assume that the machine being setup is called template and that the IP address is 172.16.1.1. You must change these values as appropriate when setting up your machine.
It is standard practice to separate the os installation and application data onto separate disks. For example, if we are installing an Oracle database server, we install CentOS onto one disk and create a second, separate disk to store the Oracle installation and data on.
You will need a computer, either physical or virtual, to install CentOS on. Creating virtual machines is covered in a separate page of this wiki.
Whether you are installing CentOS on a physical or a virtual machine, you will need access to the DVD ISO file. This can be downloaded off the internet from on of the links on the CentOS wiki.
If you are installing CentOS on a physical machine, burn the ISO to a DVD-R and use that. It is assumed that you know how to get a computer to boot from a DVD.
If you are installing CentOS on VirtualBox or VMware, make sure that the ISO file is loading in the virtual DVD drive and is connected to the virtual machine.
In this example, we have two disks. The first is /dev/sda and is 25Gb in size. The second is /dev/sdb and is 4Gb in size. We will use /dev/sda to store the OS and /dev/sdb to store the swap space.
| Mount Point | File System Type | Logical Volume Name | Size |
|---|---|---|---|
| / | ext4 | root | 4120 |
| /usr | ext4 | usr | 4120 |
| /opt | ext4 | opt | 1040 |
| /var | ext4 | var | 1040 |
| /tmp | ext4 | tmp | 2052 |
| /home | ext4 | tmp | 500 |
| Mount Point | File System Type | Logical Volume Name | Size |
|---|---|---|---|
| / | ext4 | root | 4120 |
| /usr | ext4 | usr | 3076 |
| /opt | ext4 | opt | 1040 |
| /var | ext4 | var | 1040 |
| /tmp | ext4 | tmp | 2052 |
| /home | ext4 | tmp | 500 |
You can left click the network icon at the top right corner of the screen and select “System eth0” to get a DCHP address. You can then ssh into the box to enable to you paste the following commands into a terminal rather than typing them out manually.
Increase the number of commands that are kept in bash history and have the history file formatted so that it timestamps each command. Set the terminal to write to bash history on command completion rather than when the terminal window closes
cat « EOF » /etc/bashrc
export HISTSIZE=1000000
export HISTTIMEFORMAT='%F %T '
export PROMPT_COMMAND='history -a'
EOF
The NetworkManager package gets in the way of networking by trying to be clever with IP addresses. As we are setting up a server that just sits there and never changes, we want to get rid of Networkmanager so that it doesn't interfere with the network configuration we set. Once it is removed, we restart the network service.
yum -y remove *NetworkManager*
service network restart
Edit sysctl.conf to disable IPv6. Obviously, you shouldn't do this if you intend to use IPv6. This command also disables TCP timestamps to make the machines a little less vulnerable to attack.
cat « EOF » /etc/sysctl.conf
- Disables TCP Timestamps
net.ipv4.tcp_timestamps = 0
- Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
EOF
As this is a server, you will want to configure a static IP on it rather than leaving it with DHCP.
Configure the network settings on the machine. Copy the following section of text into a text editor and change the values of the variables as appropriate to match the values you are using for the machine you are setting up. Open up a terminal as root on the machine and paste in the text. If necessary, access this wiki page from within the machine and copy/paste these commands manually (editing them as needed).
IPADDRESS=172.16.1.10 SUBNET=255.255.0.0 GATEWAY=172.16.10.10 DNS1=172.16.1.2 DNS1=172.16.1.3 DOMAIN=example.com HSTNAME="template.$DOMAIN" ADAPTER=eth0 rm -f /etc/udev/rules.d/70-persistent-net.rules TARGETFILE="/etc/sysconfig/network-scripts/ifcfg-$ADAPTER" echo "DEVICE=$ADAPTER" > $TARGETFILE echo 'BOOTPROTO=static' >> $TARGETFILE echo 'NM_CONTROLLED=no' >> $TARGETFILE echo 'ONBOOT=yes' >> $TARGETFILE echo 'TYPE=Ethernet' >> $TARGETFILE echo "IPADDR=$IPADDRESS" >> $TARGETFILE echo "NETMASK=$SUBNET" >> $TARGETFILE TARGETFILE="/etc/sysconfig/network" echo 'NETWORKING=yes' > $TARGETFILE echo "HOSTNAME=$HSTNAME" >> $TARGETFILE echo "GATEWAY=$GATEWAY" >> $TARGETFILE TARGETFILE="/etc/resolv.conf" echo "search $DOMAIN" > $TARGETFILE echo "nameserver $DNS1" >> $TARGETFILE echo "nameserver $DNS2" >> $TARGETFILE service network restart
You may need to log into Gnome to get the user-dirs.locale generated.
sed -i "s/_US/_GB/g" /root/.config/user-dirs.locale sed -i "s/_US/_GB/g" /etc/sysconfig/i18n
mkdir /etc/skel/.config cp /root/.config/user-dirs.locale /etc/skel/.config/ cp /root/.config/user-dirs.dirs /etc/skel/.config/ mkdir /etc/skel/Desktop mkdir /etc/skel/Documents mkdir /etc/skel/Downloads mkdir /etc/skel/Music mkdir /etc/skel/Pictures mkdir /etc/skel/Public mkdir /etc/skel/Templates mkdir /etc/skel/Videos
CentOS comes with Java 1.6 installed. We don't want this so remove it.
yum -y remove java
We now need to install lots of software
yum -y install \
gedit gconf-editor \
perl \
java-1.7.0-openjdk java-1.7.0-openjdk-devel \
policycoreutils-python \
gcc kernel kernel-devel kernel-headers dkms make bzip2 \
wget unzip openssh-clients cifs-utils
Now that Java is installed, set JAVA_HOME so that when and if we install Groovy, it will work properly.
echo 'export JAVA_HOME=/usr/lib/jvm/java; export JAVA_HOME' >> /etc/profile
Restart the machine by clicking System→Shutdown→Restart or by typing 'init 6' in the root terminal window.
Obviously you should skip this section if you are installing CentOS on a physical machine. Instructions can be found here.