Sunday, January 22, 2012

Cách tốt nhất cập nhật lại ngày giờ cho Centos

# yum install ntp # chkconfig ntpd on # ntpdate 0.asia.pool.ntp.org # /etc/init.d/ntpd start

Tuesday, January 17, 2012

How To Fix PHP Error Notice: Undefined variable: index

Notice: Undefined index:

Change php.ini

NOTE: you may have something different set for the error_reporting , just make sure you make the changes on the line without a semi-colon because a semi-colon at the begining of the line mean its a comment

So now change it to:

     Code:
error_reporting = E_ALL & ~E_NOTICE

Save your changes and then restart you Apache server for the changes to take affect witht his command:
     Code:
/etc/init.d/httpd restart


Thursday, January 12, 2012

Remove IP Spamhaus

Check at server
[root@dedi25 ~]# telnet mx1.mail.sg1.yahoo.com 25
Trying 124.108.116.109...
Connected to mx1.mail.sg1.yahoo.com (124.108.116.109).
Escape character is '^]'.
553 5.7.1 [BL21] Connections will not be accepted from 112.213.94.125, because the ip is in Spamhaus's list; see http://postmaster.yahoo.com/550-bl23.html
Connection closed by foreign host.
[root@dedi25 ~]# 


Remove IP Spamhaus
http://cbl.abuseat.org/lookup.cgi?ip=125.23.9.125

Check
http://www.spamhaus.org/query/bl?ip=125.23.9.125

Tuesday, January 10, 2012

Hướng dẫn cấu hình crontab not send email

[root@dedi94125 ~]# vi /etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly

01 01 * * * root /var/qmail/bin/dh_key 2>&1 > /dev/null


Chú ý: nếu muốn không send email thì MAILTO = rỗng

Cách 2:  thêm vào thông số  /dev/null 2>&1

#Before
* * * * * php /path/to/script#After
* * * * * php /path/to/script > /dev/null 2>&1
 
 

Monday, January 9, 2012

How To scp, ssh and rsync without prompting for password

