-
-
Save thinhhung/0e1a3f8caf4ce0aa744407208d4ac749 to your computer and use it in GitHub Desktop.
Install beanstalkd on CentOS 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Beanstalkd is a simple, fast work queue | |
[Service] | |
User=nobody | |
Restart=always | |
RestartSec=500ms | |
ExecStart=/usr/local/bin/beanstalkd -b /var/lib/beanstalkd | |
LimitNOFILE=10240 | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Socket for beanstalkd, a simple, fast work queue | |
[Socket] | |
ListenStream=11300 | |
[Install] | |
WantedBy=sockets.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# | |
# wget -O- https://gist.githubusercontent.com/ifduyue/2ebe43be8d2ea1275abf/raw/install-beanstalkd-allinone.sh | bash -s | |
# ...or... | |
# curl -sSL https://gist.githubusercontent.com/ifduyue/2ebe43be8d2ea1275abf/raw/install-beanstalkd-allinone.sh | bash -s | |
# | |
# Set options: | |
# {wget or curl like above...} | beanstalkd_opt='-b /var/lib/beanstalkd -f0' bash -s | |
# | |
# | |
# $ beanstalkd -h | |
# Use: beanstalkd [OPTIONS] | |
# | |
# Options: | |
# -b DIR wal directory | |
# -f MS fsync at most once every MS milliseconds (use -f0 for "always fsync") | |
# -F never fsync (default) | |
# -l ADDR listen on address (default is 0.0.0.0) | |
# -p PORT listen on port (default is 11300) | |
# -u USER become user and group | |
# -z BYTES set the maximum job size in bytes (default is 65535) | |
# -s BYTES set the size of each wal file (default is 10485760) | |
# (will be rounded up to a multiple of 512 bytes) | |
# -c compact the binlog (default) | |
# -n do not compact the binlog | |
# -v show version information | |
# -V increase verbosity | |
# -h show this help | |
# | |
set -eu | |
version=1.10 | |
beanstalkd_opt=${beanstalkd_opt--b /var/lib/beanstalkd} | |
wget -O v$version.tar.gz https://github.com/kr/beanstalkd/archive/v$version.tar.gz | |
tar xf v$version.tar.gz | |
make -C beanstalkd-$version | |
make install -C beanstalkd-$version | |
rm -rf beanstalkd-$version v$version.tar.gz | |
if [[ ! -f /lib/systemd/system/beanstalkd.service ]]; then | |
cat > /lib/systemd/system/beanstalkd.service <<EOF | |
[Unit] | |
Description=Beanstalkd is a simple, fast work queue | |
[Service] | |
User=nobody | |
Restart=always | |
RestartSec=500ms | |
ExecStart=/usr/local/bin/beanstalkd $beanstalkd_opt | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
fi | |
if [[ ! -f /lib/systemd/system/beanstalkd.socket ]]; then | |
cat > /lib/systemd/system/beanstalkd.socket <<EOF | |
[Unit] | |
Description=Socket for beanstalkd, a simple, fast work queue | |
[Socket] | |
ListenStream=11300 | |
[Install] | |
WantedBy=sockets.target | |
EOF | |
fi | |
valdir=$(echo -- $beanstalkd_opt | grep -Po -- '-b \K[^ ]+') || true | |
if [[ -n "$valdir" ]]; then | |
mkdir -p $valdir | |
chown nobody:nobody $valdir | |
fi | |
systemctl enable beanstalkd.service | |
systemctl start beanstalkd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
version=1.10 | |
wget -O v$version.tar.gz https://github.com/kr/beanstalkd/archive/v$version.tar.gz | |
tar xf v$version.tar.gz | |
make -C beanstalkd-$version | |
make install -C beanstalkd-$version | |
rm -rf beanstalkd-$version v$version.tar.gz | |
if [[ -f beanstalkd.service && -f beanstalkd.socket ]]; then | |
cp beanstalkd.service /lib/systemd/system/beanstalkd.service | |
cp beanstalkd.socket /lib/systemd/system/beanstalkd.socket | |
mkdir -p /var/lib/beanstalkd | |
chown nobody:nobody /var/lib/beanstalkd | |
systemctl enable beanstalkd.service | |
systemctl start beanstalkd.service | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment