changing default my.cnf path in mysql - mysql

I am having two mysql instances on same machine. The installations are on /usr/loca/mysql1 and /usr/local/mysql2.
I m having separate my.cnf files located in /etc/mysql1 and /etc/mysql2. I installed the first instance of my sql using source distribution and with the --prefix=/usr/local/mysql1 option. The second one i got from copying and pastinf the same directory to /usr/local/mysql2.
When i start the mysql daemon on /usr.local/mysql/libexec it reads the my.cnf file in /etc/mysql1. And if i start the mysql daemon in /usr/local/mysql2 it reads the same my.cnf file. I have separate port numbers and .sock files defined in the .cnf file in those 2 locations.
I can read the my.cnf file in the second location by using --defaults-file=/etc/mysql2/my.cnf option on mysqld startup. I do not need to enter this each and every time i start the daemon.
If i am going to have more instances how can i point the correct my.cnf file to read to each and every mysql daemon. What is the retionale behind mysqld links with the my.cnf file.
how can i predefine the location of my.cnf file for each instance.

As you've already discovered, MySQL has a compiled-in search location for its configuration file. Although you could recompile yourself, changing this, you've also discovered the --defaults-file option to mysqld, which instructs it to use an entirely different configuration path. Coupled with --data-dir, this means you can start multiple instances of MySQL bound to different ports (and addresses, if liked) and working with entirely separate sets of data, while working off the same binaries and libraries.
Traditionally, most operating system distributions will bundle a single init script for starting the "default" instance of MySQL; that is, the one installed in the "usual" location, and with the standard configuration path. Although this is to cater for the commonest case, what you're after is a bit different, so you'll need to create separate scripts to launch the separate instances.
If you're planning on deploying a lot of MySQL instances on the same machine (and I'd have to ask why), then you may want to write a custom init script which has some way of "discovering" each of these (perhaps by inspecting some directory containing a "common" layout), and then loops over them, starting each one up. Of course, the same init script then needs to be capable of locating and properly shutting down each one.

I think the only sure way is to compile from source with the prefix option. Either that, or create a bash script that starts mysql2 with the --defaults-file option and then use that to start it instead.
However, "creating" another installation the way you did isn't good. When you compile a package, the PREFIX is hard-coded into the executable. So whenever it looks for a resource, it starts from that prefix, unless told not to with command line options.
So, if I were you, I'd just recompile from source with a new prefix.

Related

How to separate /etc/my.cnf for different mysql versions

I want to be able to have different mysql/percona servers installed on same server.
However only one of them will be active until I decide to deactivate it and activate another.
Is there easy way to put /etc/my.cnf inside mysql data directory instead of /etc?
PHP using similar approach - ini file is inside php directory and /etc/php.ini is a symlink.
I am thinking about global /etc/my.cnf with single like !!includedir /xxxx/yyyy/$version.
Is this possible?
you can installed different version on same node with different data directive. To run same,you need to run mysql server with path of config file like below:
FULL_PATH/mysqld_safe --defaults-file=FULL_PATH/my.cnf &

MySQL binary log location Windows 2008 Server

I'm running a Windows 2008 Server with IIS, PHP and MySQL. MySQL is installed as a service. There's software on the server that uses a database that I need good backups of, including transaction logging. I've turned on Binary Logging via setting log-bin= and expire_logs_days= in the my.ini file. This saves those logs in the MySQL data folder on that drive. If I lose the drive, I lose my logs and they've done me no good as a backup.
I've found all kinds of advice for relocating these logs on a Linux box, but trying to use the same idea of including a path in the log-bin statement is not working. I've tried "flipping" the slashes, adding quotes and the common other attempts when "translating" Linux to Windows.
I created a mapped drive to the external location to make this easier, and I've tried using \server\folder path statements as well as z:\ path statements.
Any help would be greatly appreciated.
If you made your changes in the [mysqld] section in the my.ini file then you should be good. The correct path naming convention, should look something like this log-bin="C:/yourfilepathname/logs". Since you are still experiencing issues, Please check to make sure that mysql has permission to write to the directory that you are specify the logs files to be written to.
Another way you can check if this is the issue, go to your .err log file when you try to stop and start mysql server it will tell you something along the lines of not having permission to write to that directory.
Also, I would note that log bin files in it of themselves are not a backup. You need to be taking mysqldumps or snapshots of the entire directory from your server, preferably from a slave of your master production server.
You are missing a trailing slash.
Here is what's in my my.ini (I'm using MariaDB 10.1, but I believe this will work for you also):
[mysqld]
datadir=D:/mysql-data
log-bin=E:/mysql-bin/
When I left out the trailing slash in the log-bin setting, I also got the same error in logs, and the service failed to start. After adding the slash, no errors, and the service started successfully.
I now see files getting created in E:\mysql-bin, such as .index, .000001.
make sure you are ending with filename. see below.
log-bin=C:/Program Files/MySQL/MySQL Server 5.6/data/bin.log
Actually it's due to using the normal windows backslashes. Instead of z:\ use z:/ (forward slash). Also if you don't end with a forward slash then it will use the last part as the file name. Exp:
z:/bin-logs/ (this will have files named .index and .000001)
z:/bin-logs/log (this will have files named log.index and log.000001)

Relationship between different hbase-site.xml for a Cloudera install

