CouchDB: Unable to start CouchDB normally - couchdb

I am a newbie to couchDB. Recently, I have dived into it with a quick installation instruction over here:
sudo apt-get update -y
sudo apt-get install g++ -y
sudo apt-get install erlang-base erlang-dev erlang-eunit erlang-nox -y
sudo apt-get install libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool -y
curl -O http://apache.mirrors.tds.net/couchdb/source/1.5.1/apache-couchdb-1.5.1.tar.gz
tar -zxvf apache-couchdb-1.5.1.tar.gz
cd apache-couchdb-1.5.1
./configure
make
sudo make install
sudo adduser --disabled-login --disabled-password --no-create-home couchdb
sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb
sudo ln -s /usr/local/etc/logrotate.d/couchdb /etc/logrotate.d/couchdb
sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d
sudo update-rc.d couchdb defaults
1. modify /usr/local/etc/couchdb/local.ini
2. change bindAddress to 0.0.0.0
3. reboot
4. remember to go into the config settings and secure server
5. remember to turn on auto compaction
I have followed exactly the guide, except the 4th and 5th steps cause I did not know how to do it. When I ran:
couchdb
I got the following message in the terminal (I am using Ubuntu 14.04 LTS):
Apache CouchDB 1.5.1 (LogLevel=info) is starting.
Error opening log file /usr/local/var/log/couchdb/couch.log: permission denied{"init terminating in do_boot",{{badmatch,{error,{bad_return,{{couch_app,start,[normal,["/usr/local/etc/couchdb/default.ini","/usr/local/etc/couchdb/local.ini"]]},{'EXIT',{{badmatch,{error,{shutdown,{failed_to_start_child,couch_primary_services,{shutdown,{failed_to_start_child,couch_log,{error,"permission denied","/usr/local/var/log/couchdb/couch.log"}}}}}}},[{couch_server_sup,start_server,1,[{file,"couch_server_sup.erl"},{line,98}]},{application_master,start_it_old,4,[{file,"application_master.erl"},{line,269}]}]}}}}}},[{couch,start,0,[{file,"couch.erl"},{line,18}]},{init,start_it,1,[]},{init,start_em,1,[]}]}}
Crash dump was written to: erl_crash.dump
init terminating in do_boot ()
May anyone help me figure out this problem and suggest some solution to fix it? Thank you very much.

You may need to start the couchdb process as the couchdb user, with su couchdb -c ./couchdb (assuming the current directory contains the executable) - double-check the su command options for your system.
Also, check the permissions on /usr/local/var/log/couchdb/couch.log - make sure it is writeable by the couchdb user.

I would like to make a note here for how I fixed this problem in my environment. In my case, the /opt/couchdb/data folder was a symlink to /var/lib/couchdb. No matter what I tried I would get a permission denied error at startup, even though all the files seemed to be owned by user couchdb.
I eventually figured out that the "execute" permission was not set on /var/lib. Without this permission the symlink would not work. If you run into this problem, start by setting chmod -R a+x /var as I did, to prevent this from happening.

Although on CentOS, the "problem" is avoided using service couchdb [start|status|stop|restart].

https://medium.com/#tomiwatech_45998/installing-couchdb-on-ubuntu-17-10-18148e2eb846
Hi there,
this helped me resolve the issue and solved the problem. My ubuntu version is 16.04 and i downloaded couchdb-1.7.0 version.

You can start couchdb using below command
sudo couchdb stop
sudo couchdb start

Related

As part of shell script, sudo su is not working. Any alternate?

