Arkiv

Inlägg taggade ‘linux’

Optimera MySQL

december 23rd, 2009 admin Inga kommentarer

Tänkte tipsa om ännu ett verktyg för att optimera mysql och hålla ordning på allt, och det är tuning-primer.sh

Du kan ladda hem scriptet här:

http://www.day32.com/MySQL/tuning-primer.sh

Här nedan kan du se ett exempel på resultatet från tuning-primer.sh:

— MYSQL PERFORMANCE TUNING PRIMER –
– By: Matthew Montgomery -

MySQL Version 5.0.51a-24+lenny2-log i486

Uptime = 0 days 0 hrs 0 min 14 sec
Avg. qps = 73
Total Questions = 1028
Threads Connected = 2

Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations

To find out more information on how each of these
runtime variables effects performance visit:

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL’s Enterprise Monitoring and Advisory Service

SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 2 sec.
You have 0 out of 1124 that take longer than 2 sec. to complete
Your long_query_time seems to be fine

BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 8
Current threads_cached = 1
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 125
Current threads_connected = 1
Historic max_used_connections = 2
The number of used connections is 1% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See ”MEMORY USAGE” section to make sure you are not over-allocating

No InnoDB Support Enabled!

MEMORY USAGE
Max Memory Ever Allocated : 71 M
Configured Max Per-thread Buffers : 328 M
Configured Max Global Buffers : 66 M
Configured Max Memory Limit : 394 M
Physical Memory : 1011 M
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 14 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 13
Key buffer free ratio = 87 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 40 M
Current query_cache_used = 388 K
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = .94 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won’t cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 132.00 K
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly

OPEN FILES LIMIT
Current open_files_limit = 4247 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine

TABLE CACHE
Current table_cache value = 2056 tables
You have a total of 673 tables
You have 673 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 16 M
Current tmp_table_size = 32 M
Of 208 temp tables, 16% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 7 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 0 : 2056
Your table locking seems to be fine

Categories: GSOC Taggar: , , , , , , ,

Uppdatera wordpress plugins automatiskt

september 23rd, 2009 admin Inga kommentarer

Ett litet shell script som är bra om man har många plugins, körs fördelaktigt i crontab en gång om dan eller liknande:

#!/bin/sh

#Uppdatera plugins

#skapa tempmiljö
mkdir /tmp/arf
cd /tmp/arf

#hämta alla plugins
wget -q http://downloads.wordpress.org/plugin/link-log-matcher.zip
wget -q http://downloads.wordpress.org/plugin/wordpress-popular-posts.zip
wget -q http://downloads.wordpress.org/plugin/sociable.zip
wget -q http://downloads.wordpress.org/plugin/google-sitemap-generator.zip
wget -q http://downloads.wordpress.org/plugin/gd-star-rating.zip
wget -q http://downloads.wordpress.org/plugin/contact-form-7.zip
wget -q http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip
wget -q http://downloads.wordpress.org/plugin/akismet.zip
wget -q http://downloads.wordpress.org/plugin/all-in-one-adsense-and-ypn.zip
wget -q http://downloads.wordpress.org/plugin/google-news.zip
wget -q http://downloads.wordpress.org/plugin/another-wordpress-classifieds-plugin.zip
wget -q http://downloads.wordpress.org/plugin/contextual-related-posts.zip

#unzippa allt och ta bort zippat skit
find . -name ‘*.zip’ -exec unzip {} \;
rm -rf /tmp/arf/*.zip

#börja med att rensa
rm -rf /var/www/sites/*/wp-content/plugins/*.zip
rm -rf /var/www/sites/*/wp-content/plugins/hello.php
rm -rf /var/www/sites/*/readme.html
rm -rf /var/www/sites/*/license.txt

#uppdatera

