總網頁檢視次數
星期二, 8月 25, 2009
CENTOS - iostat package
To Check Disk usage
iostat -x 5
iostat -t 2 -k
Check free memory
free -m
星期三, 8月 19, 2009
CENTOS - RAMDISK
Ramdisk is very good to have if you want something to stay in memory. Files in memory makes it so you can access them with out having to access hard drive all the time. Perfect candidates would be things which do not change eg. web images or downloadable files, etc. If you have Linux Kernel 2.4 or later, you already have support of ramdisk built in. You can check if ramdisk is setup by doing:
# dmesg | grep RAMDISK
RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize
You should get above output on CentOS and RHEL. Other linux flavors will have similar output as well. If you would like to see how they are named and what you would need to refer to, do the following:
# ls -l /dev/ram*
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ram -> ram1
brw-rw---- 1 root disk 1, 0 Apr 24 12:05 /dev/ram0
brw-rw---- 1 root disk 1, 1 Apr 24 12:05 /dev/ram1
brw-rw---- 1 root disk 1, 10 Apr 24 12:05 /dev/ram10
brw-rw---- 1 root disk 1, 11 Apr 24 12:05 /dev/ram11
brw-rw---- 1 root disk 1, 12 Apr 24 12:05 /dev/ram12
brw-rw---- 1 root disk 1, 13 Apr 24 12:05 /dev/ram13
brw-rw---- 1 root disk 1, 14 Apr 24 12:05 /dev/ram14
brw-rw---- 1 root disk 1, 15 Apr 24 12:05 /dev/ram15
brw-rw---- 1 root disk 1, 2 Apr 24 12:05 /dev/ram2
brw-rw---- 1 root disk 1, 3 Apr 24 12:05 /dev/ram3
brw-rw---- 1 root disk 1, 4 Apr 24 12:05 /dev/ram4
brw-rw---- 1 root disk 1, 5 Apr 24 12:05 /dev/ram5
brw-rw---- 1 root disk 1, 6 Apr 24 12:05 /dev/ram6
brw-rw---- 1 root disk 1, 7 Apr 24 12:05 /dev/ram7
brw-rw---- 1 root disk 1, 8 Apr 24 12:05 /dev/ram8
brw-rw---- 1 root disk 1, 9 Apr 24 12:05 /dev/ram9
lrwxrwxrwx 1 root root 4 Apr 24 12:05 /dev/ramdisk -> ram0
All those ramdisks listed have same size. In above example, they are all 16MB. Let us change that so we have more space allowed. Note that I say allowed and not allocated. We allocate space in one of the later steps by formatting one of the drives above. Let us set it up so we have 128 MB. Since this has to be in multiples of 1024, we will setup Ramdisk to have 131072K.
vi /etc/grub.conf
Find first line which looks similar to following:
kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00
add ramdisk_size=131072 to the end of the line. Now your line should look like:
kernel /vmlinuz-2.6.9-42.0.10.EL ro root=/dev/VolGroup00/LogVol00 ramdisk_size=131072 Save and exit grub.conf. At this point you have it configured to have ramdisk with new size but it does not take effect until you reboot your system. Once you have rebooted your system, we can start doing rest of configurations.
mke2fs -m 0 /dev/ram0
This will format the ram0 ramdrive for us to use. At this point, kernel will allocate space for you. Let us setup Ramdisk mount point so we can use it. We will also have it be owned by user “sunny” so that user can read/write to that mount.
mkdir /home/ramdisk
mount /dev/ram0 /home/ramdisk
chown sunny.sunny /home/ramdisk
At this point you should be able to type: mount and see your new Ramdisk drive mounted on /home/ramdisk
Remember that everything you put on this drive will be gone if you reboot your server. If you unmounted the Ramdisk drive and remounted it, your files will still be there. It is because your system has that much ram set aside for your Ramdisk and will not use it for anything else. If you would like to setup Ramdisk the same next time you boot up, add these lines to your /etc/rc.local files.
mke2fs -m 0 /dev/ram0
mount /dev/ram0 /home/ramdisk
chown sunny.sunny /home/ramdisk
Source from : http://crazytoon.com/2007/06/01/ramdisk-how-do-you-install-and-set-up-ramdisk-under-linux-centos-rhel-fedora/
星期六, 8月 15, 2009
CENTOS - Update time zone and time
crontab -e
0 * * * * /usr/sbin/ntpdate -u stdtime.gov.hk
CENTOS 5.3 bonding ( my own script )
Add following two lines
alias bond0 bonding
options bond0 miimon=80 mode=6
*** backup configuration files for rollback
#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak
#cp /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1.bak
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
Del all except the hardware mac address (HWADDR=xx:xx.... )
Add the following lines
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
Del all except the hardware mac address (HWADDR=xx:xx.... )
Add the following lines
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
*** Add new bond0 configuration file
#vi /etc/sysconfig/network-scripts/ifcfg-bond0
Add the following lines
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=x.x.x.x
GATEWAY=x.x.x.1
USERCTL=no
MTU=9000
That's all ... restart network to test
#service network restart
Remember to test reboot and see if all configuration will be up automatically ..
#shutdown -r now
CENTOS- bonding ( network teaming )
System: Debian Sarge 3.1 (vanilla kernel 2.6.12.4)
Modules Involved: bonding, mii, nic_module (e100 in this example)
Utilities: ifenslave, mii-tool
Preparation:
Before attempting to bond two NICs, it is highly recommended that you verify the integrity and functionality of each NIC on its own. This document assumes that you've already done that. Using 'mii-tool' you should see something like the following:
testbox:/# mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD, link ok
In order for this to work, the kernel must have support for bonding
devices. A few ways to check would be:
testbox:/# modprobe --list | grep bonding/lib/modules/2.6.12.4-vs2.0/kernel/drivers/net/bonding/bonding.ko
testbox:/# cat /boot/config-2.6.12.4-vs2.0 | grep -i bonding
CONFIG_BONDING=m
We use the mii-tool (mii.o module) to monitor the interfaces for
failover... though, as most ethernet adapters use an MII (Media
Independant Interface) to autonegotiate link speeds, its pretty standard
that you'd have this.
testbox:/# cat /boot/config-2.6.12.4-vs2.0 | grep -i mii# CONFIG_MPENTIUMII is not set
# CONFIG_MPENTIUMIII is not set
CONFIG_MII=y
testbox:/# modprobe --list | grep -i mii
/lib/modules/2.4.26-2-686/kernel/drivers/net/mii.ko
Second, your going to need to install the ifenslave utility.
testbox:/# apt-get update && apt-get install ifenslave
.......... removed standard output (nothing interesting)
Theres no configuration here, so that is that. Now we are ready for
the configuration files.
Configuration Files:
There are many different variations of this, but for now... this is how I did it to get it working.
vi /etc/modutils/aliases and add/edit the following:
alias bond0 bonding
alias eth0 e100
alias eth1 e100
options bonding mode=0 miimon=100
vi /etc/modutils/actions and add/edit the following:
probeall bond0 eth0 eth1 bonding
After editing the modprobe config files you need to run the command:
testbox# update-modules
vi /etc/network/interfaces and add/edit the following:
auto bond0
iface bond0 inet static
address 10.1.100.63
netmask 255.255.255.0
hwaddress ether 00:02:B3:48:50:2C
gateway 10.1.100.1
up ifenslave bond0 eth0 eth1
down ifenslave -d bond0 eth0 eth1
You do NOT set up entries for 'eth0' or 'eth1' outside of whats listed above under the 'bond0' entry. Bond0 will now be the interface that the kernel works with. running an 'ifconfig' will show all three interface (bond0,eth0,eth1), all with the same MAC and IP addresses.
And thats basically it. Now, all you should need to do is load the 'bonding' module and stop/start networking... and the apropriate modules should load automagically:
testbox:/# modprobe bonding
testbox:/# /etc/init.d/networking stoptestbox:/# /etc/init.d/networking start
You might have to play around with this part for a bit. For me I had to manually ifconfig up the bond0 device:
testbox:/# ifconfig bond0 10.1.15.63 netmask 255.255.255.0 up
In a higher end environment, you could plug each NIC into a separate switch (staying on the same VLAN) and further improve your high availability config... and so on and so forth.
Source from : http://www.howtoforge.com/nic_bonding
星期三, 8月 15, 2007
Setup Apache
- look for /etc/httpd/conf/httpd.conf
- search for ErrorDocument
- uncomment/add the line for 404 and 403
- type in http://xxx.xxx.com for redirection
2. Disable directory browsing
- look for /etc/httpd/conf/httpd.conf
- search for FollowSymLinks
- remove index from that line and make it like " Options FollowSymLinks"
*** service httpd restart , each time after you make changes to httpd.conf file so as to make it effective immediately ***
星期二, 3月 27, 2007
Oracle Command
sqlplus USERNAME/PASSWORD@CONNECT_IDEN
After connect to db
show all // show all configuration information
select * from v$instance // show your current
select owner, table_name from all_tables
desc
星期四, 3月 22, 2007
CentOS 3.8 Server Setup
2. wget all source files, mysql+apache+php (php5 is not ok for CentOS 3.8)
3. rpm -ivh *.rpm // for mysql setup files
4. yum install perl-DBI // fullfill mysql deps
5. yum install gcc // fulfill apache install deps
6. in apache tar directory
$./configure --prefix=/usr/local/apache2
or (when you have any error related to apr...)
$./configure --enable-so --enable-mods-shared=expires,ssl,headers,http,info,rewrite --with-apr=/backup/httpd-2.2.4/srclib/apr/ --with-apr-util=/backup/httpd-2.2.4/srclib/apr-util/
$ make
$ make install
$ /usr/local/spache2/bin/apachectl start
Refer to http://httpd.apache.org/docs/2.2/install.html for more details
7. extract php source
8. yum install flex // fulfill php compile deps
9. yum install bison // fulfill php comple deps
10. yum install libxml libxml-devel libxml2-devel // fulfill php comple deps
11. ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
12. make
13. make install
14. refer to /php-4.4.6/INSTALL for the rest of configuration
After that, I have Mysql5.0 + Apache 2 + PHP 4 in my server
PHP compile options
// add graphical support
yum install libjpeg-devel
yum install libpng-devel
yum install zlib-devel
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-gd --with-zlib-dir=usr/share/doc/zlib-1.1.4
yum install libpng-devel
星期三, 3月 21, 2007
Useful Linux (CentOS) commands
yum list // show availiable package from server
yum install package-name // install package
yum localinstall package-name.rpm // try to install the rpm with deps
chkconfig --list // check list of running environment process
CentOS 3.8 PHP 4.3.2 config file location
/etc/php.ini
/etc/php.d
CentOS 3.8 PHP MbString problem
Warning: mb_internal_encoding(): Unknown encoding "big5" in /var/www/html/phpmyadmin/libraries/string.lib.php on line 41Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/phpmyadmin/libraries/string.lib.php:41) in /var/www/html/phpmyadmin/libraries/common.lib.php on line 2404Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/phpmyadmin/libraries/string.lib.php:41) in /var/www/html/phpmyadmin/libraries/common.lib.php on line 2404Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/phpmyadmin/libraries/string.lib.php:41) in /var/www/html/phpmyadmin/libraries/common.lib.php on line 2354Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/phpmyadmin/libraries/string.lib.php:41) in /var/www/html/phpmyadmin/index.php on line 101
You can edit the /var/www/html/phpmyadmin/libraries/string.lib.php line 41 to comment out that line by
change it from
mb_internal_encoding($GLOBALS['charset']);
to
// mb_internal_encoding($GLOBALS['charset']);
and then you can reload your page again and you can see that .. and then you have to setup your language to any one rather than "Chinese Traditional Big5". I choose UTF8 and then you can del the comment for line 41 and everything will works fine .. remember dont' choose Big5 after you del the comment. If not, you have to do so again.