create free blogs for system admins

Create yourown blogs  .  Share your knowledge with others , create your own signature in the web.

You can also upload photos , videos and much more.  We also provide sigmple Adsense integration plugin and using this you can add your Google adsense code in your blogs .

Create Your Blogs : http://hellosystemadmin.com/login/

Customise your Blogs : http://hellosystemadmin.com/support/docs/

Mysql takes 100 % CPU

I have seen that when executing a mysql query the cpu usage becomes 100 % and it takes a long time to execute the query.  I have executed the same query thorugh phpmyadmin and that time also it took a long time to execute also mysql consumes 100 % cpu .  I have done some change to my.cnf file and restarted mysql and the problem wentaway.  You can also adjust your my.cnf values as follows.

[mysqld]
max_allowed_packet = 128M
sort_buffer_size = 512M
max_connections=500
query_cache_size = 512M
query_cache_limit = 512M
query-cache-type = 2
table_cache = 80
thread_cache_size=8
key_buffer_size = 512M
read_buffer_size=64M
read_rnd_buffer_size=64M
myisam_sort_buffer_size=64M
innodb_flush_log_at_trx_commit=2
innodb_buffer_pool_size=700M
innodb_additional_mem_pool_size=20M

Once you made the changes in my.cnf do not forget to restart mysql server. Mysql can be restarted in any of the following methods

If you have installed mysql using RPM you can restart mysql using one of the following commands

service mysqld restart  OR /etc/init.d/mysqld restart

If you have installed mysql from source files you  can shutdown mysql and start it as follows

Stop Mysql : mysqladmin -uroot -p shutdown

Start msyql : /usr/local/mysql/bin/mysqld_safe –user=mysql &   (assume mysql is installed at /usr/local/mysql)

Mysql database replication

Install mysql server on both server and client machine

Settings in Server

Editi My.conf

log-bin = mysql-bin
server-id = 1
binlog-do-db=DBNAME1
binlog-do-db=DBNAME2
# Backing up Master Database

mysqldump -u root -p –routines –add-drop-table –master-data –databases DBNAME1 DBNAME2 > master.sql

musql -uroot -p

CREATE USER ‘repluser’@'%’ IDENTIFIED BY ‘password’;
GRANT PROCESS , SUPER , REPLICATION SLAVE , REPLICATION CLIENT ON * . * TO ‘repluser’@'%’ IDENTIFIED BY ‘password’ WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

grant replication slave on *.* to repluser@SLAVE_SERVER_IP_ADDRESS identified by ‘password’;

# Slave configuration

vi /etc/my.cnf

log-bin = mysql-bin
server-id = 2
master-host=MASTER SERVER IP
master-user=repluser
master-password=password;
master-connect-retry=60
replicate-do-db=DBNAME1
replicate-do-db=DBNAME2

# Copying the SQL file rom Master

scp root@master IP address : path to the sql  file

# Create Database in SLAVE
# dump database to new dbs

# execute following queries in mysql

change master to master_host=’Master IP address’;

change master to master_user=’repluser’;

change master to master_password=’Master user pass’;

change master to master_log_file=’mysql-bin.

(the log file should be same as that displayed in master when executing the command ’show master status;’
change master to MASTER_LOG_POS=98 ;  (the Numbe  should be same as that displayed in master when executing the command ’show master status;’

start slave
show slave status


Find PID of a PHP script

I have been trying to find the PID of a php site which is hosted in my apache web server. I did not know that it was very easy until in found the built in php function getmypid(). To find the process ID (PID) of a PHP script  use the following code in your php file

echo getmypid ();

IFRAME Virus injecting malicious code | Web server security

This year, there has been a large increase in the number of legitimate websites infected by a so-called “iframe” threat – a type of malicious script.

Several prominent websites have come under attack from hackers who have modified the underlying code so that malware can be distributed to unsuspecting users who visit the site. When a user visits an infected site, an invisible connection is established to a remote server, which can then attempt to install malware on the user’s computer. The intention could be to generate spam, or possibly something more sinister, such as stealing personal information e.g. bank account or credit card details. The above texts are taken from Avast news letter]

How does Iframe attack happens ?

Iframes are inserted to web sites files through FTP. Normally ,  people (developers, webmasters etc) used to save the ftp password in their FTP client programs (Cute FTP, filezilla etc). In such case, if  that system is infected with virus or any malware the saved ftp password will be taken and emailed to hackers (who created the virus or malware to get the ftp details of web sites). Once hackers get this ftp password, they have automated system to insert the Iframe to web site files thorugh their FTP program.  Once the iframes are inserted to the website, when users broswse  the infected website their system also get infected with malware or virus. If users are using a good antivirus program  they may get a warning that the server is infected.

What can i do if my system is infected ?

I did not  find any anti virus program that will detect the virus or malware. I think it is best idea to Format the system and reinstall everything than taking RISK. Also Enable Firewall in the system after installing the OS

What all security methods can be taken in order to prevent this kind of iframe attack ?

Since the Iframe attack happens thorugh FTP password our first attention should go to securing FTP server.  Instead of using normaly FTP, use SFTP and this can help us upt to an extend. Also,  the best idea is to allow FTP access from allowed IPs only. This can be done using either software or hardware firewalls. Since , hardware firewall is expensive we can think of software firewalls. For windows IIS ftp service, we can deny all ips except allowed IPs.  For linux this can be done  using Iptables (http://www.hellosystemadmin.com/restrict-ftp-access-using-iptables/). The above tasks  can be  done by an administrator only and this will not be so a fast method when FTP usrs have dynamic Ip address.  So we need to think about creating some scripts (php , VB, shell ) which can be used by all  users.  For  example in a linux server we can create some PHP script which will use Iptables command to add his ip to the firewall.  I suggest a simple algorithm to do this task

Create a mysql database  with two tables  ‘users’ and ‘rules’ . The table ‘users’ includes the customer Id and password. And the second table should include CustomerID, IPAddress and Status (You can add any other fields according to your convenience). Now we needto create a php script which will call iptables command to add the firewall rule. Follwoing is sampel rule

iptables -I INPUT -s XXX.XXX.XXX.XXX  -d 0.0.0.0-p tcp -m tcp €“dport 21 -j ACCEPT

In the above command, we can pass the IP address and Status as  php variables

Is your website compromised  ? Simply fill the form given below

Your Name (required)

Your Email (required)

Web site name (required)

Subject

Your Message


Fatal error: Call to undefined function wp_list_addonn() in /home/aneesh/public_html/wp-content/themes/Grante/sidebar.php on line 106