Automatically Install Updates Ubuntu

Updating your system at periodic time is a good practice. But some of us forgot to do so. In search of automatic updates I found Unattended Upgrade. You can modify the package as per your need.

To start, first you need to install Unattended-Upgrade

sudo apt-get install unattended-upgrades

Unattended-Upgrade calls /etc/cron.daily/apt
To set everything first create a file /etc/apt/apt.conf.d/10periodic and edit it with your favorite editor. For eg I am attaching my file below.

sudo /etc/apt/apt.conf.d/10periodic
APT::Periodic::Enable "1";
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "5";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::RandomSleep "1800";
APT::Periodic::Verbose "1";

Note: Details about what these values mean may be found in the header of the /etc/cron.daily/apt file.
When the apt job starts, it will sleep for a random period between 0 and APT::Periodic::RandomSleep seconds. The default value is “1800″ so that the script will stall for up to 30 minutes (1800 seconds) so that the mirror servers are not crushed by everyone running their updates all at the same time. Only set this to 0 if you use a local mirror and don’t mind the load spikes. Note that while the apt job is sleeping it will cause the execution of the rest of your cron.daily jobs to be delayed.

Now edit /etc/apt/apt.conf.d/50unattended-upgrades, it should look like below:

// Automatically upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {    
    // ${distro_id} and ${distro_codename} will be automatically expanded
    "${distro_id} stable";
    "${distro_id} ${distro_codename}-security";
    "${distro_id} ${distro_codename}-updates";
//  "${distro_id} ${distro_codename}-proposed-updates";
};
 
// List of packages to not update
Unattended-Upgrade::Package-Blacklist {
//  "vim";
//  "libc6";
//  "libc6-dev";
//  "libc6-i686";
};
 
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you 
// have a working mail setup on your system. The package 'mailx'
// must be installed or anything that provides /usr/bin/mail.
Unattended-Upgrade::Mail "root@localhost";
 
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
Unattended-Upgrade::Remove-Unused-Dependencies "true";
 
// Automatically reboot *WITHOUT CONFIRMATION* if a 
// the file /var/run/reboot-required is found after the upgrade 
//Unattended-Upgrade::Automatic-Reboot "false";

Note : The double “//” serve as comments, so whatever follows “//” will not be evaluated

Now create STAMP file,

touch /var/lib/apt/periodic/update-stamp
touch /var/lib/apt/periodic/download-upgradeable-stamp
touch /var/lib/apt/periodic/upgrade-stamp
touch /var/lib/apt/periodic/autoclean-stamp

Now we will set cronjob to run the unattended-update

su
crontab -e
19 13 * * * /etc/cron.daily/apt > /home/vidyadhar/apt.log 2>&1

That’s it. The task will run at 1:19 PM every day.

Oracle Database 11g R2 on Ubuntu 11.04

Following is the how to for installing Oracle Database 11gR2 on Ubuntu 11.04

Installing Dependencies
To install dependencies, run

sudo apt-get install gcc make binutils gawk x11-utils rpm build-essential libaio1 libaio-dev libmotif4 libtool expat alien ksh pdksh unixODBC unixODBC-dev sysstat elfutils libelf-dev binutils lesstif2 lsb-cxx lsb-rpm libstdc++5

We need to create some softlinks to start the installation. To do so run the following commands as root,

ln -sf /bin/bash /bin/sh
ln -s /usr/bin/awk /bin/awk
ln -s /usr/bin/rpm /bin/rpm
ln -s /usr/bin/basename /bin/basename
ln -s /usr/lib/i386-linux-gnu/libpthread_nonshared.a /usr/lib/libpthread_nonshared.a
ln -s /usr/lib/i386-linux-gnu/libc_nonshared.a /usr/lib/libc_nonshared.a
ln -s /lib/i386-linux-gnu/libgcc_s.so.1 /lib/libgcc_s.so.1
ln -s /usr/lib/i386-linux-gnu/libstdc++.so.6 /usr/lib/libstdc++.so.6

Also we need to add oracle user and oinstall, dba, nobody group. Run following as a root user,

addgroup oinstall
addgroup dba
addgroup nobody
usermod -g nobody nobody
useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
mkdir /home/oracle
chown -R oracle:dba /home/oracle

We need to do changes in start-up script, run following as root,

mkdir /etc/rc.d
for i in 0 1 2 3 4 5 6 S
do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d 
done

Now we will create the directory for installation, and changes it owner to oracle. Run following commands as root

mkdir -p /u01/app/oracle
chown -R oracle:dba /u01

We also need to modify the kernel parameter, to do so run following commands as root

echo "#">> /etc/sysctl.conf
echo "# Oracle 11gR2 entries">> /etc/sysctl.conf
echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf
echo "fs.file-max=6815744" >> /etc/sysctl.conf
echo "kernel.shmall=2097152" >> /etc/sysctl.conf
echo "kernel.shmmni=4096" >> /etc/sysctl.conf
echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range=9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default=262144" >> /etc/sysctl.conf
echo "net.core.rmem_max=4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default=262144" >> /etc/sysctl.conf
echo "net.core.wmem_max=1048586" >> /etc/sysctl.conf
echo "kernel.shmmax=1073741824" >> /etc/sysctl.conf