The below 3 lines are part of my shell script, but it is executing first line and copying file properly.
In-order execute this rpm file, i need to prompt to root user. Hence, 2nd step i wrote. But it is not executing, hence i'm not able to install the rpm file.
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/
sudo su
yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
So, any alternate solution to this (sudo su) or tell me how to prompt to root user in-order to install the mentioned rpm file.
Thanks
You could try using sudo -s or
sudo yum -y install /home/user1/oracle-instantclient12.2-basiclite-12.2.0.1.0-1.x86_64.rpm
The first option switches you to the root user, while the second allows you to run the command as root.
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/ && sudo -i yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
you'd have to add && (see this answer) in between the two commands and install with sudo yum:
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/ && sudo yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
sudo rpm -i /home/user1/oracle-instantclient12.2-basiclite.rpm should also work.
there is no other way to run two commands from a single command-line ...
are you sure the seconds half of the command-line even runs on the remote host? because I'd rather would expect it to be prefixed with send-command (in case running this from a local shell and not on the remote host). it is also not being indicated which Linux distribution you attempt to run the command against; adding the relevant RPM repository and then installing from there, might be the most reliable method of doing so.

sudo: command not found when I ssh into server

I am a newbie with server handling and Linux. I am trying to install composer on my server so that i can host my Laravel project onto it as mentioned in the tutorial in Ultimate Guide: Deploy Laravel 5.3 App on LEMP Stack. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:
-bash: sudo: command not found
I desperately need some deliberate help
Sudo is probably not installed or not in your path
check to see if you are root in this case sudo is not needed unless you are trying to impersonate another user. just run your command without sudo mv composer.phar /usr/local/bin/composer
See if sudo is your path by running which sudo or echo $PATH. If sudo is not in your path, your path variable might be broken. You can try testing this by executing a common location for sudo /usr/bin/sudo or running locate sudo | grep bin to attempt to find its location.
If you know that sudo was installed, or your path looks broken, try fixing your path. Check your distribution's env file (/etc/environment in ubuntu) to make sure that it is formatted correctly (script commands are illegal in this file)
If you are not root and you want to run a command with root prvileges then you must install sudo. But if you don't have sudo and you are not root then you can't install it. In this case I recommend switching to the root user with su
If you do not have the root password and you own the machine, you can reset the root password with a tutorial such as https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
After you manage to login as root install sudo with apt-get update; apt-get install sudosince you are using Ubuntu.
Verify the the name of your sudoers group with visudo and modify your sudoers file if you need to. https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
if you have an existing sudoers group or you create one you can add yourself to the group. For example if your sudoers group is called sudo run usermod -aG sudo myuser. The sudoers group by default in Ubuntu based Linux is sudo. A sudoers group entry looks like this: %sudo ALL=(ALL:ALL) ALL
If you are trying to impersonate another user and cannot install sudo, you can still use su if it is installed and you have permission / password for the other user.
e.g. su someuser
As suggested in this post, you may have to install sudo in your server.
To do that, log in as root with the following command: su -. Then install sudo with your package manager (if you're in Ubuntu: apt-get install sudo).
Then add your user to the sudo group: usermod -aG sudo <username>.
Finally type exit to log out of the root account and go back to your user.
try to install your sudo using by first logging in as a root(su - ) and then try to install **apt-get or yum sudo **. Make sure your path variable is set so that you would be able to get binary.
which sudo
echo $PATH

How to configure HHVM with Nginx compiled from source?

I installed Nginx 1.8 (compiled from source) on Debian 7:
cd /opt/
sudo wget http://nginx.org/download/nginx-1.8.0.tar.gz
sudo wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz
sudo tar -zxvf nginx-1.8.0.tar.gz
sudo tar -zxzf ngx_cache_purge-2.3.tar.gz
cd /opt/nginx-1.8.0/
sudo ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module --with-ipv6 --add-module=/tmp/ngx_cache_purge-2.3
sudo make && make install
sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
sudo wget -O init-deb.sh http://www.linode.com/docs/assets/1538-init-deb.sh
sudo mv init-deb.sh /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults
Than I start nginx with the following command:
sudo /etc/init.d/nginx start
And everything works fine until now.
The problem is when I try to install HHVM it doesn't work:
sudo wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
sudo echo deb http://dl.hhvm.com/debian wheezy main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm libgmp-dev libmemcached-dev
sudo update-rc.d hhvm defaults
And when I finally run:
sudo /usr/share/hhvm/install_fastcgi.sh
I get the following error:
Checking if Nginx is installed
Nginx not found
Any thoughts how I can install HHVM with Nginx compiled from source?
You're going to have to read the script and apply its patch manually. It's hardcoded to work with the distro-supplied nginx, and assumes that it's installed in that location -- since the deb we provide for Debian sticks a particular script in the nginx system configuration anyways. Your manually built nginx is in a different location; the script would have no way of knowing where to find it!
Here's the source for the install_fastcgi.sh -- the relevant bit is that it inserts a line after server_name to include hhvm.conf. You can find that hhvm.conf either here or it's probably already on your system at /etc/nginx/hhvm.conf.
BTW, the script really isn't that complicated. In general, a good way to figure out why something broke is to skim through it and see what it's doing :)

