-
-
Save msmith/1171217 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance. | |
# | |
# Must be run with root privileges | |
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5) | |
# | |
export BUILD_DIR="$PWD" | |
# install gem dependencies | |
yum install gcc gcc-c++ libtool curl-devel ruby-rdoc zlib-devel openssl-devel make automake rubygems perl git-core | |
gem install rake --no-ri --no-rdoc | |
if [ ! -e "/usr/local/bin/couchdb" ] | |
then | |
if [ ! -d "$BUILD_DIR/build-couchdb" ] | |
then | |
# get build-couch code | |
git clone git://github.com/iriscouch/build-couchdb | |
cd $BUILD_DIR/build-couchdb/ | |
git submodule init | |
git submodule update | |
fi | |
# run build-couch | |
cd $BUILD_DIR/build-couchdb/ | |
rake git="git://git.apache.org/couchdb.git tags/1.1.0" install=/usr/local | |
fi | |
# install our .ini | |
cat << 'EOF' > /usr/local/etc/couchdb/local.ini | |
[couchdb] | |
delayed_commits = false | |
[httpd] | |
port = 80 | |
bind_address = 0.0.0.0 | |
socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}] | |
WWW-Authenticate = Basic realm="administrator" | |
;WWW-Authenticate = bummer | |
[couch_httpd_auth] | |
require_valid_user = true | |
[log] | |
level = error | |
[admins] | |
EOF | |
# generate & set the initial password | |
export ADMIN_PASSWORD=`mkpasswd` | |
echo "admin = ${ADMIN_PASSWORD}" >> /usr/local/etc/couchdb/local.ini | |
# allow beam to bind to port 80 (not necessary if you make httpd.port >=1024) | |
setcap 'cap_net_bind_service=+ep' /usr/local/lib/erlang/erts-5.8.4/bin/beam | |
if [ ! -e "/etc/logrotate.d/couchdb" ] | |
then | |
# add couch.log to logrotate | |
ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/ | |
# change to daily rotation | |
sed -e s/weekly/daily/g -i /usr/local/etc/logrotate.d/couchdb | |
#logrotate -v -f /etc/logrotate.d/couchdb | |
fi | |
# add couchdb user | |
adduser --system --home /usr/local/var/lib/couchdb -M --shell /bin/bash --comment "CouchDB" couchdb | |
# change file ownership | |
chown -R couchdb:couchdb /usr/local/etc/couchdb /usr/local/var/lib/couchdb /usr/local/var/log/couchdb /usr/local/var/run/couchdb | |
# run couchdb on startup | |
ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb | |
chkconfig --add couchdb | |
chkconfig --level 345 couchdb on | |
# done! | |
echo | |
echo | |
echo "Installation complete!" | |
echo "Couchdb admin password was set to: ${ADMIN_PASSWORD}" | |
echo | |
echo "Couchdb is ready to start. Run:" | |
echo " sudo service couchdb start" |
Ran into an error using this script to install on a fresh Amazon Linux AMI. Any help would be greatly appreciated!
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:309: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:318: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:323: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:323: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:323: warning: (near initialization for ‘CouchHTTPFunctions[0]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:324: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:324: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:324: warning: (near initialization for ‘CouchHTTPFunctions[1]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:325: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:325: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:325: warning: (near initialization for ‘CouchHTTPFunctions[2]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:326: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:326: warning: (near initialization for ‘CouchHTTPFunctions[3]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c: In function ‘install_http’:
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/http.c:346: warning: passing argument 5 of ‘JS_InitClass’ from incompatible pointer type
/usr/local/include/js/jsapi.h:2127: note: expected ‘JSNative’ but argument is of type ‘JSBool ()(struct JSContext *, struct JSObject *, uintN, jsval *, jsval *)’
mv -f .deps/couchjs-http.Tpo .deps/couchjs-http.Po
gcc -DHAVE_CONFIG_H -I. -I/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv -I../../.. -D_XOPEN_SOURCE -L/usr/local/lib -L/usr/local/lib -L/opt/local/lib -I/usr/local/lib/erlang/usr/include -I/usr/local/include/js -DXP_UNIX -I/usr/local/include -I/usr/local/include/js -D_BSD_SOURCE -I/usr/local/include -g -O2 -MT couchjs-main.o -MD -MP -MF .deps/couchjs-main.Tpo -c -o couchjs-main.o test -f 'couch_js/main.c' || echo '/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/'
couch_js/main.c
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c: In function ‘evalcx’:
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:62: warning: assignment makes pointer from integer without a cast
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c: In function ‘execute_script’:
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:215: error: ‘JSScript’ undeclared (first use in this function)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:215: error: (Each undeclared identifier is reported only once
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:215: error: for each function it appears in.)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:215: error: ‘script’ undeclared (first use in this function)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c: At top level:
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:251: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:251: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:251: warning: (near initialization for ‘global_functions[0]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:252: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:252: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:252: warning: (near initialization for ‘global_functions[1]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:253: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:253: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:253: warning: (near initialization for ‘global_functions[2]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:254: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:254: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:254: warning: (near initialization for ‘global_functions[3]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:255: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:255: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:255: warning: (near initialization for ‘global_functions[4]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:256: warning: initialization from incompatible pointer type
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:256: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:256: warning: (near initialization for ‘global_functions[5]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:257: warning: excess elements in struct initializer
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:257: warning: (near initialization for ‘global_functions[6]’)
/home/ec2-user/build-couchdb/git-build/git%3A%2F%2Fgit.apache.org%2Fcouchdb.git%3Atags%2F1.1.0/src/couchdb/priv/couch_js/main.c:266: warning: initialization from incompatible pointer type
make[4]: ** [couchjs-main.o] Error 1
make[4]: Leaving directory /tmp/couchdb-build20120426-30815-7iwl93/src/couchdb/priv' make[3]: Leaving directory
/tmp/couchdb-build20120426-30815-7iwl93/src/couchdb'
make[2]: Leaving directory /tmp/couchdb-build20120426-30815-7iwl93/src' make[1]: Leaving directory
/tmp/couchdb-build20120426-30815-7iwl93'
make[3]: *** [all-recursive] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
git checkout HEAD src/couchdb/priv/couch_js/utf8.h
git ls-files --others --ignored --exclude-standard | xargs rm -vf
removed INSTALL' removed
Makefile.in'
removed acinclude.m4' removed
aclocal.m4'
removed bin/Makefile.in' removed
config.h.in'
removed configure' removed
etc/Makefile.in'
removed etc/couchdb/Makefile.in' removed
etc/default/Makefile.in'
removed etc/init/Makefile.in' removed
etc/launchd/Makefile.in'
removed etc/logrotate.d/Makefile.in' removed
etc/windows/Makefile.in'
removed m4/ac_check_curl.m4' removed
m4/ac_check_icu.m4'
removed m4/libtool.m4' removed
m4/ltoptions.m4'
removed m4/ltsugar.m4' removed
m4/ltversion.m4'
removed m4/lt~obsolete.m4' removed
share/Makefile.in'
removed src/Makefile.in' removed
src/couchdb/Makefile.in'
removed src/couchdb/priv/Makefile.in' removed
src/erlang-oauth/Makefile.in'
removed src/etap/Makefile.in' removed
src/ibrowse/Makefile.in'
removed src/mochiweb/Makefile.in' removed
test/Makefile.in'
removed test/bench/Makefile.in' removed
test/etap/Makefile.in'
removed test/javascript/Makefile.in' removed
test/view_server/Makefile.in'
removed utils/Makefile.in' removed
var/Makefile.in'
rake aborted!
Command failed with status (2): [make ...]
Tasks: TOP => default => couchdb:build => couchdb:couchdb => /usr/local/bin/couchdb
(See full trace by running task with --trace)
./couchdb-ec2-install.sh: line 34: /usr/local/etc/couchdb/local.ini: No such file or directory
./couchdb-ec2-install.sh: line 55: mkpasswd: command not found
./couchdb-ec2-install.sh: line 56: /usr/local/etc/couchdb/local.ini: No such file or directory
Failed to set capabilities on file `/usr/local/lib/erlang/erts-5.8.4/bin/beam' (No such file or directory)
usage: setcap [-q] -v [ ... (-r|-|) ]
Note must be a regular (non-symlink) file.
sed: can't read /usr/local/etc/logrotate.d/couchdb: No such file or directory
chown: cannot access /usr/local/etc/couchdb': No such file or directory chown: cannot access
/usr/local/var/lib/couchdb': No such file or directory
chown: cannot access `/usr/local/var/log/couchdb': No such file or directory
error reading information on service couchdb: No such file or directory
error reading information on service couchdb: No such file or directory
Installation complete!
Couchdb admin password was set to:
Couchdb is ready to start. Run:
sudo service couchdb start
[ec2-user@ip-10-28-197-254 ~]$ sudo service couchdb start
couchdb: unrecognized service
on my instance erts is v 5.9
changed line to read:
allow beam to bind to port 80 (not necessary if you make httpd.port >=1024)
setcap 'cap_net_bind_service=+ep' /usr/local/lib/erlang/erts-5.9/bin/beam
i also changed
rake git="git://git.apache.org/couchdb.git tags/1.2.0" install=/usr/local
After these two changes it seemed to run.
Installing on AWS 64 bit linux large instance.
Made the changes in the comments above and the script ran to completion. erts was 5.9.1.3 btw.
service couchdb start and it's running as checked with ps ax
service couchdb status returns blank line.
curl http://localhost:5984/
curl: (7) couldn't connect to host
I'm wondering if it's a 64 bit issue.
hello people,
can someone please help me.
I am new to this stuff.
What do i have to type in the terminal in order to run the *sh script.
I am struggeling even with downloading the script :-/
I build up an aws linux ec2 and have access via ssh.
Please help :-)
Great script! Maybe consider using 1.3.0 instead, and R14B04 as your erlang release. Nice to update it a bit :-). @cesine your changes are spot on, good work!
503 Service Temporarily Unavailable while accessing https://git-wip-us.apache.org/repos/asf/couchdb.git
Successfully installed rake-12.3.0
1 gem installed
./couchDBScript.sh: line 30: rake: command not found
rake not found even after installation. why is that?
Yup, we use this in http://blitz.io to spin up new instances (especially with EC2 user-data) and it's super useful.