Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Sunday, September 21, 2008

EPEL repository for CentOS 5

To make your x64 CentOS more Desktop-friendly
create file "/etc/yum.repos.d/EPEL.repo"


with contest:

[epel]
name=Epel from fedora
baseurl=http://download.fedora.redhat.com/pub/epel/5/x86_64/
gpgcheck=0


From now it is possible to install such applications,that are not available in original CentOS installation,
as Wine,DosBox, fbreader, gnochm, gnokii, gparted, kdiff3, octave and so on.

Priorities plugin for yum should be enabled for that.

Wednesday, September 17, 2008

MySql basics CentOs 5


# mysql --version
mysql Ver 14.12 Distrib 5.0.45, for redhat-linux-gnu (x86_64) using readline 5.0

# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.soc
k' (2)

to resolve :

# sudo mysql_install_db --user=mysql


Set password:


/usr/bin/mysqladmin -u root password 'new-password'


start engine:


# sudo /usr/bin/mysqld_safe &

Starting mysqld daemon with databases from /var/lib/mysql

# ps -efa| grep mysql
root 20687 4414 0 23:19 pts/2 00:00:00 /bin/sh /usr/bin/mysqld_safe
mysql 20730 20687 0 23:19 pts/2 00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock
rtg 20749 4414 0 23:19 pts/2 00:00:00 grep mysql


change password:


# sudo /usr/bin/mysqladmin -u root password 'NEWpassword'


login and issue some commands:


# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)

mysql> help contents
You asked for help about help category: "Contents"
For more information, type 'help ', where is one of the following
categories:
Account Management
Administration
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Language Structure
Storage Engines
Stored Routines
Table Maintenance
Transactions
Triggers


Create user:


mysql> CREATE USER rtg identified by 'password'
-> ;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
[rtg@rtgCent usr]$ mysql -u rtg -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.45 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Sunday, July 27, 2008

ddd installation on centOS



get ddd there:

http://ftp.gnu.org/gnu/ddd/

Through yum, install following package:


RPM Group : Development/Libraries
Source : openmotif-2.3.0-0.5.el5.src.rpm
Yum Group : Development/X Software Development
-> Type : Optional
Build Time : Sun May 25 06:14:11 2008
Install Time : Sun Jul 27 23:56:16 2008
License : Open Group Public License


and it dependencies

then

tar -xf ddd-.tar.gz
cd ddd
./configure
make
sudo make install

Tuesday, July 22, 2008

Gcc auto-vectorization

Code: vect_auto.c

#include <stdio.h>
#include <string.h>

int main()
{
int i,j,k,l;

int a[4096];
int b[4096];

memset((void *)a,0,4096);
memset((void *)b,0,4096);

for(i=0;i<4096;i++)
{
a[i] =i%67;
b[i]= i%87;
}

for(k=0;k<200000;k++)
for(i=0;i<4096;i++)
a[i] = a[i]+b[i];

l=0;

for(j=0;j<4096;j++)
{l=l+a[i];}

// printf("%d\n",l);
return l;
}



$ gcc -O3 -ftree-vectorize vect_auto.c -o vect_o

disasm:


0x0000000000400530 : movdqa (%rax,%rbp,1),%xmm0
0x0000000000400535 : paddd (%rax,%rbx,1),%xmm0
0x000000000040053a : movdqa %xmm0,(%rax,%rbx,1)

0x000000000040053f : add $0x10,%rax
0x0000000000400543 : cmp $0x4000,%rax
0x0000000000400549 : jne 0x400530



$ gcc -O3 vect_auto.c -o vect_o_no
disasm:

0x0000000000400528 : xor %edx,%edx
0x000000000040052a : nopw 0x0(%rax,%rax,1)
0x0000000000400530 : mov 0x0(%rbp,%rdx,4),%eax
0x0000000000400534 : add %eax,(%rbx,%rdx,4)
0x0000000000400537 : add $0x1,%rdx
0x000000000040053b : cmp $0x1000,%rdx
0x0000000000400542 : jne 0x400530

0x0000000000400544 : add $0x1,%ecx
0x0000000000400547 : cmp $0x30d40,%ecx
0x000000000040054d : jne 0x400528