cp -R /tmp/arf/* /var/www/sites/xxx/wp-content/plugins/
cp -R /tmp/arf/* /var/www/sites/xxx/wp-content/plugins/

echo ”Klar, rensar upp lite…”
#ta bort temp miljön
rm -rf /tmp/arf
echo ”ciaoo…”

WordPress 2.8.4

augusti 18th, 2009 admin Inga kommentarer

I samband med förra inlägget angående buggen i WordPress så har nu en officiell fix släppts.

WordPress 2.8.4 är släppt då ytterligare ett sårbarhet har påträffats. Detta är en sårbarhet som angripare kan använda för att kringgå säkerhetskontrollen vid återställning av lösenord genom att använda en specialanpassad URL. Resultatet blir att den första användaren som inte har en nyckel i databasen (vanligtvis användaren admin) får sitt lösenord återställt. Angriparen får inte tillgång till din installation men kan nollställa ditt lösenord om och om igen.

Ladda ner WordPress 2.8.4 »
Ladda ner Svenska WordPress 2.8.4 »

Categories: GSOC, Internet Taggar: , , , ,

Installera debian med usb sticka

juli 7th, 2009 admin Inga kommentarer

För att enkelt installera debian (Eller valfri annan linux distribution) med hjälp av en usb sticka följ stegen nedan:

1. Ladda hem nödvändiga filer
DD
boot.img.gz
debian-502-i386-businesscard.iso

2. Extrahera boot.img ur boot.img.gz

3. Kör ”dd bs=1M if=boot.img of=\\.\e:”

4. Kopiera över debian-502-i386-businesscard.iso till E: eller vilken enhet din usb-sticka har.

Resultat:
H:\>dd bs=1M if=boot.img of=\\.\e:
rawwrite dd for windows version 0.5.
Written by John Newbigin
This program is covered by the GPL. See copying.txt for details
239+0 records in
239+0 records out

H:\>

Nu är det bara att boota på din usb sticka om du har konfigurerat bios för detta.

Categories: GSOC Taggar: , , ,

Starta om linux out of memory

juli 3rd, 2009 admin Inga kommentarer

Om din burk krashar med OOM, alltså out-of-memory så kan du lägga till detta i /etc/sysctl.conf för att den ska panica vid out of memory och därmed starta om:

vm.panic_on_oom=1

Sen måste denna rad också finnas som jag har skrivit om förut för att den skall starta om:

kernel.panic=10

Categories: GSOC Taggar: , ,

MySQL ta bort alla likadana poster

juni 23rd, 2009 admin Inga kommentarer

För att enkelt ta bort likadana poster i MySQL följ guiden nedan:

mysql> use XXX;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> create table ny_posts AS select * from posts where 1 group by post_title;
Query OK, 1674 rows affected (0.11 sec)
Records: 1674 Duplicates: 0 Warnings: 0

mysql> drop table posts;
Query OK, 0 rows affected (0.01 sec)

mysql> rename table ny_posts to posts;
Query OK, 0 rows affected (0.00 sec)

mysql>

Categories: GSOC, Webb Taggar: , ,

Starta om linux på natten

juni 17th, 2009 admin Inga kommentarer

Jag har lite diffusa problem med minnesanvändningen av min VPS just nu, och en temporär(!) lösning kan vara att starta om servern en gång mitt i natten, det har löst det tillfälligt för mig, medans jag optimerar apache & mysql så får det vara så här.

Logga in som root och kör ‘crontab -e’ och lägg sedan in detta för att starta om en gÃ¥ng varje natt klockan 04:00, all output som kan tänkas komma frÃ¥n den kastas bort.

0 4 * * * shutdown -r now >/dev/null

Åter igen så vill jag poängtera att detta endast är en temporär lösning!

Categories: GSOC Taggar: , , , , ,

Starta om linux vid kernel panic

juni 17th, 2009 admin Inga kommentarer

För att starta om din linux burk vid kernel panics så skriv in följande i botten på din /etc/sysctl.conf fil:

kernel.panic = 20

Då kommer den starta om efter 20 sekunder då den fått en kernel panic.

Notera dock att det kan vara bra att använda swatch eller något för att läsa loggar om man gör så här, men har man inte tillgång till servern 24/7 så kan det vara behändigt att den startar om själv.

Categories: GSOC Taggar: , , ,

Backup mysql html

juni 16th, 2009 admin Inga kommentarer

Ett litet script som tar backup på dina databaser samt html filer, och komprimerar dom efteråt för enkel förvaring.

#!/bin/sh
#backup 0.1 gsoc
#dumps databases and all html
mkdir /root/tools/backups
cd /root/tools/backups
#Databas
mysqldump –all-databases -p | bzip2 -c > backup-`date +”%b_%d_%Y”`.sql.bz2
#HTML
tar –create –bzip2 –file=backup-`date +”%b_%d_%Y”`.tar.bz2 /var/www/sites

Categories: GSOC, Webb Taggar: , , , ,

WordPress visar endast blanka sidor?

juni 9th, 2009 admin Inga kommentarer

Flytta alla plugins till en annan mapp och lägg tillbaka dom en och en tills du vet vilken plugin det är som orsakar skiten.

För just mig var det wp-super-cache som ställde till det, så börja där.

Categories: GSOC, Webb Taggar: , , ,