Configuring multiple instances of mysqld on almalinux - mysql

I've been trying to setup multiple instances of mysqld on an almalinux box.
I can't get the systemctl start mysqld#replica03 statements to recognize the associated options setup in the /etc/my.cnf file.
If I change the [mysqld#replica03] or [mysqld#replica04] to [mysqld] it works and uses the appropriate datadir and port. As soon as I use [mysqld#replica03] and [mysqld#replica04] in the /etc/my.cnf file it uses the default /var/lib/msyql datadir and options instead of the ones I specified
I have run
systemctl enable mysqld#replica03
systemctl enable mysqld#replica04
Any ideas would be appreciated.
/etc/my.cnf file:
[client-server]
[mysqld#replica03]
server_id=3
port=3306
datadir=/var/lib/mysql_replica03
socket=/var/lib/mysql_replica03/mysql.sock
log-error=/var/log/mysql_replica03/mysqld.log
pid-file=/var/run/mysqld_replica03/mysqld.pid
[mysqld#replica04]
server_id=4
port=3307
datadir=/var/lib/mysql_replica04
socket=/var/lib/mysql_replica04/mysql.sock
log-error=/var/log/mysql_replica04/mysqld.log
pid-file=/var/run/mysqld_replica04/mysqld.pid

When you need multiple instances, and you're using systemd to achieve it, the server option groups configuration is the way to go.
The comment you made on your question shows that the suffix used is prefixed with a dot.
ExecStart=/usr/libexec/mysqld --defaults-group-suffix=.%I
So the server groups should be rewritten to
[mysqld.replica03]
server_id=3
port=3306
datadir=/var/lib/mysql_replica03
socket=/var/lib/mysql_replica03/mysql.sock
log-error=/var/log/mysql_replica03/mysqld.log
pid-file=/var/run/mysqld_replica03/mysqld.pid
[mysqld.replica04]
server_id=4
port=3307
datadir=/var/lib/mysql_replica04
socket=/var/lib/mysql_replica04/mysql.sock
log-error=/var/log/mysql_replica04/mysqld.log
pid-file=/var/run/mysqld_replica04/mysqld.pid
Another important observation is that the order in configuration files matters. Theses replica servers definitions need to be parsed after main [mysql] section.
my_print_defaults will help you with it:
$ my_print_defaults --defaults-group-suffix=.another mysqld
--datadir=/var/lib/mysql
--socket=/var/lib/mysql/mysql.sock
--log-error=/var/log/mariadb/mariadb.log
--pid-file=/run/mariadb/mariadb.pid
--datadir=/db/another/mysql
--socket=/db/another/mysql/mysql.sock
--log-error=/db/another/log/mariadb/mariadb.log
--pid-file=/run/mariadb/mariadb-another.pid
$
If your OS has a /etc/my.cnf.d/ directory, as mine does, you will need to sort the filenames in order to accommodate this requirement.
As I'm using mariadb, and I have a /etc/my.cnf.d/mariadb-server.cnf, my another server group is on a file named zz-another.cnf, making sure it will be parsed after mariadb-server.cnf.

Related

How to decrease MySQL container memory usage?

Problem:
MySQL is taking over 350MB on idle, as shown in docker stats
Tried:
Tweaking the configuration file as suggested in posts like this one.
Added these lines to the file: /etc/mysql/my.cnf
innodb_buffer_pool_size=64M
innodb_log_buffer_size=256K
max_connections=5
key_buffer_size=8
thread_cache_size=0
host_cache_size=0
innodb_ft_cache_size=1600000
innodb_ft_total_cache_size=32000000
thread_stack=131072
sort_buffer_size=32K
read_buffer_size=8200
read_rnd_buffer_size=8200
max_heap_table_size=16K
tmp_table_size=1K
bulk_insert_buffer_size=0
join_buffer_size=128
net_buffer_length=1K
innodb_sort_buffer_size=64K
Dockerfile
FROM mysql
COPY my.cnf /etc/mysql/
Actual:
I made sure my.cnf changes were in the container, however its still taking over 350MB idle, is it possible to get it below that or am I trying something just not possible?
Prepared repository:
https://github.com/alexanderkoller/low-memory-mysql
Before using this repository's configurations memory is about 458Mib/s
After: 31.12Mib/s
Tested on mysql 5.6
You can try and appropriately reduce footage.
https://github.com/major/MySQLTuner-perl

PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start

when i try to start the zabbix-server i am getting and run/zabbix/zabbix_server.pid not readable (yet?) error,
ls -al
-rw-rw-r--. 1 zabbix zabbix 5 May 1 15:15 zabbix_server.pid
my zabbix-server config file
#This is a configuration file for Zabbix Server process
# To get more information about Zabbix,
# visit http://www.zabbix.com
############ GENERAL PARAMETERS #################
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
#PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Please help. suggest me a solution
I've had this issue when building a zabbix 4.0 server. To fix the issue I made sure that the path to the PID file was correct on '/etc/zabbix/zabbix_server.conf' and '/lib/systemd/system/zabbix-server.service'.
Interestingly restarting the service alone did not get rid of the error. I needed to reboot the server and this fixed the problem.
close the selinux on centos7
It works for me.
just close selinux for this time
setenforce 0
Close selinux forever
vi /etc/selinux/config
SELINUX=disabled
That message only indicates that the server failed to start. Check the server log (/var/log/zabbix/zabbix_server.log according to your config file), it will contain a more meaningful error message.
In my case, it was a issue connecting with the database.
Remove current pid file + be sure that no zabbix_server process is running on your machine.
Zabbix server does not accept special chars like: !##$%^&*()_+,./;'[]}{|":?>< in DBPassword variable.

Issue when running mysqld

I download mysql-5.7.9-winx64.zip and when i try to run mysqld i got this error :
E:\Softwares\mysql-5.7.9-winx64\bin>mysqld
mysqld: Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.
mysqld: Can't change dir to 'E:\Softwares\mysql-5.7.9-winx64\data\' (Errcode: 2 - No such file or directory)
2015-11-13T10:45:09.715411Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_ti
mestamp server option (see documentation for more details).
2015-11-13T10:45:09.731411Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of
generated files. Consider setting it to a valid, non-empty path.
2015-11-13T10:45:09.732411Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2015-11-13T10:45:09.732411Z 0 [Note] mysqld (mysqld 5.7.9) starting as process 3532 ...
2015-11-13T10:45:09.864419Z 0 [Warning] Can't create test file E:\Softwares\mysql-5.7.9-winx64\data\yous-PC.lower-test
2015-11-13T10:45:09.864419Z 0 [Warning] Can't create test file E:\Softwares\mysql-5.7.9-winx64\data\yous-PC.lower-test
2015-11-13T10:45:09.864419Z 0 [ERROR] failed to set datadir to E:\Softwares\mysql-5.7.9-winx64\data\
2015-11-13T10:45:09.865419Z 0 [ERROR] Aborting
2015-11-13T10:45:09.865419Z 0 [Note] Binlog end
2015-11-13T10:45:09.945424Z 0 [Note] mysqld: Shutdown complete
You must run the Command Prompt as administrator. Then run mysqld.
To do this right click the Command Prompt startup icon and then select Run As Admininistrator. Then run mysqld and you should no longer see that error.
mysqld needs access to your registry the first time. you do not have to do this after the first time.
For development/debugging purposes i need a MySQL-Server without installation and don't want it to change my windows installation, e.g. by setting registry keys. MySQL's hint "start server with --log_syslog=0" works well:
mysqld -u root --log_syslog=0
try the MySQL Installer 5.7.9 to install it automatically mysql-installer-web-community-5.7.9.0.msi and it works.
Windows operating system will not allow you to make changes in certain system critical registry keys. Nevertheless, if you want to make changes even in such registry keys, you will have to take full control of these keys before Windows will allow you to make or save the changes.
check this link:
http://www.thewindowsclub.com/how-to-take-full-control-of-windows-7-registry-keys
I ran into the same problem on a Windows machine. I tried to "Run as Administrator" and change the path, but nothing prevailed.
It turned out Mysql wasn't reading the "my.ini" file.
I solved the problem by putting the "my.ini" file into the C:/Windows directory as it was pointed out in the official MySQL troubleshoot guide HERE
I run into both log error and data folder misconfig issues like you have.
Here is my solution:
Run the Command Prompt as administrator. Then run mysqld. - (just like user1660791 suggested)
For the path error, you need to make sure to \ instead of \ for path.
Example as below:
basedir = C:\\myfolder\\mysql-5.7.11-winx64
Have to post this as new answer due to i don't have permission comment of others post.
Use basedir = C:/myfolder/mysql-5.7.11-winx64 then find cmd.exe for the path: C:\Windows\System32\cmd.exe.
In order to do this, right click the Command Prompt startup icon and then select "Run As Admininistrator".

Monit to monitor 2 searchd instances on one server

I have 2 rails apps hosted on the same server and each one of them have its own configuration for thinking_sphinx /searchd with different ports configured. I managed to get this set up working and I have 2 instances of searchd running.
My problem is getting Monit to monitor these 2 instances. Even though these 2 instances of searchd have its own PID in separate directories, I was not able to define the configuration in the monitrc because the process names in this case are the same, namely searchd.
In my monitrc, i have 2 separate commands as follows:
check process searchd with pidfile /var/www/app1/shared/pids/production.sphinx.pid
start program=....
stop program=....
check process searchd with pidfile /var/www/app2/shared/pids/production.sphinx.pid
start program=...
stop program=...
Monit requires a unique process name. Is it possible to start up my second instance of searchd using a different process name?
Thanks for the help.
You can call the process whatever you wish in monit configuration files - it doesn't need to match the executable. So:
check process searchd_app1 with pidfile /var/www/app1/shared/pids/production.sphinx.pid
start program=....
stop program=....
check process searchd_app2 with pidfile /var/www/app2/shared/pids/production.sphinx.pid
start program=...
stop program=...

Monit service name error

So I have the following in my monitrc file:
check process apache with pidfile /usr/local/apache/logs/httpd.pid
group apache
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed host XXX port 80 protocol http
and request "/monit/token" then restart
if cpu is greater than 60% for 2 cycles then alert
if cpu 80% for 5 cycles then restart
if totalmem 500 MB for 5 cycles then restart
if children 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
but I keep getting the error that:
Error: service name conflict, apache already defined '/usr/local/apache/logs/httpd.pid'
If the hostname of the server is 'apache' then the conflict is with the default rule for monitoring the system load.
Monit seems to have the implicit rule of 'check system hostname', where the hostname is the output of hostname command.
You can overwrite that by adding just a line like:
check system newhostname
For example:
check system localhost
I saw this error when I forgot to comment out the line:
include /etc/monit/conf.d/*
in a custom /etc/monit/conf.d/myprogram.conf file, so it was recursively including that file.
By any chance do you have an entry with a host name apache beneath this entry or in a separate monit config file?
You have the same service defined more than once. Check all your monit config files for that service. This includes your monitrc and all files listed under the "Includes" section (like include /etc/monit/conf.d/*).
If you redefine "Includes" within a file in one of your "Includes" directories, you will run into recursive reference problems.
Very very important thing : you need monit 5.5
For example in ubuntu 12.04 available in repo only 5.3
So you need to download and install from other repo.
Solution for me , for example :
wget http://mirrors.kernel.org/ubuntu/pool/universe/m/monit/monit_5.5.1-1_amd64.deb && sudo dpkg -i monit_5.5.1-1_amd64.deb
For my case, I simply had to restart monit to get rid of the service name error:
sudo service monit restart
Check if you have had any conflicts for Apache defined in any of the monit conf files under /etc/monit.d/ directory, I accidentally did added nginx for my puma.conf and ran into the same error before.