[rtg@rtgCent vect]$ time ./vect_o_no

real 0m2.178s
user 0m2.128s
sys 0m0.003s
[rtg@rtgCent vect]$ time ./vect_o

real 0m0.867s
user 0m0.835s
sys 0m0.001s

vector operations used in the second executable, but gain in time is not such a big.

Tuesday, July 15, 2008

CPP (C++) vs C, std::string vs char[] : string processing benchmark

Very simple benchmark.
cpp source vs c source

This presents usage of string concatenation operators in c and c++.

C is up to 20 times faster on different compilers on small strings.
(However it just 3 times faster on my CentOS if outer loop increased up to 10000)


[rtg@rtgCent cpp_vs_c]$ g++ -O3 ppstr.cpp -o ppstr
[rtg@rtgCent cpp_vs_c]$ gcc -O3 cstr.c -o cstr
[rtg@rtgCent cpp_vs_c]$ sudo time nice -n -10 ./ppstr
[rtg@rtgCent cpp_vs_c]$ sudo time nice -n -10 ./cstr

(or xlC instead of g++ and gcc if you have IBM compiler)

Saturday, July 12, 2008

Eject cd or DVD disk under Linux

If you are not able to eject cd (or DVD) disk from your linux box (by pushing button on cd(DVD)-rom)/ try


umount /dev/cdrom-hda

instead of cdrom-hda another name for the cd device can be.

This will solve issue.

Thursday, July 10, 2008

stupid vs smart, case vs ftable, algorithms vs processors, testing price vs gain

Actually, the task below can be easily solved by the paper and pen.

It was written in home at evening, just to measure performance as additional argument for rewriting stupid code for improving maintainability and performance of old legacy code.

Hypothetical example of the optimization of the following code was considered, and the return of the optimization effort (as resulting 'optimized' code) was timed.


     for(unsigned int i=0;i<65536;i++)
for(unsigned int j=0;j<65536;j++)
switch(j%15+1)
{
case 1:
f1();
break;
case 2:
f2();
...
}


The following are examples of performance, that can be achieved for integer massive operations due to different types of optimization.

Tried on AMD dual core DeskTop centOS, with gcc 4.1.3,
with optimization, and without.

4 types of code were considered:

Using switch(code) and case to define function to call;

Using case(code) and inlining function in call;

Using call to function by code ( fun(code) );

Just doing job without obfuscation by ftabs and cases.

Compilation done in following way:


[rtg@rtgCent cpp_exa]$ g++ -O3 case.cpp -o caseo
[rtg@rtgCent cpp_exa]$ g++ -O3 ftab.cpp -o ftabo
[rtg@rtgCent cpp_exa]$ g++ ftab.cpp -o ftab
[rtg@rtgCent cpp_exa]$ g++ case.cpp -o case
[rtg@rtgCent cpp_exa]$ su -


Some examples of output:

Red and green just presents timing for worst and best timing.


[root@rtgCent cpp_exa]# time nice -n -10 ./case
-458752

real 2m23.422s
user 2m23.205s
sys 0m0.112s

[root@rtgCent cpp_exa]# nice -n -10 ./caseo
-458752
[root@rtgCent cpp_exa]# time nice -n -10 ./caseo
-458752

real 1m3.688s
user 1m3.614s
sys 0m0.054s

[root@rtgCent cpp_exa]# time nice -n -10 ./ftab
-458752

real 1m41.664s
user 1m41.521s
sys 0m0.101s
[root@rtgCent cpp_exa]# time nice -n -10 ./ftabo
-458752

real 0m56.068s
user 0m56.004s
sys 0m0.047s
[root@rtgCent cpp_exa]# time nice -n -10 ./plaino
-458752

real 1m3.801s
user 1m3.732s
sys 0m0.047s

[root@rtgCent cpp_exa]# time nice -n -10 ./plain
-458752

real 1m53.174s
user 1m53.060s
sys 0m0.079s

[root@rtgCent cpp_exa]# time nice -n -10 ./opto
-458752

real 0m14.527s
user 0m14.509s
sys 0m0.014s

