Tag Archives: LINUX
Create local repository using CD/DVD in CentOS/Redhat
“/etc/yum.repos.d” is the location which contain all the files related to repository.
1) Login as root user
2) mount the cd/dvd
3) create a file in “/etc/yum.repos.d” named as “localrepo.repo” with below content
4) Execute “yum-config-manager –enable localrepo” to enable the repository
5) Execute “yum repolist” command to list the repos which are enabled
Now the creation of repository is completed and you can install the packages required using yum command.
EX:-
yum -y install gcc*
yum update or yum install failing yummain.user_main(sys.argv[1:], exit_code=True)
Traceback (most recent call last):
File “/bin/yum”, line 29, in
yummain.user_main(sys.argv[1:], exit_code=True)
File “/usr/share/yum-cli/yummain.py”, line 365, in user_main
errcode = main(args)
File “/usr/share/yum-cli/yummain.py”, line 271, in main
return_code = base.doTransaction()
File “/usr/share/yum-cli/cli.py”, line 773, in doTransaction
resultobject = self.runTransaction(cb=cb)
File “/usr/lib/python2.7/site-packages/yum/__init__.py”, line 1736, in runTransaction
if self.fssnap.available and ((self.conf.fssnap_automatic_pre or
File “/usr/lib/python2.7/site-packages/yum/__init__.py”, line 1126, in
fssnap = property(fget=lambda self: self._getFSsnap(),
File “/usr/lib/python2.7/site-packages/yum/__init__.py”, line 1062, in _getFSsnap
devices=devices)
File “/usr/lib/python2.7/site-packages/yum/fssnapshots.py”, line 158, in __init__
self._vgnames = _list_vg_names() if self.available else []
File “/usr/lib/python2.7/site-packages/yum/fssnapshots.py”, line 56, in _list_vg_names
names = lvm.listVgNames()
lvm.LibLVMError: (0, ”)
Solution :
reboot server
yum clean metadata
yum clean all
yum update
Scheduling in crontab
PostgreSQL auto start script
#
# chkconfig: 2345 80 05
# description: start and stop PostgreSQL Database Enterprise Edition
#
#
# Note: Change the value of POSTGRES to the login name of the PostgreSQL owner
POSTGRES=postgres
export PGDATA=/home/postgres/DATA
export PGPORT=5432
export PGSOFTWARE=/home/postgres/9.6_SOFTWARE #location where we installed the software
PATH=${PATH}:$PGSOFTWARE/bin
export PATH
case $1 in
‘start’)
echo $”Starting PostgreSQL: “
if [[ `whoami` == ‘postgres’ ]]
then
$PGSOFTWARE/bin/pg_ctl start
else
su $POSTGRES -c “$PGSOFTWARE/bin/pg_ctl start”
fi
;;
‘stop’)
echo $”Shutting down PostgreSQL: “
if [[ `whoami` == ‘postgres’ ]]
then
$PGSOFTWARE/bin/pg_ctl start
else
su $POSTGRES -c “$PGSOFTWARE/bin/pg_ctl stop”
fi
;;
‘status’)
echo $”Status of PostgreSQL: “
if [[ `whoami` == ‘postgres’ ]]
then
$PGSOFTWARE/bin/pg_ctl status
else
su $POSTGRES -c “$PGSOFTWARE/bin/pg_ctl status”
fi
;;
‘restart’)
echo $”Restarting PostgreSQL: “
if [[ `whoami` == ‘postgres’ ]]
then
$PGSOFTWARE/bin/pg_ctl restart
else
su $POSTGRES -c “$PGSOFTWARE/bin/pg_ctl restart”
fi
;;
*)
echo “usage: $0 {start|stop|restart|status}”
exit
;;
esac
exit
Get data from Oracle table into Linux array
select * from machines;
HOSTNAME IPADDRESS
——————– ——————–
machine1 192.68.1.1
machine2 192.68.1.2
I need to run a function for each hostname and ipaddress and repeat this for all the rows. I am taking the content into array and loop over the results and run the function for each row.
Below is the code for the same.
#!/bin/bash
export ORACLE_HOME=/home/oracle/app/oracle/product/12.1.0/dbhome_1
export ORACLE_SID=orcl
export PATH=/home/oracle/app/oracle/product/12.1.0/dbhome_1/bin:$PATH
elements=`sqlplus -s / as sysdba <<EOF
set feedback off
set echo off
set trimspool on
set termout off
set serveroutput on size 100000 format wrapped
set lines 500
set pages 0
select * from test;
EOF`
declare -a my_array=($elements) # Declaring the array and loading the rows
my_array_length=${#my_array[@]} # getting the lenght of the array
loop_var=0 # loop variable to retrieve the data
while(($loop_var<$my_array_length))
do
echo “Machine “:${my_array[$loop_var]};
echo “IP ADDRESS “:${my_array[$loop_var+1]};
loop_var=$loop_var+2;
done
[oracle@OracleED ~]$ sh /tmp/t.sh
Machine :machine1
IP ADDRESS :192.68.1.1
Machine :machine2
IP ADDRESS :192.68.1.2
SUSE Linux root file system 100% full
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 3
suddenly my root file system is getting full , occupied 214 GB of space.
Solution :-
It is bug in Suse linux.
There is a file “/root/.xsession-errors” which occupies the space.
refer to below link
Download software directly from GitHub to Linux(Redhat)
yum -y install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.uhost.hk
* extras: centos.uhost.hk
* updates: centos.uhost.hk
Package git-1.8.3.1-6.el7_2.1.x86_64 already installed and latest version
2) Clone the package using the URL.
[root@replication extension]# git clone https://github.com/EnterpriseDB/mysql_fdw.git
Cloning into ‘mysql_fdw’…
remote: Counting objects: 399, done.
remote: Total 399 (delta 0), reused 0 (delta 0), pack-reused 399
Receiving objects: 100% (399/399), 211.40 KiB | 134.00 KiB/s, done.
Resolving deltas: 100% (240/240), done.
[root@replication extension]# cd mysql_fdw/
[root@replication mysql_fdw]# ls -ltr
total 180
-rw-r–r– 1 root root 8965 Oct 25 12:05 README.md
-rw-r–r– 1 root root 1155 Oct 25 12:05 META.json
-rw-r–r– 1 root root 1558 Oct 25 12:05 Makefile
-rw-r–r– 1 root root 1038 Oct 25 12:05 LICENSE
….
….
….
how to create a new filesystem in REDHAT Linux
fdisk /dev/sda
enter n to create new partition.
enter the size of the partition.
enter “w” to write the partition table and restart the system if required.
2) Format the partition for the filesystem.
/sbin/mkfs -t ext3 /dev/sda11
[root@node3 ~]# /sbin/mkfs -t ext3 /dev/sda11
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3260416 inodes, 6516365 blocks
325818 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
199 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
3) Give a label to the partition
[root@node3 ~]# /sbin/e2label /dev/sda11 /oradisk
4) Add an entry in the /etc/fstab to make the filesystem mount on every reboot.
LABEL=/oradisk /oradisk ext3 defaults 1 2
5) Mount the new filesystem
[root@node3 ~]# mkdir /oradisk
[root@node3 ~]# chown oracle:oinstall /oradisk
[root@node3 ~]# mount /dev/sda11 /oradisk
[root@node3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 9.5G 649M 8.4G 8% /
/dev/sda9 2.9G 69M 2.7G 3% /opt
/dev/sda8 4.8G 138M 4.4G 4% /home
/dev/sda7 4.8G 2.7G 1.8G 60% /usr
/dev/sda10 1.9G 36M 1.8G 2% /usr/local
/dev/sda6 4.8G 198M 4.3G 5% /var
/dev/sda3 9.5G 151M 8.9G 2% /tmp
/dev/sda1 2.9G 75M 2.7G 3% /boot
tmpfs 501M 0 501M 0% /dev/shm
/dev/sda11 25G 173M 24G 1% /oradisk ===> filesystem got mounted
How to configure NFS in REDHAT Linux
Below is my configuration
NODE3 : (NFS Client)
192.9.1.103
NODE2 : (NFS Server)
192.9.1.101
Folder to share : /u01/SOFTWARE
Steps to configure
1) Install the required packages for the NFS on both the server(NODE2) and client(NODE3).
nfs-utils-1.0.9-42.el5.x86_64.rpm
nfs-utils-lib-1.0.8-7.6.el5.x86_64.rpm
nfs-utils-lib-devel-1.0.8-7.6.el5.x86_64.rpm
nfs4-acl-tools-0.3.3-1.el5.x86_64.rpm
portmap-4.0-65.2.2.1.x86_64.rpm
To install the package , use the below command.
rpm -ivh
2) ON NFS SERVER
2a) make an entry about the directory we want to share in the /etc/exports file like below.
/u01/SOFTWARE 192.9.1.103(rw,sync,fsid=0)
2b) Start the services
service nfs start
service portmap start
2c) Configure service will start automatically after reboot.
chkconfig nfs on
chkconfig portmap on
3) ON CLIENT
3a) execute the below command as root user.
mkdir /SOFTWARE
mount 192.9.1.101:/u01/SOFTWARE /SOFTWARE
[root@node3 etc]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5 9.5G 647M 8.4G 8% /
/dev/sda9 2.9G 69M 2.7G 3% /opt
/dev/sda8 4.8G 138M 4.4G 4% /home
/dev/sda7 4.8G 2.7G 1.9G 60% /usr
/dev/sda10 1.9G 36M 1.8G 2% /usr/local
/dev/sda6 4.8G 194M 4.3G 5% /var
/dev/sda3 9.5G 151M 8.9G 2% /tmp
/dev/sda1 2.9G 75M 2.7G 3% /boot
tmpfs 501M 0 501M 0% /dev/shm
192.9.1.101:/u01/SOFTWARE 59G 12G 44G 21% /SOFTWARE ===> Filesystem got mounted.
3b) Make below entry in /etc/fstab of nfs client (NODE2) to mount the filesystem automatically after reboot.
192.9.1.103:/u01/SOFTWARE /SOFTWARE nfs4 soft,intr,rsize=8192,wsize=8192,nosuid