18 Aralık 2010 Cumartesi

Mysql yavaş çalışan sorgular

One of the most important steps in optimizing and tuning mysql is to identify the queries that are causing problems. How can we find out what queries are taking a long time to complete? How can we see what queries are slowing down the mysql server? Mysql has the answer for us and we only need to know where to look for it…
Normally from my experience if we take the most ‘expensive’ 10 queries and we optimize them properly (maybe running them more efficiently, or maybe they are just missing a simple index to perform properly), then we will immediately see the result on the overall mysql performance. Then we can iterate this process and optimize the new top 10 queries. This article shows how to identify those ‘slow’ queries that need special attention and proper optimization.
1. Activate the logging of mysql slow queries.

The first step is to make sure that the mysql server will log ‘slow’ queries and to properly configure what we are considering as a slow query.

First let’s check on the mysql server if we have slow query logging enabled:

mysqladmin var |grep log_slow_queries
| log_slow_queries | OFF |

If log_slow_queries is ON then we already have it enabled. This setting is by default disabled – meaning that if you don’t have log_slow_queries defined in the mysql server config this will be disabled.
The mysql variable long_query_time (default 1) defines what is considered as a slow query. In the default case, any query that takes more than 1 second will be considered a slow query.

Ok, now for the scope of this article we will enable the mysql slow query log. In order to do to do this in your mysql server config file (/etc/my.cnf RHEL/Centos or /etc/mysql/my.cnf on Debian, etc.) in the mysqld section we will add:

[mysqld]
long_query_time = 1
log-slow-queries = /var/log/mysql/mysql-slow.log

This configuration will log all queries that take more than 1 sec in the file /var/log/mysql/mysql-slow.log. You will probably want to define these based on your particular setup (maybe you will want the logs in a different location and/or you will consider a higher value than 1 sec to be slow query).

Once you have done the proper configurations to enable mysql to log slow queries you will have to reload the mysql service in order to activate the changes.
2. Investigate the mysql slow queries log.

After we enabled slow query logging we can look inside the log file for each slow query that was executed by the server. Various details are logged to help us understand how was the query executed:

* Time: how long it took to execute the query
* Lock: how long was a lock required
* Rows: how many rows were investigated by the query (this can help see quickly queries without indexes)
* Host: the actual host that launched the query (this can be localhost, or a different one in multiple servers setup)
* The actual mysql query.

This information allows us to see what queries need to be optimized, but on a high traffic server and with lots of slow queries this log can grow up very fast making it very difficult to find any relevant information inside it.
In this case we have two choices:

1. We increase the long_query_time and we focus on the queries that take the most time to complete, and we gradually decrease this once we solve the queries.
2. We use some sort of tool to parse the slow query log file and have it show us the most used queries.

Of course based on the particular setup we might end up using both methods.

MySQL gives us a small tool that does exactly this: mysqldumpslow. This parses and summarizes the MySQL slow query log.
From the manual page here are the options we can use:

-v verbose
-d debug
-s=WORD
what to sort by (t, at, l, al, r, ar etc)
-r reverse the sort order (largest last instead of first)
-t=NUMBER
just show the top n queries
-a don't abstract all numbers to N and strings to 'S'
-n=NUMBER
abstract numbers with at least n digits within names
-g=WORD
grep: only consider stmts that include this string
-h=WORD
hostname of db server for *-slow.log filename (can be wildcard)
-i=WORD
name of server instance (if using mysql.server startup script)
-l don't subtract lock time from total time

For example using:

mysqldumpslow -s c -t 10

we get the top 10 queries (-t 10) sorted by the number of occurrences in the log (-s c).
Now it is time to have those queries optimized. This is outside of the scope of this article but the next logical step is to run EXPLAIN on the mysql query and then, based on the particular query to take the appropriate actions to fix it.

Centos 5.5 'i php 5.2.1 e güncelleme

rpm --import http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

cd /etc/yum.repos.d
wget http://dev.centos.org/centos/5/CentOS-Testing.repo

yum --disablerepo=* --enablerepo=c5-testing update php

Centos 5.5 e yum nasıl kurulur?

Sunucuya root olarak login olduktan sonra,sırasıyla;

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/elfutils-libs-0.137-3.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/gmp-4.1.4-10.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/readline-5.1-3.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-2.4.3-27.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.8.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-python-2.6.26-2.1.2.8.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/expat-1.95.8-8.3.el5_4.2.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/sqlite-3.3.6-5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/elfutils-0.137-3.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/rpm-python-4.4.2.3-18.el5.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/m2crypto-0.16-6.el5.6.i386.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm

rpm -Uvh http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm

wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm

rpm -Uvh yum-*.rpm

yum -y update


PS: Bağlılık(depency) isteyen komutlarda ki python depency isteniyor.
komut ile beraber --nodeps parametresi kullanmak gerekiyor(muş)

Kaynak:http://wiki.openvz.org/Install_yum#CentOS_5_i386

17 Aralık 2010 Cuma

Configuring Plesk DNS

The default Plesk DNS template, located under Server/Services/DNS, is used to create the zone files for all domains which are added to your account. However, it's initial configuration is not what is normally seen for a zone file. Therefore, it is suggested to follow the steps below to modify the template.

1. The first step is to determine what the name of your primary and secondary name servers will be. Convention uses the subdomains ns1 and ns2 as the name servers. For this example, our name servers will be ns1.mydomain.com and ns2.mydomain.com.
2. Secondly, access the DNS template by selecting Server from the left frame under system, and then select DNS under services in the right frame.
3. The template that appears has 2 entries which need to be removed:
3a. The NS record: ". NS ns.."
3b. The corresponding A record: "ns.. A "
4. These fields are removed by checking the box on the entries line and select "Remove Selected". On the next screen confirm the deletion.
5. Now 2 entries for the primary and secondary name servers need to be added. This is accomplished under the "Add a DNS record" section.
5a. From the drop-down menu, select NS as the record type and click on the button.
5b. On the next screen, leave the domain name field blank and enter "ns1.mydomain.com" into the name server field, then click ok.
5c. Repeat this for the "ns2.mydomain.com" entry.
6. The final step is to specify the IPs for these subdomains.
6a. Add "mydomain.com" as a domain to your Plesk account through the Domains screen under General in the left frame.
6b. After adding "mydomain.com", click on the domain name and then select DNS from the following screen to edit the zone file.
6c. The DNS screen will look similar to the template screen.
6d. From the "Add a DNS record" section, select "A" as the record tyep adn click on "Add".
6e. Enter "ns1" in the domain name text box.
6f. Enter one of your IPs as the IP address and click "OK".
6g. Repeat for "ns2" using a different IP address.

That's it. All future domains will have the new configuration as their zone file. If you have already added domains, they can be converted to the new template by clicking on the "Default" button on the domains DNS page under "Restoring the DNS zone by the template".

You will now want to register the two domains, ns1.mydomain.com and ns2.mydomain.com, as name servers with your registrar

Qbasic

Tarihi qbasic programlama dili kurulum dosyaları için buraya tıklayınız.