[root@rtgCent cpp_exa]# time nice -n -10 ./opt
-458752

real 0m31.956s
user 0m31.923s
sys 0m0.022s



It were just examples of the simpliest 'non algorithmic' optimization.

Simplified 'Algorithmic' optimization of the simplest case gives more than 100 time's faster output:


[root@rtgCent cpp_exa]# time nice -n -10 ./alg
-458752

real 0m0.011s
user 0m0.004s
sys 0m0.005s
[root@rtgCent cpp_exa]# time nice -n -10 ./algo
-458752

real 0m0.011s
user 0m0.003s
sys 0m0.005s



If you have some different opinion/results, please report in comments :)

By the way, who needs optimization today of critical systems, with today's pricing on retesting of system, and today modern cheap fast processors?


Code for examples:
alg.cpp
ftab.cpp
case.cpp
plain.cpp
opt.cpp


cpuinfo:

cpuinfo

Sunday, June 22, 2008

CentOS x64: firefox java and flash plugin

Last solutions of problems with x64 that worked:



Flash:


just got it from there:
http://labs.adobe.com/downloads/flashplayer10.html

then in terminal:

$ tar -xf libflashplayer-10.0.22.87.linux-x86_64.so.tar.gz
$ sudo cp libflashplayer.so /usr/lib64/mozilla/plugins/


Restart firefox-64 bit;
Youtube is working. Google analytics is also working.

Below are the previous problem solutions that worked in different time


They are working from time to time. (see comments also for details).

Java:



Firefox requested for additional plugin and directed to java page for download. After that, downloaded 32-bit (not x64!) rpm of java from sun.

Warning: if following this guide check java versions,sun updates versions of java, so numbers could be different, and pathes,if such present in the command line.



chmod a+x jre-6u6-linux-i586-rpm.bin
./jre-6u6-linux-i586-rpm.bin


fix alternatives file. Set sun's:


[root@rtgCent Desktop]# /usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1
[root@rtgCent Desktop]# /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jre1.6.0_06/bin/java 2
[root@rtgCent Desktop]# /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
*+ 2 /usr/java/jre1.6.0_06/bin/java

Enter to keep the current selection[+], or type selection number:

# ln -s /usr/java/jre1.6.0_06/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so

[root@rtgCent Desktop]# vi /etc/profile.d/java.sh
export J2RE_HOME=/usr/java/jre1.6.0_06
export PATH=$J2RE_HOME/bin:$PATH

