Ubuntu 16.10 Server MariaDB (MySql) open_file_limit won’t go higher than 16364

In Ubuntu 16.10 and other systemd enabled OS like Debian, CentOs and LinuxMint with MariaDB Server version 10.x+ open_file_limit won’t go higher than 16364. according to MariaDB it’s simply because the SystemD daemon prefer new ways to set limit and a few other vital modifications

systemd is an init replacement that MariaDB uses on releases since 10.1.8. Distribution packages before this version may use a different configuration so consult their documentation if required.

systemd services are packaged on RPM and Debian based Linux distributions. When systemd is used, mysqld_safe is not used and settings in the mysqld_safe section of configuration files will not be read or applied.

systemd overview

systemd service files are included in the MariaDB-server package. The service definition is installed in /usr/lib/systemd/system/mariadb.service. The service name is mariadb.service; however aliases to mysql.service and mysqld.service are included for convenience.

Unlike previous init scripts, the mysqld process is executed directly from the init script running as the mysql user. This places a couple of limitations on situations that were previously possible:

  • open-files-limit cannot be raised beyond the operating system limit (usually 1K) and hence the systemd configuration for mariadb has LimitNOFILE set to 16K by default;
  • memlock can be used from version 10.1.10; and
  • The start timeout from init scripts was quite large and special configuration may be required if there is a slow startup time (MDEV-9202).
  • A mapping of common mysqld_safe options to systemd options is provided below.

    mysqld_safe option systemd option Comments
    no option ProtectHome=false If any MariaDB files are in /home/
    no option PrivateDevices=false If any MariaDB storage references raw block devices
    no option ProtectSystem= If any MariaDB write any files to anywhere under /boot, /usr or /etc
    no option TimeoutStartSec={time} Set if the systemd reports failure to start because of timeout. 0 disables any timeout
    no option (ref MDEV-9264) OOMScoreAdjust={priority} e.g. -600 to lower priority of OOM killer for mysqld
    open_files LimitNOFILE={limit}  
    core_file_size LimitCORE={size}  
      LimitMEMLOCK={size} or unlimited When large-pages or memlock is used
    nice Nice={nice value}  
    syslog StandardOutput=syslog  
    syslog-tag SyslogIdentifier  
    flush-caches ExecStartPre=/usr/bin/sync  
      ExecStartPre=/usr/sbin/sysctl -q -w vm.drop_caches=3  
    numa-interleave ExecStart=/usr/bin/numactl –interleave=all /usr/sbin/mysqld ${MYSQLD_OPTS} ${_WSREP_NEW_CLUSTER}  

    Note: systemd.service contains the official meanings for these systemd settings.

    There are other options and the mariadb-service-convert script will attempt to convert these as accurately as possible.

    In addition to the set of options previously provided by mysqld_safe, systemd.service has considerably more options.

When all or some of these settings have been altered don’t forget to:

systemctl daemon-reload
systemctl restart mysql.service

To make the new values active

To verify your changes open a mysql instance in terminal or your preferred Mysql GUI and type

show global variables like 'open%';

If you can see the changes, your done. As exsamle I’ve set my LimitNOFILE=1024000 in /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf and the output looks like

MariaDB [(none)]> show global variables like 'open%';
| Variable_name    | Value   |
| open_files_limit | 1024000 |
1 row in set (0.00 sec)

Posted on

Apache order of deny,allow or allow,deny

If you as many other users sometime need to do some allow,deny in apache and can’t remember which order to use them, then here is the link to Apaches Order Directives

But in short:

Ordering is one of:

First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.
First, all Deny directives are evaluated; if any match, the request is denied unless it also matches an Allow directive. Any requests which do not match any Allow or Deny directives are permitted.
This order has the same effect as Order Allow,Deny and is deprecated in its favor.

Keywords may only be separated by a comma; no whitespace is allowed between them.

Match Allow,Deny result Deny,Allow result
Match Allow only Request allowed Request allowed
Match Deny only Request denied Request denied
No match Default to second directive: Denied Default to second directive: Allowed
Match both Allow & Deny Final match controls: Denied Final match controls: Allowed