Lets say you want to copy between two hosts host_src and host_dest. host_src is the host where you would run the scp, ssh or rsyn command, irrespective of the direction of the file copy!
  1. On host_src, run this command as the user that runs scp/ssh/rsync
    $ ssh-keygen -t rsa

    Generating public/private rsa key pair.
    Enter file in which to save the key (/root/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    82:c6:21:5b:9e:07:6e:6d:3b:66:47:eb:9e:ff:6a:bd root@localhost
    Chú ý:  Nếu không muốn hiện bản nhập key thì Enter passphrase bằng rỗng
    This will prompt for a passphrase. Just press the enter key. It'll then generate an identification (private key) and a public key. Do not ever share the private key with anyone! ssh-keygen shows where it saved the public key. This is by default ~/.ssh/id_rsa.pub:
    Your public key has been saved in /.ssh/id_rsa.pub
  1. Transfer the id_rsa.pub file to host_dest by either ftp, scp, rsync or any other method.
  1. On host_dest, login as the remote user which you plan to use when you run scp, ssh or rsync on host_src.
  2. Copy the contents of id_rsa.pub to ~/.ssh/authorized_keys
    $ cat id_rsa.pub >> ~/.ssh/authorized_keys
    $ chmod 700 ~/.ssh/authorized_keys
    Cần copy nội dung  id_rsa.pub ghi vào file ~/.ssh/authorized_keys
    Nếu có nhiều key thì copy vào bên dưới file  ~/.ssh/authorized_keys

    If this file does not exists, then the above command will create it. Make sure you remove permission for others to read this file. If its a public key, why prevent others from reading this file? Probably, the owner of the key has distributed it to a few trusted users and has not placed any additional security measures to check if its really a trusted user.

  1. Note that ssh by default does not allow root to log in. This has to be explicitly enabled on host_dest. This can be done by editing /etc/ssh/sshd_config and changing the option of PermitRootLogin from no to yes. Don't forget to restart sshd so that it reads the modified config file. Do this only if you want to use the root login.
Well, thats it. Now you can run scp, ssh and rsync on host_src connecting to host_dest and it won't prompt for the password. Note that this will still prompt for the password if you are running the commands on host_dest connecting to host_src. You can reverse the steps above (generate the public key on host_dest and copy it to host_src) and you have a two way setup ready!

Tuesday, January 3, 2012

Hướng dẫn install mtop cho centos 32bit

wget http://dag.wieers.com/rpm/packages/m....rf.noarch.rpm

[root@dedi94125 ~]# rpm -ivh mtop-0.6.6-1.2.el5.rf.noarch.rpm
warning: mtop-0.6.6-1.2.el5.rf.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
error: Failed dependencies:
perl(Curses) is needed by mtop-0.6.6-1.2.el5.rf.noarch


-- cần phải cài gói perl-Curses-1.28-1.el5.rf.i386.rpm
[root@dedi94125 ~]# wget http://pkgs.repoforge.org/perl-Curse...l5.rf.i386.rpm
[root@dedi94125 ~]# rpm -ivh perl-Curses-1.28-1.el5.rf.i386.rpm



[root@dedi94125 ~]# mtop --help

mtop ver 0.6.6/20120104

Copyright (C) 2002 Marc Prewitt/Chelsea Networks
mtop comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
welcome to redistribute it under certain conditions; see the COPYING file
for details.

Usage: mtop [OPTIONS]

--version Show version number and exit
--help Show this screen and exit
--host={mysql_host} Connect to the MySQL server on {mysql_host}
--dbuser={mysql_user} Connect to the MySQL server as {mysql_user}
--password={mysqluser_pw} Use {mysqluser_pw} when connecting
--seconds={refresh} Refresh the screen each {refresh} seconds
--[no]idle Display/don't display idle threads
--filter-user={regex} Filter display based on user regular expression
--filter-host={regex} Filter display based on host regular expression
--filter-db={regex} Filter display based on db regular expression
--filter-command={regex} Filter display based on command regular expression
--filter-state={regex} Filter display based on state regular expression
--filter-info={regex} Filter display based on info regular expression
--user={user} Display threads for only {user}
--manualrefresh Wait for user input between refreshes

All options can be truncated to their shortest unique abbreviation.

See 'man mtop' or 'perldoc mtop' for more information.

[root@dedi94125 ~]# mtop --dbuser=databasname

Wednesday, December 21, 2011

Setup Oracle 11g 11.0.2.1 for Solaris 10 - 64bit

setup vnc
svccfg -s application/x11/x11-server add display1
svccfg -s application/x11/x11-server:display1 addpg options application
svccfg -s application/x11/x11-server:display1 addpropvalue options/server astring: "/usr/X11/bin/Xvnc"
svccfg -s application/x11/x11-server:display1 addpropvalue options/server_args astring: '"SecurityTypes=None"'


vncserver


mount iso for Solaris
root@TT4-BCCLML1-S # lofiadm -a /u01/sol-10-u10-ga2-sparc-dvd.iso
/dev/lofi/1

mkdir /dvd_iso
root@TT4-BCCLML1-S # mount -F hsfs -o ro /dev/lofi/1 /dvd_iso


root@TT4-BCCLML1-S # cd /dvd_iso/

Use umount command to unmount image:
# umount /mnt

Now remove/free block device:
# lofiadm -d /dev/lofi/1




/usr/sbin/prtconf | grep "Memory size"

/usr/sbin/swap -l

#check  64bit
/bin/isainfo -kv

uname -r

cat /etc/release

df -k /tmp

pkginfo -i SUNWarc SUNWbtool SUNWhea SUNWlibC SUNWlibms SUNWsprot \
  SUNWtoo SUNWi1of SUNWi1cs SUNWi15cs SUNWxwfnt

#cai goi
pkgadd -d /dvd_iso/Solaris_10/Product SUNWi1cs SUNWi15cs


nếu cài oracle trước đó
more /var/opt/oracle/oraInst.loc

root@kinhnghiem # more /var/opt/oracle/oraInst.loc
inventory_loc=/u02/app/oraInventory
inst_group=oinstall


prtconf | grep Mem
Memory size: 32760 Megabytes
groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba -d /export/home/oracle oracle
mkdir /export/home/oracle
chown oracle:oinstall /export/home/oracle
passwd -r files oracle



$ id -p
uid=59008(oracle) gid=10001(dba) projid=3(default)


By default, Oracle 10 will allocate 40% of the total system physical memory to create SGA and PGA. So for 32G system memory, the shmmax for Oracle 10 will be 0.4*32G = 12.8G.

40% 13105
50% 16442
75% 24536
100% 32764


# cat /etc/project
projmod -sK "project.max-shm-memory=(privileged,10G,deny)" oracle
projmod -p 100  -c 'lptrung add' -U oracle -G dba  -K 'project.max-shm-memory=(privileged,21G,deny)' oracle

projadd -p 100  -c 'lptrung add' -U oracle -G dba  -K 'project.max-shm-memory=(privileged,21G,deny)' projoracle

usermod -K project=projoracle oracle

projects -l



mkdir -p /u01/app/oracle/product/11.2.0.2/db_1
chown -R oracle:oinstall /u01

vi .profile

TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
# Select the appropriate ORACLE_BASE
ORACLE_HOSTNAME=KINHNGHIEM-S; export ORACLE_HOSTNAME
ORACLE_UNQNAME=bcclml; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.2/db_1; export ORACLE_HOME
ORACLE_SID=bcclml; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH



solaris
the following command displays a summary of I/O activity ten times, at ten-second intervals:
sar -b 10 10

update 11.2.0.2
Fix error tcp_largest_anon_port ....

bash-3.00# ndd -set /dev/tcp tcp_largest_anon_port 65535
bash-3.00# ndd -set /dev/udp udp_smallest_anon_port 9000
bash-3.00# ndd -set /dev/udp udp_largest_anon_port 65500
bash-3.00# ndd -set /dev/tcp tcp_smallest_anon_port 9000
bash-3.00# ndd -set /dev/tcp tcp_largest_anon_port 65500

Tuesday, December 20, 2011

Map san xuống server solaris sử dụng UFS

-- Kiểm tra ổ dĩa hiện tại
root@c4is-standby-s # echo |format

AVAILABLE DISK SELECTIONS:
       0. c1t0d0
          /pci@1f,700000/scsi@2/sd@0,0
       1. c1t1d0
          /pci@1f,700000/scsi@2/sd@1,0
       2. c1t2d0
          /pci@1f,700000/scsi@2/sd@2,0
       3. c1t3d0
          /pci@1f,700000/scsi@2/sd@3,0
       4. c5t600A0B8000330D0A0000054748BF696Bd0
          /scsi_vhci/ssd@g600a0b8000330d0a0000054748bf696b
       5. c5t600A0B80004700CE0000057348BF6846d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057348bf6846
       6. c5t600A0B80004700CE0000057748BF6AD0d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057748bf6ad0
Specify disk (enter its number): Specify disk (enter its number):

-- Vào SAN tạo volumn sau đó map xuống host
--Sau khi map xuống xong kiểm tra ổ đĩa mới 

root@c4is-standby-s # echo |format

AVAILABLE DISK SELECTIONS:
       0. c1t0d0
          /pci@1f,700000/scsi@2/sd@0,0
       1. c1t1d0
          /pci@1f,700000/scsi@2/sd@1,0
       2. c1t2d0
          /pci@1f,700000/scsi@2/sd@2,0
       3. c1t3d0
          /pci@1f,700000/scsi@2/sd@3,0
       4. c5t600A0B8000330D0A0000054748BF696Bd0
          /scsi_vhci/ssd@g600a0b8000330d0a0000054748bf696b
       5. c5t600A0B80004700CE00001D8C4EF0CD9Cd0
          /scsi_vhci/ssd@g600a0b80004700ce00001d8c4ef0cd9c
       6. c5t600A0B80004700CE0000057348BF6846d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057348bf6846
       7. c5t600A0B80004700CE0000057748BF6AD0d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057748bf6ad0
Specify disk (enter its number): Specify disk (enter its number):

-- Ổ đĩa hiện tại đc map xuống là
 5. c5t600A0B80004700CE00001D8C4EF0CD9Cd0


-- Xác định lại silde của partition cần format để chọn  newfs

root@c4is-standby-s # format
Searching for disks...done

c5t600A0B80004700CE00001D8C4EF0CD9Cd0: configured with capacity of 1024.00GB


AVAILABLE DISK SELECTIONS:
       0. c1t0d0
          /pci@1f,700000/scsi@2/sd@0,0
       1. c1t1d0
          /pci@1f,700000/scsi@2/sd@1,0
       2. c1t2d0
          /pci@1f,700000/scsi@2/sd@2,0
       3. c1t3d0
          /pci@1f,700000/scsi@2/sd@3,0
       4. c5t600A0B8000330D0A0000054748BF696Bd0
          /scsi_vhci/ssd@g600a0b8000330d0a0000054748bf696b
       5. c5t600A0B80004700CE00001D8C4EF0CD9Cd0
          /scsi_vhci/ssd@g600a0b80004700ce00001d8c4ef0cd9c
       6. c5t600A0B80004700CE0000057348BF6846d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057348bf6846
       7. c5t600A0B80004700CE0000057748BF6AD0d0
          /scsi_vhci/ssd@g600a0b80004700ce0000057748bf6ad0

--- chọn ổ đĩa mới thứ 5 mới gắn vào

Specify disk (enter its number): 5
selecting c5t600A0B80004700CE00001D8C4EF0CD9Cd0
[disk formatted]
Disk not labeled.  Label it now? yes


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !     - execute , then return
        quit
format> p


PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        ! - execute , then return
        quit
partition> p
Current partition table (original):
Total disk sectors available: 2147467230 + 16384 (reserved sectors)

Part      Tag    Flag     First Sector          Size          Last Sector
  0       root    wm                34       128.00MB           262177   
  1       swap    wu            262178       128.00MB           524321   
  2 unassigned    wu                 0            0                0   
  3 unassigned    wm                 0            0                0   
  4 unassigned    wm                 0            0                0   
  5 unassigned    wm                 0            0                0   
  6        usr    wm            524322      1023.74GB           2147467229   
  8   reserved    wm        2147467230         8.00MB           2147483613   

partition> q


==> chú ý thấy vị trí thứ 6 dung lượng là 1G  => chính là s6
 

Tạo newfs

newfs /dev/rdsk/c5t600A0B80004700CE00001D8C4EF0CD9Cd0s6
 


-- Tạo một thư mục tên u04, sao đó mount vào
mount -F ufs /dev/dsk/c5t600A0B80004700CE00001D8C4EF0CD9Cd0s6 /u04

Chú ý: thay thế rdsk bằng dsk


=====================
Lệnh để clean cache device 

devfsadm -Cv

Saturday, December 17, 2011

kloxo 500 - Internal Server Error

There are still have a problem when update Kloxo to version 6.1.10 (especially from 6.1.7) with using 'auto update' or 'update home' on kloxo.

Solution, run this commands:


# for sure to using latest version for certain packages
yum update
# shell command version for update
sh /script/upcp
# cleanup process for certain settings
sh /script/cleanup
# restart some services
service xinetd restart
# fix web config to make sure using latest
sh /script/fixweb --server=all
# Better reboot after that
reboot

Friday, December 16, 2011

Reset password root MYSQL với quyền root

[root@servert1 ~]# /etc/init.d/mysqld stop

Stopping MySQL: [ OK ]

[root@servert1 ~]# mysqld_safe --skip-grant-tables &

 [1] 13694

[root@servert1 ~]# Starting mysqld daemon with databases from /var/lib/mysql

[root@servert1 ~]# mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.0.77 Source distribution

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


mysql> use mysql;

mysql> update user set password=PASSWORD("testpass") where User='root';

Query OK, 3 rows affected (0.05 sec)

Rows matched: 3 Changed: 3 Warnings: 0


mysql> flush privileges;

Query OK, 0 rows affected (0.04 sec)

mysql> quit