save by :wq ; (or use gedit/mousepad/kate if don't like vi) restart firefox,
























check,if all working.

Flash


Solution 1:



For CentOS 5.2 firefox 64-bit works better with nsplugnwrapper from the box.
Just reinstall nsplugiwrapper to resolve initial problem with flash that can be.
However java not worked and I moved to 32-bit version of firefox.
Procedure below is related to ff 1.5 and CentOS 5.1, but it works for firefox 3 under centos 5.2 also

Solution 2:


To fix various errors with java and flash under CentOS x64 on my AMD-based home box, I've tried to use nspluginwrapper, manually installed java 64-bit from sun, also various versions of flash from Adobe by downloading rpm and manual install.

Finally problem was not completely solved after that, some issues were with flash, and I haven't got java working.

To solve I just decided to move on 32-bit version.

That way I just stopped Firefox, issued following

su -
[insert pwd]
yum list installed firefox jre
yum remove jre.x86_64
yum remove firefox.x86_64
yum install firefox.i386


and I got flash working without problems on google analytics.








Tuesday, June 17, 2008

mc : can not ftp on ftp://xxx.xxx.xxx.xxx address

To browse on ftp in mc :
F9->Left->ftp link

If you insert ip address with 'ftp://' prefix,
ftp can fail with error of bad access for anonymous.

Just insert ip without any prefixes and postfixes, and then browse.

Wednesday, May 21, 2008

KVM on core 2 duo laptop Ubuntu / Failed :(

After successfull usage of KVM on my CentOS desktop,
started installation of kvm on Ubuntu (Xubuntu 8.04) on my Core2 duo laptop:


$ sudo apt-get install kvm
..
* Your system does not have the CPU extensions
required to use KVM. Not doing anything.

# check for presence of vitualization in cpu
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T5470 @ 1.60GHz
stepping : 13
cpu MHz : 800.000
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm
constant_tsc arch_perfmon pebs bts pni monitor ds_cpl est tm2 ssse3 cx16
xtpr lahf_lm ida
bogomips : 3195.76
clflush size : 64

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Core(TM)2 Duo CPU T5470 @ 1.60GHz
stepping : 13
cpu MHz : 800.000
cache size : 2048 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
pbe nx lm constant_tsc arch_perfmon pebs bts pni monitor ds_cpl est
tm2 ssse3 cx16 xtpr lahf_lm ida
bogomips : 3191.86
clflush size : 64
#is virtualization in flags?
$ egrep 'vmx|svm' /proc/cpuinfo
$



Ups, failed :(

It was because KVM works only with specific processors.

To conclude: Different CPU model have different best virtual machine.

That way further I'll try Xen there
(which failed on my CentOS desktop due to lack of rtl8168/8111 drivers from the box;
It seems that if they will be installed, there is high probability of lacking
the driver after the updates of the xen kernel package).

Monday, May 19, 2008

Virtualization with KVM

Used this guide:
http://wiki.centos.org/HowTos/KVM to run virtual machine on my CentOS box.

Xubuntu run in 3-5 min's, that is 5-10 times faster than with native quemu virtualization from box.

For now I will use it as default virtual machine.

Tips for creation of new machine:


su
qemu-img create -f qcow2 disk.img 5G
qemu-kvm -hda disk.img -cdrom
/media/Elements_/images/eeexubuntu-7.10.3/eeexubuntu-7.10.3-desktop-i386.iso
-m 512 -boot d

rcs + rsync for keeping your files on several machines

I have two GNU/Linux laptops (Xubuntu) and one GNU/Linux desktop (CentOS).

Need to synchronize them to keep the integrity of the information on the machines.

Tried git, but found it too strong too keep my little docs and code snippets.
That way decided to use well known and stable GNU tools rcs and rsync.

man rcs 
man rsync
are prerequisites ;

Why rcs? Because repository could be synced with code/docs, and it is GNU.
Why rsync? It is GNU solution for syncing files.

Two basic session snippets for usage:

init files for directory:

cd fldr_for_sync
mkdir RCS
# --
rcs -i file # add new file under rcs
# -- it is the same with --
touch another_file; ci anoter_file


basic rsync dir with subdirs; it is not overwrites old files in dest dir;
permissions and links kept;

rsync -avz path_to_fldr_src path_to_dest


I found that rcs + sync can substitute git for such task and even make the task more clear and robust, due to the long history and high stability of the rcs and rsync tools.

Sunday, May 18, 2008

Hybernate on CentOS5.1

Found a way to hybernate (suspend to disk) through the xfce (and gnome) interface on CentOS5.1.
I don't see the hybernate button on the quit form (there only Logout, Restart and Shutdown).

Started

 gnome-power-preferences 
and made settings:


Then got the icon in the tray through which it is possible to hybernate:

Saturday, May 17, 2008

Todays issues

1) Found that plugin-wrapper installed under firefox to support Adobe Flash
was not working under other user. I have seen no graphics in analytics and youtube.

After I written about:plugins in firefox address line, plugins started work.
Don't know how exactly they were "activated", but it works for me.

2) Written alias freemind for freemind.sh in my local folder.

3) currently installing;
pidgin (I am under xfce, and like pidgin on my eee pc)
squashfs
and other:

Friday, May 16, 2008

freemind on CentOS 5.1

Required:
- Java from sun; installed from rpm with sun manual

export PATH=/usr/java/jre1.6.0_05/bin:$PATH
export JAVA_HOME="/usr/java/jre1.6.0_05"
export CLASSPATH=.:/usr/java/jdk1.6.0_05

Got zip freemind-max-bin from freemind sourceforge (ANY platform)
downloads page.

unzip in prepared folder in home;

chmod a+x freemind.sh
freemind.sh