Cant apt-get remove or apt-get install | fopen permission denied

So out of no where I was unable to SSH into my headless linux box.
So I hooked up a screen and started tooling with it.
My server is still fully functional and the box seems in tact. I just wouldn't let me SSH in.
So I tried follow a few online tutorials on adding my IP to the SSH allow file but nothing seemed to work.
I kept getting
"Network Connect: Connection Refused"
when attempting to SSH in with putty.
So I decided to nuke the iptables and do
sudo apt-get remove --purge iptables
which resulted in a failure.
Something like this
"processing tables for mandb " "fopen permission denied"
So I tried doing
sudo apt-get install iptables
which it said the same fopen error.
End result is my server is up and running but I have no ssh capabilities into my box. On that note though I do still have an active samba connection. Take that for what its worth.
The fopen permission denied thing when doing apt-get or dpkg, is very often a sign that your manpages cache at /var/cache/man is owned by root:root instead of man:root. Try changing this with
chown -R man:root /var/cache/man
I followed the instructions below and the problem was solved. I hope it works for you.
sudo apt autoremove
sudo dpkg --configure -a
sudo apt-get update
sudo apt-get upgrade

Mongo: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145

When I try to run mongo in shell in ubuntu or open rockmongo I see this error:
couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
What's the reason? I tried to reinstall mongo but this didn't help. When I type sudo apt-get purge mongodb-10gen returned error is
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried this:
first remove line about mongo in /etc/apt/sources.list
run this commands:
sudo dpkg pr mongofb-10gen
sudo apt-get -f install
sudo apt-get upadte
sudo apt-get upgrade
then sudo apt-get purge mongodb-10gen is successful
at the end:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
add deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
in /etc/apt/sources.list
sudo apt-get update
sudo apt-get install mongodb-10gen
Then when I try to start mongo i saw the same error. :o
I assume that you followed the steps, outlined here.
Most probably you have a problem with mongo lock (or at least I had it once while installing on ubuntu). I solved it with the following commands:
sudo rm /var/lib/mongodb/mongod.lock
sudo service mongodb restart
P.S. I by myself recently experienced this problem when I was updating my amazon ec2 instance. I have not properly shut down mongo before doing this and this resulted in a problem with mongo lock.
Check your log file of mongodb. you will get to know the exact issue.
tail -f /var/log/mongodb/mongodb.log
The issue may because of "ERROR: Insufficient free space for journal files"
Increase your volume space that will fix your issue.
If you got this after a restart... Make sure that you have over 3GB+ of space free else Mongo Won't start.
even i had the same problem so i deleted the mongod lock file
sudo rm /var/lib/mongodb/mongod.lock
and the restart the server it worked , restarting by command below
sudo service mongodb restart
i got the solution by changing the owner of db directory to 'mongodb'
`sudo chown -R mongodb:mongodb /data/*`
then type 'mongo'
I guess the reason why you cannot connect to mongodb is the insufficient space in the drive on your computer.

Resources