I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Frankie Kam -
Number of replies: 5
รูปภาพของPlugin developers

Someone help me out here. My VPS is running with 512Mb RAM and I am trying to optimize it as much as I can. So far I have installed eaccelerator (yeah!!) which seems to work fine.

Now I am trying to optimize my system's MySQL. Like all true-geeks, I jump at the slightest chance to tweak my budget VPS to squeeze out the last ounce of speed from it. Anyway....

...I went to this website (many others on the Net like it):
http://www.hightekhosting.com.au/myaccount/knowledgebase.php?action=displayarticle&id=154
where it gave the code for my.conf that optimises the SQL queries.

I proceeded to modify my VPS's (Lunix) /etc/my.cnf.

The result is that when I login to Plesk, I get this message:

ERROR: PleskMainDBException
MySQL query failed: Unknown table engine 'InnoDB'

0: common_func.php3:155
db_query(string 'select param, val from misc')
1: common_func.php3:585
get_param(string 'mysql41_compatible')
2: common_func.php3:482
db_set_names()
3: common_func.php3:461
db_connect_real(string 'localhost', string 'admin', string '**********', string 'psa')
4: common_func.php3:441
db_connect()
5: auth.php3:121

The good news is that I had earlier (wisely of course) backedup the my.cnf file. So by restoring the original file, and by restarting my VPS container, my Plesk will work fine. I've done it. So what's my problem then? By restoring my original my.cnf file, I'm back to square one. But I want to OPTIMIZE my MySQL and the link above says it's a tried-and-tested code to optimize MySQL. But when I try it, my Plesk doesn't work. I want to have my Plesk work (can login) and I want to ENJOY the benefits of the optimizing code for my MySQL. In other words, I want to have my cake and eat it too. Heh.

What am I doing wrong? If what I am trying to do, doesn't work for me, can someone else suggest a way for me to optimize my MySQL databases so that my Moodle runs faster?

Here's my original my.cnf code (in magenta):

