Tikejhya: Ashish Nepal

Knowledgebase

Month: August 2012

Cut last x character leaving the rest

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

cut last x character leaving the rest.
Cut last 8 character leaving the rest

sed -e's/........$//g'

Here . represents the number of character (from behind LOL)

Aug 6 13:16:21 www kernel: python[21745]: segfault at 00000000000000f8 rip 0000003b14821d67 rsp 00007fffbdd4f470 error 4

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

[root@www bin]# tail -f /var/log/messages
www kernel: python[21745]: segfault at 00000000000000f8 rip 0000003b14821d67 rsp 00007fffbdd4f470 error 4

Testing Tool: objdump -Dslx filename

There are various potential reasons:
It could be due to right authentication, Right version of program (compatibility), sometimes moving back a version helps
Correct $PATH (in terms of evn veriable) Disk space and so on.

However my case was solved when i used script as relevent (privileged) user it was sorted. I got this error when python script was not running under correct user. (manual running was ok however not from application level which is kinda wired but it got solved.)

Python speaks same issue: http://bugs.python.org/issue210812
Good to learn: http://www.cyberciti.biz/tips/segmentation-fault-on-linux-unix.html

FIO Disk Benchmarking

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

FIO

wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/fio-2.0.7-1.el6.rf.x86_64.rpm
yum install libaio
rpm -ivh fio-2.0.7-1.el6.rf.x86_64.rp

Problem:
warning: fio-2.0.7-1.el6.rf.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 6b8d79e6: NOKEY
error: Failed dependencies:
libaio.so.1()(64bit) is needed by fio-2.0.7-1.el6.rf.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by fio-2.0.7-1.el6.rf.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by fio-2.0.7-1.el6.rf.x86_64

Solution:
yum install libaio

Sample run Command (googled it somewhere)

Sample command runs (syntax is exactly the same on all platforms):
1. Write out a 20GB file called fio.write.out in 64k chunks, 1 thread:
# fio –size=20g –bs=64k –rw=write –ioengine=sync –name=fio.write.out

2. Read 20GB from file fio.write.out in 64k chunks, 1 thread:
# fio –size=20g –bs=64k –rw=read –ioengine=sync –name=fio.write.out

3. Write out 4 x 10GB files in 64k chunks, 4 threads:
# fio –size=10g –bs=64k –rw=write –ioengine=sync –name=fio.write.out –numjobs=4

4. Read 10GB from files fio.write.out.* in 64k chunks, 4 threads:
# fio –size=10g –bs=64k –rw=read –ioengine=sync –name=fio.write.out –numjobs=4

How to create reiserfs partition on centos

How to create reiserfs partition on centos

In order to install reiserfs partition on centos you will need elrepo
(Download correct version of repo as in given sample i have used for centos 6)

rpm –import http://elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://elrepo.org/elrepo-release-6-4.el6.elrepo.noarch.rpm

Install reiserfs and utils

yum install kmod-reiserfs reiserfs-utils

Check the free disk (i will assume /dev/sdb)
I particularly added new partition in vmware workstation and rebooted server.

fdisk -l

create partition first.
fdisk /dev/sdb/
n
p
1
entre
entre
w – Write to finalize

Format with reiserfs
mkfs.reiserfs /dev/sdb1

Tune with reiserfs
reiserfstune -l drive_reiser /dev/sdb1

makedir that you want to mount at.
mkdir /reiser

edit fstab for boot load
vi /etc/fstab
/dev/sdb1 /reiser reiserfs defaults 0 0

Mount disk permanently
mount -a

How to setup dynamic and static ip in centos

How to setup dynamic and static ip in centos

cd /etc/sysconfig/network-scripts/

vi ifcfg-eth0

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=none

IPADDR=192.168.0.100

NETMASK=255.255.255.0

GATEWAY=192.168.0.1

HWADDR=00:0F:22:71:0A:53

If you want to switch back to DHCP, repeat the steps above and replace the contents of the ifcfg-eth0 file with the parameters below.
DEVICE=eth0

BOOTPROTO=dhcp

HWADDR=00:0F:20:71:0A:50

ONBOOT=yes

TYPE=Ethernet

DHCP_HOSTNAME=some.server.net
Restart your interface to apply the changes.

[root@tikejhya]#ifdown eth0

[root@tikejhya]#ifup eth0

OSSEC IPtables rules

#ossec
-A INPUT -i eth0 -p udp -m udp –sport 1514 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp –dport 1514 -j ACCEPT

As ossec uses UDP protocol so enable udp on firewall.

NTP (Time sync) Centos

In order to sync time using NTP in centos server normally you will have to have these basic settings in /etc/ntp.conf

server ntp1.server.net #Public server
server ntp2.server.net #Public Server
server 192.168.1.58 #Optionally you can choose one of yours as central
server ntp.central.server.net #Optional (assuming one of the local server)

restrict 172.30.39.0 mask 255.255.255.128 # restrict from making changes
restrict 172.30.38.0 mask 255.255.255.128 # restrict any server making changes

/etc/init.d/ntp stop && ntpdate 84.83.82.81 # Assuming 84.X… is ntp server
or
service ntpd stop && ntpdate 84.83.82.81 # Assuming 84.X… is ntp server

In order to ensure things are working well firewall port should be opened if there is any firewall inbetween. (NTP port is 123)

Powered by WordPress & Theme by Anders Norén