Note: kernel.shmmax = max possible value, e.g. size of physical memory in bytes. In my case machine is having 2GB so we are specifying 1GB. Adjust the parameter as per your configuration

Load new kernel parameters, by running following as root user,

sysctl -p

We have to change shell configuration, to do the same run following commands as root user,

cp /etc/security/limits.conf /etc/security/limits.conf.original
echo "#Oracle 11gR2 shell limits:">>/etc/security/limits.conf
echo "oracle soft nproc 2048">>/etc/security/limits.conf
echo "oracle hard nproc 16384">>/etc/security/limits.conf
echo "oracle soft nofile 1024">>/etc/security/limits.conf
echo "oracle hard nofile 65536">>/etc/security/limits.conf

Download Oracle 11g R2 database from Oracle Download Center for linux.

I have downloaded both the zip in /home/oracle. We need to extract both the zip to start the installation. To unzip run,

cd /home/oracle
unzip linux_11gR2_database_1of2.zip 
unzip linux_11gR2_database_2of2.zip

Now we will start the installation. You can start the installation from /home/oracle/database.
Login as a oracle user.

su oracle

Go to the binaries and start the installation as a oracle user,

cd /home/oracle
chmod 777 -R database
cd database
./runInstaller -ignoreSysPrereqs

Now you will see the Welcome screen. As per my requirement we do not need email update so I am disabling the same.

Now in the step 2 we will choose “Create and configure database”

In step 3 as our machine is desktop call, I choose “Desktop class”

In step 4 you need to specify oracle_home, database file location, database name options. Adjust the parameter as per your setup. For reference see below screenshot,

In step 5 click on “Ignore all” option and select Next

In step 6 installation will show you the summary page.

Now it will start the installation

While in the process of Database Configuration Assistant, I got error saying oracle is not available. We select Ignore option

Now it will show “Database Control has been brought up in non-secure mode. Just click on OK.

It will show you the Enterprise Manager URL. Note it down for future reference.

We need to run root.sh script as a root user. Do the same and click on OK button.

It will show you successful installation message, just click close.

Now we need to login to Enterprise Manager to check the status.
Open browser and type http://server_ip:1158/em/

Enter SYS as username, choose Connect as sysdba and enter password which we specified at step 4

We will create init stop / start script to manage listener.

vi /etc/init.d/oracledb
#!/bin/bash
 
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin
 
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
 
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
 
exit 0

Change the permission of the script as a root

chmod a+x /etc/init.d/oracledb
update-rc.d oracledb defaults 99

Upgrade From Ubuntu 11.04 to Ubuntu 11.10 Alpha

This how to shows you how to upgrade from Ubuntu 11.04 to Ubuntu 11.10 Alpha release. Please note do this on your own risk as Ubuntu 11.10 is in still alpha stage.

First it is recommended that you install all pending updates before upgrading to the next release of Ubuntu.

To fully update your system, run the below command

sudo apt-get update && sudo apt-get upgrade

After updating, open a terminal and type

sudo update-manager -d

It will open Update Manager, from the window select Upgrade button next to New Ubuntu release ’11.10′ is available.

Then read the release notes and click Upgrade

Wait for all Ubuntu 11.10 packages to be downloaded and installed

When prompted during the upgrade, choose lightdm as your default display manager since it is going to be the default for all new releases of Ubuntu.

When all packages are downloaded and installed, click Restart Now to complete.

That’s it.

Changing Default Boot OS in Ubuntu 11.04

I am writing this post cause after upgrading the Ubuntu kernel I have to change OS boot order agin. I don’t want to do this again and again after every kernel update.
Workaround is change the boot order in /etc/grub.d/ folder. Run following command in ubuntu,

mv /etc/grub.d/30_os-prober /etc/grub.d/06_os-prober

Then update grub,

update-grub

Again this will not work if you are having more than one other OS. In such scenario you need to edit /etc/default/grub and change the GRUB_DEFAULT value so that it matches the OS you want.

Install Kernel 2.6.39 RC4 on Ubuntu 11.04

Recently I need to upgrade Ubuntu kernel version. I tried to do same with kernel-ppa. But it was not working. So I need to install it manually.

I am using 32bit machine and my current kernel version is :

uname -r
2.6.38-8-generic

To update the version to 2.6.39 RC4 download the kernel first:

mkdir /tmp/kernel
cd /tmp/kernel
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.39-rc4-natty/linux-image-2.6.39-020639rc4-generic_2.6.39-020639rc4.201104191410_i386.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v2.6.39-rc4-natty/linux-headers-2.6.39-020639rc4_2.6.39-020639rc4.201104191410_all.deb

Now we need to install kernel-image as well as kernel-headers

cd /tmp/kernel
sudo dpkg -i *

Now we need to reboot our machine to update the version:

sudo init 6

While rebooting choose kernel 2.6.39-020639rc4. Once the reboot confirm the kernel version by running

uname -r
2.6.39-020639rc4-generic

For 64bit machine you can download file from below links:
linux-image-2.6.39-rc4-amd64.deb
linux-headers-2.6.39-rc4-all.deb

Page 6 of 35« First...«456789»102030...Last »
rss twitter facbook

Categories

Archives