[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0

#skip-bdb

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-bdb

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2

AND HERE'S THE SUGGESTED MY.CNF CODE FROM
http://www.hightekhosting.com.au/myaccount/knowledgebase.php?action=displayarticle&id=154
(in blue text)

my.cnf configuration for server with 512Mb Ram

For servers with 512Mb of Ram (including VPS), this my.cnf configuration is ready-to-go.

Simply replace your /etc/my.cnf file with this configuration (ensure you backup existing my.cnf first!!)

 

[mysqld]
#skip-name-resolve
safe-show-database
#old_passwords
back_log = 50
skip-innodb
max_connections = 650
key_buffer_size = 144M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 4000
thread_cache_size = 512
wait_timeout = 20
connect_timeout = 10
tmp_table_size = 64M
max_heap_table_size = 64M
max_allowed_packet = 64M
net_buffer_length = 16384
max_connect_errors = 100000
thread_concurrency = 8
concurrent_insert = 2
table_lock_wait_timeout = 30
read_rnd_buffer_size = 786432
bulk_insert_buffer_size = 8M
query_cache_limit = 2M
query_cache_size = 48M
query_cache_type = 1
query_prealloc_size = 262144
query_alloc_block_size = 65536
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
default-storage-engine = MyISAM
max_write_lock_count = 4

[mysqld_safe]
nice = -10
open_files_limit = 8192

[mysqldump]
quick
max_allowed_packet = 16M

[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

These are tried and tested configurations used by Hightek Hosting in many VPS and Dedicated servers.

NOTE: These configurations MAY NOT BE SUITABLE for your application. Hightek Hosting cannot be held responsible for any damage, loss of date, time or use of service by using the above configuration

การประเมินโดยเฉลี่ย: -
In reply to Frankie Kam

Re: I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Greg Lund-Chaix -

You've disabled InnoDB with the "skip-innodb" entry in your my.cnf.  Since you apparently have InnoDB tables, MySQL is throwing errors.  InnoDB is a good thing, you shouldn't be disabling it.  Remove the "skip-innodb" and I bet it'll work.

-Greg

การประเมินโดยเฉลี่ย: -
In reply to Greg Lund-Chaix

Re: I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Frankie Kam -
รูปภาพของPlugin developers

Greg, you are 110% CORRECT!

I removed that one line and now no more problem with Plesk login. Wohooo!!

Here, have yourself a virtual extra 4Gigabytes for your server.

Frankie Kam

การประเมินโดยเฉลี่ย: -
In reply to Frankie Kam

Re: I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Alex Atkinson -

Please, please help, anyone?

I am having the same issue with my sql not running meaning that I cannot access my plesk control panel, therefore, I cannot develop my site!

I have viewed the post but I cannot find the my.cnf file anywhere?

I have accessed both the Parallells and Joomla forums to try and find a way a simple layperson like me can get the Plesk control panel working again.

I have included the screenshots below for further detail!

I was advised to the following:

IF mysql isnot running do this.

▼before work
-bash-3.2# ls
horde ib_logfile0 ib_logfile1 ibdata1 mysql phpmyadmin_VKw7zAcDcaVN psa taikai53
-bash-3.2#
-bash-3.2#

▼work
-bash-3.2# mv ib_logfile1 ib_logfile1.bak
-bash-3.2# mv ib_logfile0 ib_logfile0.bak
-bash-3.2#
-bash-3.2# /etc/init.d/mysqld start
Starting mysqld: [ OK ]
-bash-3.2#
-bash-3.2#

▼after work
-bash-3.2# ls
horde ib_logfile0.bak ib_logfile1.bak mysql phpmyadmin_VKw7zAcDcaVN taikai53
ib_logfile0 ib_logfile1 ibdata1 mysql.sock psa
-bash-3.2#

And Change your my.cnf like below you will not get error of InnoDB
-bash-3.1# cat /etc/my.cnf
[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

skip-bdb

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2
[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip-bdb

set-variable = innodb_buffer_pool_size=2M
set-variable = innodb_additional_mem_pool_size=500K
set-variable = innodb_log_buffer_size=500K
set-variable = innodb_thread_concurrency=2
-bash-3.1#

I am definitely not a php programmer and would appreciate any direction and or guidance.

 

 

 

 

การประเมินโดยเฉลี่ย: -
In reply to Alex Atkinson

Re: I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Frankie Kam -
รูปภาพของPlugin developers

Hi Alex.

Okay I know how it feels to have your Moodle site not function.
I feel for you man. Anyway, on to the solution....if I may be of any
assistance at this point of your crisis.

The my.cnf file on Centos is located inside the /etc folder.

Did you backit up before doing any drastic changes?

Do you have access to SSH (Linux command prompt) where you can
log into the system as root user and type the command:

/etc/init.d/mysqld restart

to attempt to restart your MySQL system?

From your screenshot, what happens if you tick the checkboxes and click
the "Restart Service" icons?

Lastly, I reduced your images horizontal-wise so that the full details
can be seen by the various Moodle sages who frequent this discussion
forum. Any kind soul out there who can help Alex out?

Keep me posted.

Frankie Kam

การประเมินโดยเฉลี่ย: -
In reply to Frankie Kam

Re: I modified /etc/my.cnf to optimize my SQL Queries - led to Plesk problem. So how can I optimize MySQL safely?

โดย Alex Atkinson -

Hi Frankie,

Many thanks for your reply, when I click on start for any of the services that are showing a red cross (stopped) the text comes up saying that the service has started but the red cross showing stopped is still displayed!

I hope this makes sense, I have spoken to technical support at my hosting provider, webfusion, within the hour it was fixed. However, within the hour after it being fixed and me not doing ANY work on it, it was back to how it was before!!!

Nightmare.

It is great knowing that other people are rooting for me getting it fixed, many thanks.

การประเมินโดยเฉลี่ย: -