With a Cloudera install of HBase, I saw three places have config information :
/etc/hbase/conf/hbase-site.xml,
/usr/lib/hbase/conf/hbase-site.xml,
and /var/run/cloudera-scm-agent/process/*-hbase-MASTER
Which one exactly is in effect? Or maybe all of them do?
In all cases of hbase the /etc/hbase/conf/hbase-site.xml file is always read. The /usr/lib/hbase/conf/hbase-site.xml is a symlink to /etc/hbase/conf/hbase-site.xml so it is the same file.
Lastly, anything in /var/run/ is a runtime variable and in your case it is the Cloudera Manager Agent. The Manager Agents are responsible for the management console and logging amongst other tasks.
I hope that helps,
Pat
The config file used is /usr/lib/hbase/conf/hbase-site.xml.
Other files aren't symbolic links.
Since the same configuration information needs to be used for other processes like HMaster,RegionServer, /usr/lib/hbase/conf/hbase-site.xml file is synced at different locations while initializing/preprocessing of these daemons. Hence it is advised to make any configuration changes in /usr/lib/hbase/conf/hbase-site.xml file only.
Also you need to make the same changes to these file on all nodes in your cluster and restart the HBase daemons.
I hope these answer your question.
Per my search and learning, HBase actually has two types of hbase-site.xml files, one for HMaster/RegionServer, and the other for client.
In Cloudera's distribution, the hbase-site.xml file in folder /var/run/cloudera-scm-agent/process/*-hbase-MASTER is the config used by the running HMaster process. Similar is for RegionServer.
Yet the site.xml file under /usr/lib/hbase/conf/ and /etc/hbase/conf/, symlinked from one to the other (according to #apesa), is for client usage. If one starts HBase shell on an HMaster host or a RegionServer host, this client config file will be used so the shell application knows how to connect to the ZooKeeper quorum to obtain the running HBase service. If one wants to use the HBase service from a client host, then he needs to copy this client xml file to the client host.
For regular Apache installation of HBase, as was indicated in Sachin's answer, the same hbase-site.xml is used for both purposes, though the HMaster, the RegionServer, and the client processes will use only the options needed and ignore the rest.
From experimenting with the hbase binary version 1.2.0-cdh5.16.1, it appears to use the Java classpath to find the hbase-site.xml file to use, whether running as a server or a client shell. There is a configuration parameter (--config) you can pass to hbase to control the config directory used, which by default is ./conf (run hbase to view the documented help on this).
This observation is supported by other answers on this topic (e.g. Question 14327367).
Therefore, to answer your specific question, to determine which config file is used on your machine, run hbase classpath and find which of the 3 directories appears first in the classpath.

MySQL and Windows Vista: How to setup replication?

I found many links where unix system is using.
Could anybody give some links for windows settings or tell me some quick start?
There are two listening addreses: 127.0.0.1/2 but mysql can connect also on 127.0.0.3 and so on. That is strange.
Thanks
In Windows, MYSQL.EXE can be called to install a windows service. The service then can be started and stopped using SERVICES.MSC or "NET START/STOP servicename". Part of the service-definition is the path to the MY.INI file that your MySQL instance is to use.
Example:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install instance1 --defaults-file=c:\instance1\my.ini
In your my.ini file, you need to create a [mysqld] section, and for each instance you need to define a different port number (or ip number) to use, and a different datadir.
Example:
[mysqld]
port=3307
datadir=c:\instance1\data
You can, and should, add additional definition here, or maybe use an existing my.ini file as a base to start from. Also, you need to copy a database datadir into that datadir-location, or generate a new empty datadir using whatever method - you'll end up with c:\instance1\data\mysql and the user.frm, user.MYD, user.MYI and so on files in that directories.
Start the instance using NET START instance1 or SERVICES.MSC. Check EVENTVWR.MSC for error messages if that fails.
Talk to the instance using
mysql --port=3307 --host=127.0.0.1
again avoiding the word localhost, as it has special meaning.
It is then possible to use normal Unix replication tutorials to play with replication. Make sure you are using 127.0.0.1 as a hostname ("localhost" is a magic word in the MySQL/C connector and it's derivates), and that you always also specify a proper port number.
Ok. I found out that I need different servers anyway.

MySql portable version

anyone know a portable version of mysql?
I know xampp but it comes with PHP and Apache together
anyone know how to isolate the mysql?
You can download the MySQL Essentials version and make a few small changes to directories in the my.ini file to use relative paths instead of absolute paths. Then you can run the server directly without having to install or use a Windows service.
Download a MySQL .zip file (instead of an .msi, though you could get the .msi and use 7Zip or Orca to extract the files from it).
Extract the files. At a minimum you need the bin and share directories (actually, in bin, you really only need mysqld.exe as the absolute minimum to run a server).
Edit my.ini to change the basedir and datadir paths to something relative. For example:
basedir=".."
datadir="/MySQLdb"
If you do not have an existing database, then create one:
mysqld --bootstrap
Run the server (you may need to use the --skip-grant-tables switch to get it running until you have set up your MySQL user):
mysqld
To avoid the server being run in the current command-prompt, you can use the following to have it run in its own console which should disappear once it is running:
start mysqld
If you get errors, delete the log files (e.g., logs\ib_logfile*) and run it again.
I think not, without counting on XAMPP. You don't have to use PHP or Apache anyway, just run the mysql from the .exe's
Created a portable configuration at https://sourceforge.net/projects/mysql-server-portable/
You should put your my.cnf or my.ini in a different directory than your data directory.
You will then need to initialize your portable version,
"\mysql-5.7.30-winx64\bin\mysqld" --defaults-file="\mysql-5.7.30-winx64\config\my.ini" --standalone --explicit_defaults_for_timestamp --initialize
then you can start your portable version,
"\mysql-5.7.30-winx64\bin\mysqld" --defaults-file="\mysql-5.7.30-winx64\config\my.ini" --standalone --explicit_defaults_for_timestamp