Surprisingly I couldn't find a single tutorial for beginner about this script so it's gonna be an ultimate beginner question.
What I want to do :
I want to run the mysqltuner script to get information about the configuration of a server. I need a diagnosis as I encounter a few problems with this server and this script seems to be an reliable way to have one.
What I have :
mysqltuner.pl
the ftp access to the server
the phpmyadmin access
Information about the server :
Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8o
Version MySQL: 5.0.44
And that's it. I have no idea how to run it. I feel like somehow I should upload it on the server (ftp) and they run it using.. something, but I don't have the knowledge to make use of the information given on the website ( http://mysqltuner.com/ )
Instruction that makes no sense to me:
(from mysqltuner.com)
The simplest and shortest method is:
wget mysqltuner.pl
perl mysqltuner.pl
Of course, you can add the execute bit (chmod +x mysqltuner.pl) so you can execute it without calling perl directly.
Question :
With the information I have access to, how to run mysqltuner on this server?
Thanks in advance !
You need a remote shell or physical access to the server. The ftp user and phpmyadmin isn't useful. The script seems to use only perl but not php whatsoever! Install perl when it's asked.
Related
So once a week or a month we do an update to many server machines.
Sometimes a Git pull is enough, some times an SVN update, sometimes there are changes to the database. Or a combination of those. Also there is this project that has many little servers that have a very simplified version of our system and very unreliable internet. Sometimes it might be done from one of the servers, sometimes from the local working computers.
I would like to do our work a bit easier by going through all our servers and doing the appropriate actions. I have found a couple of useful Perl packages: Net::SSH::Perl and Net::SSH::Expect;
The Net::SSH::Perl fails me.
Also I have not found out how to use its cmd command in succession. For example:
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user, $pass);
my($stdout, $stderr, $exit) = $ssh->cmd('cd web/scripts && ls -la ');
warn Dumper $stdout;
my($stdout, $stderr, $exit) = $ssh->cmd('ls -la');
warn Dumper $stdout;
The 2 ls -la commands return different results. As far as I can understand (and is explained in the documentation) the ssh executes the command and then exits. It is said that I could use SSH 2 version of the SSH protocol (or something like it) and should not have this problem, but it persists (or I don't understand how to use it).
Also if a password is asked of me (for example if I run mysql -u user -p) I am unable to provide it. I've tried it with the $ssh->cmd($cmd, [ $stdin ]) , second option but to no result. The mysql is just an example. I might wish to add an IP to /etc/hosts and be prompted for su password or svn update a file and be asked for my SVN password. I know that most of those processes can be configured to not ask for passwords but we want them to ask for password.
The $ssh->shell option seems like would do the trick but when I do something like this:
$ssh->shell();`ls -la`;
the backslashed command doesn't go to the ssh-shell. Actually I have no idea where it goes or if does anything.
The Net::SSH::Expect fails me when there is a bad internet connection.
For MySQL purposes I have created a Perl script that makes connections with each different host and does the changes I want. But it would be great if I could make it all in one script.
I would be very grateful to gain some more understanding on this topic.
This is what Ansible is made for. It uses SSH to communicate to multiple hosts, and provides a decent variable scoping system and flow control for applying various tasks to various hosts.
You can build your own configuration management with perl, but ansible with raw commands (which don't require python on the remote system) or more full fledged modules (which do) is already implemented and takes the same approach. Do yourself a favor- don't reinvent this wheel.
Ansible is far from perfect, but it covers your use case very well.
I personally run it from a docker container because python's package installation story is almost as bad as Perl's :P
On a pure perl basis you also have Rex, see rexify Web site
Which is a kind of Ansible, it got ssh, parallel job and plenty of features but more perly.
OK, it's simpler than Ansible, but it worth a try.
On my shared webhost, I have very limited ssh access (only via imscp instantSSH plugin). I want to set up a script to download my whole mysql database as an sql file, but I cant figure it out.
I cant use mysqldump so I tried the mysql command, which is available, but it isn working.
I have to specify username, password, host and database, and my password contains special characters.
Anyone can help me?
If your shared host allow mysql remote connections then you can use any MySQL software to connect to the database and then extract whatever information you need. Tools like these are: HeidiSQL, NavicatGui etc.
Another way would be the one suggested by Akshay Khale.
A 3rd one would be to use phpMyAdmin (most shared web hosting have this installed by default).
A 4th one would to create a simple php script that runs mysqldump locally, saves the .sql dump file either locally on your shared hosting or remotely via FTP/SFTP or any other protocal. Also the same script can email you that file (inline or as an attachment to the email). This kind of automation can be configured using a cron job.
There are multiple ways to achieve this. It all depends on which one suits you best.
As the author of the InstantSSH plugin for i-MSCP, I can say you that you should ask your HPs to make the mysqldump command available from your chrooted shell. The host administrator can add any command to the chroot by editing the InstantSSH plugin configuration file.
I have a SQL script which selects data from DB and stores it to files. I am unable to create a directory to store these files.
I have shell script that loads the SQL file. Shell and the SQL are on separate server than MySQL db. I would prefer to create this directory using SQL as I want to avoid ssh.
Any suggestions? Surprisingly I couldn't find anything on Google.
I will assume that you're using mysql, according to your tags. You could do it with a Microsoft SQL Server or Oracle database but unfortunately, at the moment, there is no solution to create a directory from MySQL.
Some will guide you with a workaround based on the creation of a data directory, I wouldn't recommand this, as it could lead to performances issues in the future, or worst.
The best solution would be to use a script (java, vbscript, SSH, batch, ...). Again, you won't be able to start this script within your SQL query easily. I know that's no good news, but it is important not to lead you on the wrong direction.
I would suggest to reverse your thinking, and start your SQL query from a script (again, any language you're used to).
I couldn't find any other way other than opening ssh session to the target box.
Open ssh session
Create directory
close ssh session
Load sql file using shell
The sql adds the generated files to the directory created in step 2.
ssh -t $USER#$HOST <<-SSH-END;
mkdir -p "dir/path";
exit;
SSH-END
Sharing just in case someone else needs to do the same.
I have been using MySQL Tuner (http://mysqltuner.com) on Linux for a while and am quite comfortable with it. Now, for whichever reason, we have had to start hosting other websites on IIS. Is there a similar tuning utility that may recommend config changes to MySQL on Windows Server 2008?
Kind regards
I have just ported the mysqltuner.pl script to Windows - see http://mysqltuner.codeplex.com/. It uses the same checks as version 1.2 of the mysqltuner.pl script, but in a nice, friendly Windows application - no need to install Cygwin or Perl.
Ok so this is over a year after the question but I thought it relevant because you can actually still use the mysqltuner script if you combine it with Cygwin.
Install Cygwin
Make sure Perl is installed
Additionally I installed the mysql and the mysqld packages as well (Needed for the script to connect to a "remote" MySQL.
Copy the mysqltuner.pl script to your Cygwin user home directory (Found under cygwin_install_dir/home/your.user)
Start the Cygwin terminal
Run the script $ perl mysqltuner.pl --host mysql_host_ip --forcemem 512
If you encounter an error in the line of:
ERROR 1130 (HY000): Host 'somename.company.com' is not allowed to connect to this MySQL server
Go to the database server and add the appropriate user and privelages
You should now be able to use mysqltuner in a windows environment against local as well as remote MySQL servers.
...screenshots removed because I'm not allowed to use images yet, sorry.
Don't know of another tool (outside the MySQL Instance Configuration Wizard you can run) like mysqltuner which will not run unfortunately. You can install Perl on Windows, but when run the .pl file you will get an error about $PATH not having mysqladmin in it. Upon reading of the manual laughing, it plain as day states there is no Windows support for 1.2.0 version of tool.
You can see if these suggestions help in the interim:
http://www.mysqlperformanceblog.com/2006/09/29/what-to-tune-in-mysql-server-after-installation/
Edit: I just found this: http://www.webyog.com/webyog/monyogscreenshots
MONyog, it is a paid product, though. I installed the trial and it looks very promising. It monitors your SQL server and gives you alerts and recommendations based on those alerts. Might be worth a look. I cannot vouch for too much other than it has some nice information in just a short period of time.
Hi I'm logging slow queries because we're having some performance
issues and I have read about mysqldumpslow and thought that would be a good
way to sort through the queries.
At the command prompt, I type mysqldumpslow and I get this:
'mysqldumpslow' is not recognized as
an internal or external command,
operable program or batch file.
I'm using MySQL version 5.0.79 on Windows Vista.
Note:
c:\Program Files\MySQL\MySQL Server 5.0\bin is my path and I have searched the drive for 'mysqldumpslow' and can not find it.
What am I doing wrong?
Note:
MySql 5.0.x does support the mysqldumpslow command follow this link to manual
edit : oops, I read the manual wrong, and gave wrong information :-( sorry :-( let's give it another try...
I've just installed MySQL on windows, to try using mysqldumpslow, and I don't have mysqldumpslow installed either :-( So, you are not alone, and it doesn't seem to be a problem with your install (I've tried 5.1.x, but as you highlighted, it should be the same for 5.0.x)
Looking at the "mysqldumpslow" I have under Linux, it appears it is a Perl script ; and Perl is not often installed on a Windows machine. Maybe that would be a hint to a solution...
Well, after a bit more testing, when installing MySQL, it seems you have to select "Developpers Components > Scripts, examples", which is not installed by default (at least on windows) -- no need to reinstall everything : you can "modify" the installation, to add this option.
Then, you will have a "script" directory next to the "bin" one.
For instance, on your install, it should be something like "c:\Program Files\MySQL\MySQL Server 5.0\scripts".
In this directory, there are some scripts ; one of them is mysqldumpslow.pl ; which is what you are looking for ;-)
Now, you "just" have to get Perl installed and running on your machine (sorry, I've never installed Perl on windows ; but you can find some informations here)
Hope this helps better than what I posted before !
try typing
whereis mysqldumpslow
If that still says its not installed,
EDIT: Above is not relevant, as on windows. Missed that, thanks to commenter for pointing it out.
I always use mysqlsla (mysql slow log analyser) ahead of mysqldumpslow - you could give that a go.
http://hackmysql.com/mysqlsla
Mysqldumpslow is a Perl script so under Windows you will need to make
sure you have Perl installed and will need to explicitly invoke it via
Perl.
The way the script is set up it will work automatically under Unix
because Unix has the ability to run scripts directly by identifying the
correct script processor from the first line of the script. Of course
you still need Perl installed, but that is taken for granted in most
Unix installations.
Or you can also try to set the path in Windows environment variables.