also folder with unzipped freeminf could be added in the path.

Issues: no shortcuts working under xfce.
---
Update: It is working fine with full support of shortcuts under java jdk1.5.0_14

Thursday, May 15, 2008

httrack for centOS x64

httrack software solved me as the mirroring solution for Ubuntu.
Tryied get it on CentOS.
no .rpm found; downloaded tar.gz from httrack official site;


# tar -xf [tarfile]
# ./configure


configure: error: either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib

To resolve:

yum install zlib-devel
./configure
make all
make install

Ok than, I have it.

tried 'virtualization' under CentOS QEMU


Just to try what is new in word of virtual machines ( In my opinion it is not long now :) )

No idea why it can be best solution for any of common tasks.

Used file for filesystem, non-xen kernel (due to still having no network on -xen with my card).

Extremely slow.
>30 minutes to load Xubuntu Gutsy in machine.
(2-3 minutes on low-end Asus eeePC).

Host is CentOS 5.1 AMD Opteron x64 machine. Target i686 500 mb memory eeeXubuntu (Xubuntu gutsy 7.10).

Wednesday, May 14, 2008

upd:CentOS 5.1 realtec 8168/8111b

finally I have got it working under 'standard' (non-xen) kernel
using the guides from wolfy and wikipedia (http://wolfy.fedorapeople.org/) :

http://wiki.centos.org/HardwareList/RealTekRTL8111b
http://wolfy.fedorapeople.org/dkms-r8168/quick_install.html


However I still have no network under xen-kernel,
that is boring :(

Tuesday, May 13, 2008

CentOS(RHEL) and Suse difference from Ubuntu and Debian

Basically all this systems are GNU/Linux systems.

The main difference from the point of desktop user is set of applications that already present on fresh install, default configuration of desktop (graphics and theme mainly) and kernel version used.

All these distributions support kernel upgrade (through update manager, and manually, through recompilation of kernel downloaded from kernel.org (but in different recommended way for this distro's; however, seems

make oldconfig; 
make all
works on all distro's).

Main way of installing applications on the distributions is installing from packages.

Debian (with Knoppix) and Ubuntu are .deb-based distributions, where .deb is extension of package on these systems.

RedHat (CentOS, Fedora) and Suse are .rpm based distributions. Package extension is .rpm.

Also these systems support user-friendly layer for installing applications.

For .deb-based distro's main tool is apt (also different graphical front-ends used), and for .rpm based such tool is yum.

Both yum and apt provide similar functionality, such as installing, removing and searching for package.

Thats way, if you are migrating from .deb to .rpm – based system or from .rpm to .deb following matching for commands have to be considered:
RPM       DEB
--------------------
yum <-> apt, apt*
rpm <-> dpkg

Look into the man's for details.

If we consider applications packaged for distro's, traditionally, Debian has more opensource applications packaged and considered to be fast, however .rpm based distro's (as RedHat) has more Enterpise-Level applications (for example Sybase ASE database engine doesn't work on new Ubuntu's due to incompatibility in glibc).

Also, software for clustering, virtualization, logical volume group management is installed from box on CentOS5.1 with GUI and documentation.

However, watching movie or using some new cheap desktop hardware can be a problem on CentOs or RedHat, when on fresh Ubuntu it will work from Box.

There some .rpm-based desktop distributions like Ferdora, or Mandriva that repositories could be used for fresh drivers for video card or some other hardware. These distributions are more friendly on user side.

For my hardware, I use CentOS 5.1 for AMD64 desk (sometimes it works as home server), and Xubuntu's on my Laptops (eeePc, and 15.4 ' laptop from HP).

I was happy with my Xubuntu's and installed CentOS just to play with Sybase, and other enterprise-eevel products that are not supported by vendors for Debian (and Ubuntu).

64bit flash plugin for firefox 1.5 under rpm-based distro (CentOS)

Page that works in solving some issues, for installing plugin on 64-bit firefox 1.5 under CentOS 5.1 on my box:
http://www.linuxheadquarters.com/howto/64-bit/flash64.shtml

Google analytics however, not works pretty well with this plugin.

Use this article to get Flash and Java working.