Showing posts with label News. Show all posts
Showing posts with label News. Show all posts

Monday, May 2, 2011

Restore backup mysql to a remote mysql server.

Restore backup mysql to a remote mysql server.

mysql -unameuser -p --default-character-set=utf8 < dbname.sql --host=yourIPmysqlServer

* Please take note you must granted the user before restore the DB.

Thursday, April 7, 2011

SNMPD on freebsd

I'm using FreeBSD 8.2 and here's the basics for getting snmp working:

cd /usr/ports/net-mgmnt/net-snmp
make
make install
make clean

edit /etc/rc.conf
add snmpd_enable="YES"

cd /usr/local/share/snmp
edit snmpd.conf (you may have to create it)
add the following
syslocation home (replace home with whatever you'd like)
syscontact me@here.com (put in your e-mail or whatever)
rocommunity private (replace with whatever read only name you'd like)
rwcommunity public (again, change this to whatever you'd like)
master yes
now save and exit

cd /usr/local/etc/rc.d
./snmpd.sh start

This will get you up and running with a very basic snmp configuration. There's a handy utility called 'snmpconf' that can be run to help you generate the snmp.conf (optional) and snmpd.conf files. This will give you more options and help tighten up security.

at this point you should be able to snmpwalk your host
snmpwalk -v1 -c public 127.0.0.1

Thursday, November 4, 2010

How To Monitor Mysql using Zenoss

On the Zenoss server ensure your device has the Mysql zenpack

On the mysql server you plan to monitor do the following;

Add a user to Mysql so that zenoss can connect.

mysql -u root -p

grant ALL PRIVILEGES ON *.* TO ‘zenoss’@'yourzenossdomain’ IDENTIFIED BY ‘yourpassword’;

FLUSH PRIVILEGES;

Don’t forget to open port 3306 on the firewall of the Mysql server if necessary.

On the Zenoss server add the mysql user and password to zproperties of the device.

If Mysql version <5> 5

You can test that your monitored server can authenticate from your Zenoss server by

mysql -u zenoss -p -h yourmonitoredserverip


credit to http://www.how-to-linux.com

Friday, October 29, 2010

Downgrade PHP on ubuntu Server

go to /usr/local/sbin

create this script

nano downgrade.sh

enter

#!/bin/bash
# by Ruben Barkow (rubo77) http://www.entikey.z11.de/

# Originally Posted by Bachstelze http://ubuntuforums.org/showthread.php?p=9080474#post9080474
# OK, here's how to do the Apt magic to get PHP packages from the karmic repositories:

echo "Am I root? "
if [ "$(whoami &2>/dev/null)" != "root" ] && [ "$(id -un &2>/dev/null)" != "root" ] ; then
echo " NO!

Error: You must be root to run this script.
Enter
sudo su
"
exit 1
fi
echo " OK";


# finish all apt-problems:
apt-get -f install

# remove all your existing PHP packages. You can list them with dpkg -l| grep php
PHPLIST=$(for i in $(dpkg -l | grep php|awk '{ print $2 }' ); do echo $i; done)
echo these pachets will be removed: $PHPLIST
# you need not to purge, if you have upgraded from karmic:
aptitude remove $PHPLIST
# on a fresh install, you need purge:
# aptitude remove --purge $PHPLIST


#Create a file each in /etc/apt/preferences.d like this (call it for example /etc/apt/preferences.d/php5_2);
#
#Package: php5
#Pin: release a=karmic
#Pin-Priority: 991
#
#The big problem is that wildcards don't work, so you will need one such stanza for each PHP package you want to pull from karmic:

echo ''>/etc/apt/preferences.d/php5_2
for i in $PHPLIST ; do echo "Package: $i
Pin: release a=karmic
Pin-Priority: 991
">>/etc/apt/preferences.d/php5_2; done

# duplicate your existing sources.list replacing lucid with karmic and save it in sources.list.d:
#sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

# better exactly only the needed sources, cause otherwise you can get a cachsize problem:
echo "# needed sources vor php5.2:
deb http://de.archive.ubuntu.com/ubuntu/ karmic main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic main restricted

deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates main restricted

deb http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic universe
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates universe

deb http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic multiverse
deb http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ karmic-updates multiverse

deb http://security.ubuntu.com/ubuntu karmic-security main restricted
deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted
deb http://security.ubuntu.com/ubuntu karmic-security universe
deb-src http://security.ubuntu.com/ubuntu karmic-security universe
deb http://security.ubuntu.com/ubuntu karmic-security multiverse
deb-src http://security.ubuntu.com/ubuntu karmic-security multiverse
" >> /etc/apt/sources.list.d/karmic.list

aptitude update

apache2ctl restart

echo install new from karmic:
aptitude -t karmic install $PHPLIST

# at the end retry the modul libapache2-mod-php5 in case it didn't work the first time:
aptitude -t karmic install libapache2-mod-php5

apache2ctl restart

chmod +x /usr/local/sbin/downgrade.sh
run the script
sh downgrade/sh

wait until it finish
now you done

Tuesday, August 31, 2010

APR-1 Apache upgrade problem

I face a problem when i want to upgrade apache form 2.2.14 to 2.2.16.
When the upgrade is running the running stop at apr-1
than this step save my life.

It wasn't clear to me, but, in the end I uninstalled apr1, and then let the 'apache install' reinstall it. Here's the sequence that worked for me

pkgdb -F;portsclean -CDD;portsnap fetch update
cd /usr/ports/www/apache22
make deinstall clean
portupgrade -f -o devel/apr1 devel/apr
cd /usr/ports/devel/apr1
make deinstall clean
cd /usr/ports/www/apache22
make install clean

Taken from http://forums.freebsd.org/archive/index.php/t-14338.html

Thursday, August 19, 2010

Portupgrade

I learn something new from my sifoo

try to run portupgrade :

portupgrade /var/db/pkg/namepackage

make fetch-recursive-list

Thursday, July 22, 2010

Mysql Replication

Follow this step to create / install a replication DB for mysql

http://www.howtoforge.com/mysql_database_replication

if uo have an error after / fini9sh installation using thie replication try this :

error 1 =

>LOAD DATA FROM MASTER;
Query OK, 0 rows affected, 1 warning (0.12 sec)
>

try to run this :

mysql> GRANT RELOAD on *.* to repl@'%' identified by 'your_password';
OR
mysql> GRANT SUPER on *.* to repl@'%' identified by 'your_password';



Reference : http://www.linuxismybff.com/howto/mysql/mysql-basic-replication-setup/

if you still have this warning error try to run this :

mysql -u root -p
Enter password:
SLAVE STOP;

CHANGE MASTER TO MASTER_HOST='192.168.0.100', MASTER_USER='slave_user', MASTER_PASSWORD='
', MASTER_LOG_FILE='mysql-bin.006', MASTER_LOG_POS=183;

START SLAVE;
quit;

Monday, June 28, 2010

Install SNMPD on Ubuntu

1.Installation

root@ibsen:~# sudo apt-get install snmpd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libmpich1.0gf libdc1394-22 genisoimage linux-headers-2.6.27-7 libgfortran2 dvd+rw-tools linux-headers-2.6.27-7-generic libcarp-clan-perl libxml-xql-perl libparse-yapp-perl
rdate python-xml localechooser-data gcc-4.2-base libimage-size-perl libdebconfclient0 libvisual-0.4-0 libmyth-python perlmagick libvisual-0.4-plugins libavdevice52
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libperl5.10 libsensors3 libsnmp-base libsnmp15
Suggested packages:
lm-sensors
The following NEW packages will be installed:
libperl5.10 libsensors3 libsnmp-base libsnmp15 snmpd
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 2463kB of archives.
After this operation, 7987kB of additional disk space will be used.
Do you want to continue [Y/n]?

answer y

2. Configuration

Move existing /etc/snmp/snmpd.conf configuration file to /etc/snmp/snmpd.conf.org

mv /etc/snmp/snmpd.conf  /etc/snmp/snmpd.conf.org

Create a new /etc/snmp/snmpd.conf file:

rocommunity  public
syslocation "PDC, Peters DataCenter"
syscontact peter@it-slav.net

Make snmpd use the newly created file and make it listen to all interfaces:

Edit /etc/default/snmpd

Change from:

# snmpd options (use syslog, close stdin/out/err).
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

To:

# snmpd options (use syslog, close stdin/out/err).
#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

and restart snmpd

/etc/init.d/snmpd restart


Credit to http://www.it-slav.net/blogs/2009/02/05/install-and-configure-snmp-on-ubuntu/

Wednesday, June 23, 2010

Change usr directory to other HDD / Partition

to change the usr directory in freebsd (i already make it)
add new hdd to your server, format it. let say i give the new patition is /usr2
after finish format

cd /usr2
dump 0af - /usr | restore rf -

After the dump completed, edited /etc/fstab.
Delete the line with /usr in /etc/fstab.
Updated the line with /usr2, changed /usr2 for /usr. (inside fstab)
Then rebooted. Finally the system started with a new /usr filesystem.

Done!

Credit to BSD Forum!

reset your mysql root password

Stop mysql dulu

#/usl/local/etc/rc.d/mysql-server stop.

#mysqld_safe --skip-grant-tables

than open new shell and go to the mysql-server

#mysql --user=root mysql

now you enter the mysql server and run this command

update user set Password=PASSWORD('new-password') where user='root';
flush privileges;
exit;

start the server

done

Tuesday, June 15, 2010

make symbolic link on Unix

# ln -s /usr/home /home or ln -s /data/moodle2/ moodle2

Sunday, June 13, 2010

How to Lock / Unlock User in ubuntu

For Locking User from command Line

$ sudo usermod -L waxs This will Lock user account named waxs

For Locking User from command Line

$ sudo usermod -U waxs This will UnLock user account named waxs

Thursday, June 3, 2010

list all installed application on ubuntu

list all installed application on ubuntu

dpkg --get-selections

Tuesday, June 1, 2010

Centos - Adduser

You can also do this from the command line, below are the equivalent commands. You need to have root level access to use the commands below.
  • usr/sbin/useradd [options] login_name
    creates a new user
  • usr/sbin/usermod [options] login_name
    modifies a user’s attributes
  • usr/sbin/userdel [options] login_name
    deletes the specified user. Use the -r option to automatically remove the user’s home directory and mail spool.
  • usr/bin/passwd login_name
    sets the password for the specified user
  • usr/sbin/groupadd [options] group_name
    creates a new group
  • usr/sbin/groupmod [options] group_name
    modifies a group’s attributes
  • usr/sbin/groupdel group_name
    deletes the specified group

Sunday, May 23, 2010

Restore compressed backup files (MYSQL)

the commandline is :

gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]

** if you dump file bz2 you can use bunzip2

Thursday, May 20, 2010

Script to rename multiple table in MySQL

Baru-baru ni aku faced problem untuk rename table prefix secara pukal...kat database tu ada 186 tables...
kalau nak tukar satu-satu...pergghh...memang lebam...setelah google punya google...aku jumpa solution ni...tapi kena pakai ruby script dan tukar ke sql statement..tapi kalau korang nak pakai convert ke php pun x de hal...guna concept yg sama jek...

Ikut ni :


  1. masuk mysql...pastu show tables;
  2. copy semua tables yg korang nak rename tu...
  3. paste kat dlm script ni (dlm cth ni aku bagi nama file ni batch_rename.sh ) :

    OLD_PREFIX = "mdl"
    NEW_PREFIX = "mdlsirap"
    data=<<-EOD | mdl_assignment | | mdl_assignment_submissions | | mdl_backup_config | | mdl_backup_courses | | mdl_backup_files | | mdl_backup_ids | | mdl_backup_log | | mdl_block | | mdl_block_instance |

    | mdl_block_pinned |

    EOD
    tables = []
    data.each_line do |line|
    if line=~/(#{OLD_PREFIX}\w+)/
    puts "RENAME TABLE #{$1} TO #{NEW_PREFIX}#{$1};"
    end
    end


  4. Pastu runkan script ni pakai ruby punya command-line (aku assume korang dah install ruby) :
    #ruby batch_rename.sh
  5. Dia akan kluar output :
    RENAME TABLE mdl_assignment TO mdlsirap_assignment;
    RENAME TABLE mdl_assignment_submissions TO mdlsirap_assignment_submissions;
    RENAME TABLE mdl_backup_config TO mdlsirap_backup_config;
    RENAME TABLE mdl_backup_courses TO mdlsirap_backup_courses;
    RENAME TABLE mdl_backup_files TO mdlsirap_backup_files;
    RENAME TABLE mdl_backup_ids TO mdlsirap_backup_ids;
    RENAME TABLE mdl_backup_log TO mdlsirap_backup_log;
    RENAME TABLE mdl_block TO mdlsirap_block;
    RENAME TABLE mdl_block_instance TO mdlsirap_block_instance;
    RENAME TABLE mdl_block_pinned TO mdlsirap_block_pinned;
  6. just masukan sql statement ni dlm satu file lain...tapi kalau nak senang...buat step no. 4 tu camni :
    #ruby batch_rename.sh > a.sql
  7. Runkan sql file tu guna mysql...:
    #mysql namadatabase <>
  8. Selesai....
reference :
http://zerokspot.com/weblog/e/676/

Wednesday, May 19, 2010

Repair table MYSQL

Today i face 1 problem when i want mysqldump my D. my error is

Incorrect key file for table 'mdl_block_instance'; try to repair it

This command to help you to auto-repair your table on mysql

mysqlcheck -uusername -p --auto-repair namedatabase

Tuesday, May 11, 2010

Netcat Tar

This is suitable if you don't have enough space on the source machine.

On sender :

tar -czf - directory-name | nc -l 3333

on receiver :

nc sender-ip-address 3333 > mybackup.tar.gz


Courtesy : Sifoo Zaman.

Change Login Directory (FreeBSD)

today i learn something.

How to change directory when login.

Login as root
setenv EDITOR ee (i need this because i don't know how to use VI in BSD)
type vipw
edit the directory at user you want to edit
save & exit

DONE

Thursday, May 6, 2010

Hidden Apache directory listing

If you are on an RPM installation of Apache (which i dont really recommend) you will find the apache configuration file probably here:

/etc/httpd/conf/httpd.conf

If you are using apache from the source tar balls ( like real men ) probably you will find the configuration file here:

/usr/local/apache/conf/httpd.conf

Using an editor like vi , edit the httpd.conf file and scroll until you find a line like this:

Options All Indexes FollowSymLinks MultiViews

To disable directory browsing carefully remove the line that says: Indexes and leave the line like this:

Options All FollowSymLinks MultiViews

Restart your apache webserver and thats it

reference http://www.felipecruz.com/blog_disable-directory-listing-browsing-apache.php