In the following example, all hosts in the apache.org domain are allowed access; all other hosts are denied access.

Order Deny,Allow
Deny from all
Allow from apache.org

In the next example, all hosts in the apache.org domain are allowed access, except for the hosts which are in the foo.apache.org subdomain, who are denied access. All hosts not in the apache.org domain are denied access because the default state is to Deny access to the server.

Order Allow,Deny
Allow from apache.org
Deny from foo.apache.org

On the other hand, if the Order in the last example is changed to Deny,Allow, all hosts will be allowed access. This happens because, regardless of the actual ordering of the directives in the configuration file, the Allow from apache.org will be evaluated last and will override the Deny from foo.apache.org. All hosts not in the apache.org domain will also be allowed access because the default state is Allow.

The presence of an Order directive can affect access to a part of the server even in the absence of accompanying Allow and Deny directives because of its effect on the default access state. For example,

<Directory /www>
Order Allow,Deny

will Deny all access to the /www directory because the default access state is set to Deny.

Posted on

How to clear NginX Reverse_proxy cache

You can also bypass/re-cache on a file by file basis using

proxy_cache_bypass $http_secret_header;

and as a bonus you can return this header to see if you got it from the cache (will return ‘HIT’) or from the content server (will return ‘BYPASS’).

add_header X-Cache-Status $upstream_cache_status;

to expire/refresh the cached file, use curl or any rest client to make a request to the cached page.

curl https://www.reck.dk/how-to-clear-ngi…erse_proxy-cache/ -s -I -H "secret-header:true"

this will return a fresh copy of the item and it will also replace what’s in cache

Posted on

Emilie Bonde Clarup synger Lis Sørensen’s Stille før storm

Offentliggjort den 25. okt. 2015
Sang: Emilie Bonde Clarup
Guitar: Nikolaj Krogh
Klaver: Olav K. Jepsen

Posted on

Emilie Bonde Clarup synger Dodo and the Dodo’s Giv Mig Skibene Tilbage

Giv Mig Skibene Tilbage, skrevet af Dodo and the Dodo’s
Sang: Emilie Bonde Clarup

PS: hun gør det godt

Posted on

Reload windows Enviroment Variables whitout restart

Hvordan kan man dog reloade Whitdows System Enviroments Variable uden at skulle genstarte eller logge ud og logge ind, og hvorfor skulle man dog dette. Jo det er jo smart hvis man gerne vil teste Variablerne man har tilføjet for at teste om FFmpeg nu virker efter man har installere fra “FFmpeg for Windows” og synes det kunne være dejligt kun at skulle taste “ffmpeg -i input.avi output.mp4” fordi man er misundelig på Linux brugerne.

Men for at kunne reloaded “Enviroment Variables” skal der bruges to scripts 1 .vbs og en .bat

I resetvars.vbs scriptet skal du putte følgende kode

Set oShell = WScript.CreateObject("WScript.Shell")
filename = oShell.ExpandEnvironmentStrings("%TEMP%\resetvars.bat")
Set objFileSystem = CreateObject("Scripting.fileSystemObject")
Set oFile = objFileSystem.CreateTextFile(filename, TRUE)

set oEnv=oShell.Environment("System")
for each sitem in oEnv 
    oFile.WriteLine("SET " & sitem)
path = oEnv("PATH")

set oEnv=oShell.Environment("User")
for each sitem in oEnv 
    oFile.WriteLine("SET " & sitem)

path = path & ";" & oEnv("PATH")
oFile.WriteLine("SET PATH=" & path)

I det andet script (resetvars.bat filen) skal du putte følgende kode

call "%TEMP%\resetvars.bat"

Nu skal du så eksekvere resetvars.bat for at genindlæse dine “Enviroment Variables”, og du kan gemme disse filer hvor du har lyst, eneste er at de skal ligge i samme folder

PS: Koden der skal tilføjes til “Enviroment Variables” for FFmpeg er ;C:\ffmpeg\bin i slutningen af “Path”

Posted on