Tikejhya: Ashish Nepal

Knowledgebase

Month: November 2012

SysBench on CentOS – HowTo

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.

cd /usr/local/src

wget http://sourceforge.net/projects/sysbench/files/latest/download
tar -xvzf sysbench-0.4.xx.tar.gz
cd sysbench-0.4.12
libtoolize --force --copy
./autogen.sh
./configure
make

Problem:

/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make[2]: *** [sysbench] Error 1
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench’
make: *** [all-recursive] Error 1

Solution:

Pass linker: LDFLAGS linker flags, e.g. -L

export LDFLAGS='-L/usr/lib/mysql'
./configure
make
make install

Testing Parameter

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.

CPU Benchmark

sysbench --test=cpu --cpu-max-prime=20000 run

Fileio

sysbench --num-threads=16 --test=fileio --file-total-size=3G --file-test-mode=rndrw prepare

DB Benchmark

sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=databasename --mysql-user=root --mysql-password=PASSWORD prepare
sysbench --test=oltp --oltp-table-size=1000000 --mysql-db=databasename --mysql-user=root --mysql-password=PASSWORD --max-time=60 --oltp-read-only=on --max-requests=0 --num-threads=8 run

# Ideally take more than ram size

sysbench --test=fileio --file-total-size=30G prepare

sysbench --test=fileio --file-total-size=30G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run

Ref Doc: http://sysbench.sourceforge.net/docs/

Switching DHCP/Static IP Centos

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.

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=ashishnepal.com

Restart your interface to apply the changes.

ifdown eth0
ifup eth0

Package installed date

View package installation by date.

rpm -qa --qf '%{INSTALLTIME} (%{INSTALLTIME:date}): %{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}n' | sort -n

Squid Proxy

How to install squid in centos.

yum install squid

#It should do all for you, then add this line into

/etc/squid/squid.conf
visible_hostname

#create a log location.

squid -z /var/log/location

# Now learn something about ACL. and you are all done.

# Squid Monitoring Tool

yum install gcc make wget httpd
wget http://downloads.sourceforge.net/project/sarg/sarg/sarg-2.3.2/sarg-2.3.2.tar.gz


./configure error (sarg)

util.c: In function ‘getword_atoll’:
util.c:186: error: ‘LLONG_MAX’ undeclared (first use in this function)
util.c:186: error: (Each undeclared identifier is reported only once
util.c:186: error: for each function it appears in.)
make: *** [util.o] Error 1

CFLAGS="-std=gnu99" ./configure

# How to Monitor squid connection http/https.

Squid Monitoring

cat /var/log/squid/access.log | grep CONNECT | cut -d "/" -f 2 | cut -d " " -f 4 | sort -n | uniq -c | sort -n
cat /var/log/squid/access.log | grep HIT | cut -d "/" -f 4 | sort -n | uniq -c | sort -n

# How to enable ssl in squid.

squid –enable-ssl

Problem:
/usr/bin/ld: cannot find -lssl

Solution:
yum install openssl openssl-devel krb5-devel

How to kick user out from linux shell

# How to check user logged in Linux.
# How to kick user out from linux shell.

[root@tike ashish.nepal]# who -u
ashish.nepal pts/0 2012-10-26 08:57 02:52 16229 (10.8.0.14)
ashish.nepal pts/1 2012-10-26 11:47 . 25963 (10.8.0.14)
[root@tike ashish.nepal]# kill 16229

Hidding .svn files to be accessible from.

How to protect .svn directory in APACHE.

Hidding .svn files to be accessible from.

solution
vi /etc/httpd/conf/httpd.conf


Order allow,deny
Deny from all
Satisfy All

find and delete .svn

# How to find .svn Directory if any exists
ls `find new -type d -name .svn`

# How to delete all .svn folders in Directory
rm -rf `find new -type d -name .svn`

# Find files named .svn and list.
# -exec with rm would remove in this case.
find . -name .svn -exec echo {} \

Server sent unexpected return value (405 Method Not Allowed) in response to MKCOL request for

Server sent unexpected return value (405 Method Not Allowed) in response to MKCOL request for

svn delete folder1 –force
svn add folder1Copy
commit

svn mv folder1Copy/ folder1/
commit again and it’s fixed.

How to change mountpoint into new disk

How to change mountpoint into new disk

# Create New directory to mount into newly added disk
mkdir /mnt/fordb

# Now mount newly added disk to /mnt/new

mount /dev/sdx1 /mnt/fordb

# Now Copy content into new location
# This will work as backup + content will be copied across new disk

rsync -Pzarv /data/db/ /mnt/fordb/

# Unmount /mnt/fordb
# This will prepare you to remount into new desired location

umount /mnt/fordb

# move new content as diff name
# so that we could point in as /data/new

mv /data/db /data/db_bak

# Create directory with same name

mkdir /data/db

# mount into same directory

mount /dev/sdx1 /data/db

ERROR 2013 (HY000) at line : Lost connection to MySQL server during query

ERROR 2013 (HY000) at line : Lost connection to MySQL server during query

mysql –max_allowed_packet=32M database < dump.sql mysql --max_allowed_packet=100M -u root -p database < dump.sql Also, change the my.cnf or my.ini file under the mysqld section and set max_allowed_packet=100M or you could run these commands in a MySQL console connected to that same server: set global net_buffer_length=100000; set global max_allowed_packet=100000000; (for huge file)

Powered by WordPress & Theme by Anders Norén