Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit b430f13

Browse files
committed
Added purge script and changed license.
1 parent 3ed39d1 commit b430f13

10 files changed

+1038
-894
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 4
8+
indent_style = space
9+
insert_final_newline = true
10+
tab_width = 8
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
trim_trailing_whitespace = false

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

LICENSE

-13
This file was deleted.

README.md

+91-79
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,91 @@
1-
# mysql
2-
This is my personal MariaDB 5.5 configuration on my Debian “Squeeze” 6 servers.
3-
4-
## Installing MariaDB
5-
I'm using the [switch.ch mirror](http://www.switch.ch/) in my `sources.list`:
6-
7-
```shell
8-
# Add mirror.switch.ch to the sources.list
9-
echo '# MariaDB 5.5
10-
deb http://mirror.switch.ch/mirror/mariadb/repo/5.5/debian squeeze main
11-
deb-src http://mirror.switch.ch/mirror/mariadb/repo/5.5/debian squeeze main' >> /etc/apt/sources.list
12-
# Fetch the GPG key for MariaDB releases
13-
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
14-
# Update the preferences
15-
echo '# /etc/apt/preferences
16-
17-
Package: *
18-
Pin: Origin mirror.switch.ch
19-
Pin-Priority: 900
20-
21-
Package: *
22-
Pin: release o=Debian,a=stable
23-
Pin-Priority: 500
24-
25-
Package: *
26-
Pin: release o=Debian
27-
Pin-Priority: -1' > /etc/apt/preferences
28-
# Update apt / aptitude
29-
aptitude update
30-
# Create the user for the mysql daemon
31-
adduser --no-create-home --disabled-password --disabled-login mysqld
32-
# Install MariaDB
33-
aptitude install mariadb-server-5.5
34-
```
35-
Have a look at the [MariaDB repository configuration tool](http://downloads.mariadb.org/MariaDB/repositories/) to find a repository near your server.
36-
37-
## Hugepages
38-
My configuration relies on hugepages support. You can use the configuration without it, the server will work, but it will log an error.
39-
### Activating hugepages
40-
```shell
41-
# Create backup of default system configuration
42-
sysctl -a > ~/sysctl_defaults.conf
43-
# Create configuration for hugepages
44-
echo '
45-
# Activate Hugepages support. Set the number of pages to be used.
46-
# Each page is normally 2MB, so a value of 256 = 512MB.
47-
# Set it to e.g. 512 or higher if you have lots of memory.
48-
vm.nr_hugepages = 256
49-
50-
# Set the group number that is allowed to access this memory.
51-
vm.hugetlb_shm_group = 1004
52-
53-
# Increase the amount of shmem allowed per segment. This depends
54-
# on the total memory our system actually has.
55-
# Value is given in bytes (536870912 = 512MB).
56-
kernel.shmmax = 536870912
57-
58-
# Increase total amount of shared memory.
59-
# This should be 50% of available RAM.
60-
# Value is given in bytes (805306368 = 768MB).
61-
kernel.shmall = 805306368' > ~/hugepages.conf
62-
# Apply settings
63-
sysctl -p ~/hugepages.conf
64-
```
65-
66-
## Create new init script
67-
In order to be able to use the hugepages you have to raise the ulimit for the mysqld user. I included a shell script which creates that new init script for you.
68-
```shell
69-
# Change to the cloned github repo
70-
cd /path/to/the/cloned/github/repo
71-
# Make the shell script executable
72-
chmod 770 create-mariadb-init-script.sh
73-
# And simply execute it
74-
./create-mariadb-init-script.sh
75-
```
76-
Afterwards you can start/restart/stop your MariaDB server via `/etc/init.d/mariadb`.
77-
78-
## Questions?
79-
Please bare in mind that this is an advanced configuration targeted towards user who have experience in administrating a server. But if you have any questions feel free to open an issue in the wiki of this repo.
1+
# mysql
2+
This is my personal MariaDB 5.5 configuration on my Debian �Squeeze� 6 servers.
3+
4+
## Installing MariaDB
5+
I'm using the [switch.ch mirror](http://www.switch.ch/) in my `sources.list`:
6+
7+
```shell
8+
# Add mirror.switch.ch to the sources.list
9+
echo '# MariaDB 5.5
10+
deb http://mirror.switch.ch/mirror/mariadb/repo/5.5/debian squeeze main
11+
deb-src http://mirror.switch.ch/mirror/mariadb/repo/5.5/debian squeeze main' >> /etc/apt/sources.list
12+
# Fetch the GPG key for MariaDB releases
13+
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
14+
# Update the preferences
15+
echo '# /etc/apt/preferences
16+
17+
Package: *
18+
Pin: Origin mirror.switch.ch
19+
Pin-Priority: 900
20+
21+
Package: *
22+
Pin: release o=Debian,a=stable
23+
Pin-Priority: 500
24+
25+
Package: *
26+
Pin: release o=Debian
27+
Pin-Priority: -1' > /etc/apt/preferences
28+
# Update apt / aptitude
29+
aptitude update
30+
# Create the user for the mysql daemon
31+
adduser --no-create-home --disabled-password --disabled-login mysqld
32+
# Install MariaDB
33+
aptitude install mariadb-server-5.5
34+
```
35+
Have a look at the [MariaDB repository configuration tool](http://downloads.mariadb.org/MariaDB/repositories/) to find a
36+
repository near your server.
37+
38+
## Hugepages
39+
My configuration relies on hugepages support. You can use the configuration without it, the server will work, but it
40+
will log an error.
41+
42+
### Activating hugepages
43+
```shell
44+
# Create backup of default system configuration
45+
sysctl -a > ~/sysctl_defaults.conf
46+
# Create configuration for hugepages
47+
echo '
48+
# Activate Hugepages support. Set the number of pages to be used.
49+
# Each page is normally 2MB, so a value of 256 = 512MB.
50+
# Set it to e.g. 512 or higher if you have lots of memory.
51+
vm.nr_hugepages = 256
52+
53+
# Set the group number that is allowed to access this memory.
54+
vm.hugetlb_shm_group = 1004
55+
56+
# Increase the amount of shmem allowed per segment. This depends
57+
# on the total memory our system actually has.
58+
# Value is given in bytes (536870912 = 512MB).
59+
kernel.shmmax = 536870912
60+
61+
# Increase total amount of shared memory.
62+
# This should be 50% of available RAM.
63+
# Value is given in bytes (805306368 = 768MB).
64+
kernel.shmall = 805306368' > ~/hugepages.conf
65+
# Apply settings
66+
sysctl -p ~/hugepages.conf
67+
```
68+
69+
## Create new init script
70+
In order to be able to use the hugepages you have to raise the ulimit for the mysqld user. I included a shell script
71+
which creates that new init script for you.
72+
73+
```shell
74+
# Change to the cloned github repo
75+
cd /path/to/the/cloned/github/repo
76+
# Make the shell script executable
77+
chmod 770 create-mariadb-init-script.sh
78+
# And simply execute it
79+
./create-mariadb-init-script.sh
80+
```
81+
82+
Afterwards you can start/restart/stop your MariaDB server via `/etc/init.d/mariadb`.
83+
84+
## Questions?
85+
Please bare in mind that this is an advanced configuration targeted towards user who have experience in administrating a
86+
server. But if you have any questions feel free to open an issue in the wiki of this repo.
87+
88+
## License
89+
> This is free and unencumbered software released into the public domain.
90+
>
91+
> For more information, please refer to <http://unlicense.org>

UNLICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <http://unlicense.org>
25+

create-mariadb-init-script.sh

+76-62
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,76 @@
1-
#!/bin/bash
2-
3-
# ----------------------------------------------------------------------
4-
# Create new init script for MariaDB after hugepages have been activated.
5-
# This init script raises the limit for shared memory to unlimited.
6-
# Otherwise the MariaDB process is not able to lock the hugepages for
7-
# itself. After raising the limit the normal init script is called. We
8-
# create a separate init script to not break the normal apt / aptitude
9-
# upgrade process of MariaDB (which includes the normal mysql init
10-
# script)!
11-
#
12-
# ----------------------------------------------------------------------
13-
#
14-
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
15-
# Version 2, December 2004
16-
#
17-
# Copyright (c) 2012 Richard Fussenegger <[email protected]>
18-
#
19-
# Everyone is permitted to copy and distribute verbatim or modified
20-
# copies of this license document, and changing it is allowed as long
21-
# as the name is changed.
22-
#
23-
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
24-
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
25-
#
26-
# 0. You just DO WHAT THE FUCK YOU WANT TO.
27-
#
28-
# ----------------------------------------------------------------------
29-
30-
# Tell the user that we are goin to create a new init script
31-
echo 'Creating new MariaDB inti script at /etc/init.d/mariadb'
32-
33-
# Create the actual init script
34-
echo '#!/bin/bash
35-
#
36-
### BEGIN INIT INFO
37-
# Provides: MariaDB
38-
# Required-Start: $remote_fs $syslog
39-
# Required-Stop: $remote_fs $syslog
40-
# Should-Start: $network $named $time
41-
# Should-Stop: $network $named $time
42-
# Default-Start: 2 3 4 5
43-
# Default-Stop: 0 1 6
44-
# Short-Description: Start and stop the MariaDB database server daemon
45-
# Description: Controls the main MariaDB database server daemon "mysqld"
46-
# and its wrapper script "mysqld_safe".
47-
### END INIT INFO
48-
49-
ulimit -l unlimited
50-
sh /etc/init.d/mysql "${1:-'\'''\''}"' > /etc/init.d/mariadb
51-
52-
# Change permissions so it is executable
53-
chmod 770 /etc/init.d/mariadb
54-
55-
# Remove the old init script from the system startup
56-
update-rc.d -f mysql remove
57-
58-
# Add our new init script to the system startup
59-
update-rc.d mariadb defaults
60-
61-
# Tell the user that we are done
62-
echo 'New init script created and added to system startup. DONE!'
1+
#!/bin/sh
2+
3+
# ------------------------------------------------------------------------------
4+
# This is free and unencumbered software released into the public domain.
5+
#
6+
# Anyone is free to copy, modify, publish, use, compile, sell, or distribute
7+
# this software, either in source code form or as a compiled binary, for any
8+
# purpose, commercial or non-commercial, and by any means.
9+
#
10+
# In jurisdictions that recognize copyright laws, the author or authors of this
11+
# software dedicate any and all copyright interest in the software to the
12+
# public domain. We make this dedication for the benefit of the public at large
13+
# and to the detriment of our heirs and successors. We intend this dedication
14+
# to be an overt act of relinquishment in perpetuity of all present and future
15+
# rights to this software under copyright law.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
#
24+
# For more information, please refer to <http://unlicense.org>
25+
# ------------------------------------------------------------------------------
26+
27+
# ------------------------------------------------------------------------------
28+
# Create new init script for MariaDB after hugepages have been activated.
29+
#
30+
# This init script raises the limit for shared memory to unlimited. Otherwise
31+
# the MariaDB process is not able to lock the hugepages for itself. After
32+
# raising the limit the normal init script is called. We create a separate init
33+
# script to not break the normal apt / aptitude upgrade process of MariaDB
34+
# (which includes the normal mysql init script)!
35+
#
36+
# AUTHOR: Richard Fussenegger <[email protected]>
37+
# COPYRIGHT: 2015 Richard Fussenegger
38+
# LICENSE: http://unlicense.org/ PD
39+
# ------------------------------------------------------------------------------
40+
41+
# Tell the user that we are goin to create a new init script
42+
printf -- 'Creating new MariaDB inti script at /etc/init.d/mariadb'
43+
44+
# Create the actual init script
45+
cat > /etc/init.d/mariadb << EOT
46+
#!/bin/sh
47+
48+
### BEGIN INIT INFO
49+
# Provides: MariaDB
50+
# Required-Start: $remote_fs $syslog
51+
# Required-Stop: $remote_fs $syslog
52+
# Should-Start: $network $named $time
53+
# Should-Stop: $network $named $time
54+
# Default-Start: 2 3 4 5
55+
# Default-Stop: 0 1 6
56+
# Short-Description: Start and stop the MariaDB database server daemon
57+
# Description: Controls the main MariaDB database server daemon "mysqld"
58+
# and its wrapper script "mysqld_safe".
59+
### END INIT INFO
60+
61+
ulimit -l unlimited
62+
sh /etc/init.d/mysql "${1:-'\'''\''}"
63+
64+
EOT
65+
66+
# Change permissions so it is executable
67+
chmod -- 755 /etc/init.d/mariadb
68+
69+
# Remove the old init script from the system startup
70+
update-rc.d -f mysql remove
71+
72+
# Add our new init script to the system startup
73+
update-rc.d mariadb defaults
74+
75+
# Tell the user that we are done
76+
printf -- '[ok] New init script created and added to system startup.'

0 commit comments

Comments
 (0)