all,
I met a very serious problem about my couchdb. I install the couchdb on a virtual machine, the system is ubuntu. The disk of this ubuntu is 10G, I asked the couchdb to catch data from twitter but I was not aware that the couchdb occupy all the disk storage in the system. To get some storage to run the couchdb, I have delete the system log. Then I type: sudo service couchdb start, it is start, but the http://127.0.0.1:9000/_utils/cannot open. All show in the following. Is anyone can help?? I am really anxious, because all my data is store only in this couchdb.
Documentation: https://help.ubuntu.com/
ubuntu#election2:~$ sudo service couchdb status
couchdb stop/waiting
ubuntu#election2:~$ sudo service couchdb start
couchdb start/running, process 1325
ubuntu#election2:~$ sudo service couchdb status
couchdb stop/waiting
ubuntu#election2:~$ sudo service couchdb stop
stop: Unknown instance:
ubuntu#election2:~$ sudo service couchdb restart
stop: Unknown instance:
couchdb start/running, process 1601
ubuntu#election2:~$
if this couchdb is difficult to repair, is anyone can tell me how can I remove the data in this couchdb wihtout starting it.There must be some tangible document. Thank you in advance!!!!
There are two CouchDB configuration files, default.ini and local.ini. My default.ini contains an entry in the [couchdb] section called database_dir which specifies where couch databases are stored. To find your configuration files run: couchdb -c. Your database .couch file will have the same name as you would have seen in the web interface. To remove the database, delete the file. If you want to keep the data, move it to a different location.
Shut down couch using: couchdb -d or sudo service couchdb stop depending on how you started it.
Once shut down you can copy / move the couchdb database directory to a location with more space. Change your database_dir setting to the new location and restart couchdb with: couchdb -b or sudo service couchdb start
The data is stored as a db file with the name of the CouchDB bucket in a dictionary that is specified in the local.ini as database_dir. Delete the file and the data is gone.
The running CouchDB can be killed by kill :pid. The :pid is a number (process id) and can be investigated with the command ps -ax | grep "couchdb"
Related
So, I was making an app that needs to use MongoDB transactions. But the Mongoose documentation told me that "MongoDB currently only supports transactions on replica sets, not standalone servers." So I thought I basically need to switch my Standalone MongoDB instance to Replica Set (whatever that means).
The MongoDB documentation gave me the instruction of how to do this with a few steps:
Shutdown the Standalone MongoDB instance
Restart the instance using the --replSet option
mongod --port 27017 --dbpath /var/lib/mongodb --replSet rs0 --bind_ip localhost
Connect the Mongo Shell
Call rs.initiate() inside the Shell
I'm stuck at step 2. All I know, when you want to start using MongoDB, you have to start its daemon first, using sudo systemctl start mongod, and then start using it by connecting your app. but that step told me to use mongod command to start the Mongod daemon, instead of systemctl. I tried the command but got the following error:
DBException in initAndListen, terminating","attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /var/lib/mongodb"}}
At first, I thought it was some kind of a privilege issue, so I ran it again with sudo but then it ended up destroying my entire database and prevented me from starting the MongoDB the "normal way" with giving me errors that I cannot remember.
I just reinstalled the whole MongoDB to get it back to work fine. Now I'm at the same place as yesterday, unable to convert to replica set, only now my entire database is gone. What do I do to enable it?
When running the mongod as a service, use /etc/monogd.conf to set the configuration. Note that the location or name of this file might have been changed in the mongod.service file in your system.
See replication options for how to set that in the file.
I am running mongod under Linux OS. I wanted to change my data directory from the default /var/lib/mongodb to another location say /nfs/mongodb.
When I run mongodb from shell(i.e. sudo /usr/bin/mongod --dbpath /nfs/mongodb) It works just fine.
Next step, I tried to run mongodb as a service(sudo service mongodb start)
I modified the file /etc/mongodb.conf and changed the line dppath=xxx to point to the new directory I created. When I run mongodb as service I get this error:
couldn't open file /nfs/mongodb/journal/j._0 for writing errno:1 Operation not permitted, terminating
Why the mongodb works in the shell and not as a service?
This is very likely because of permission issue.
When you run sudo mongod, it runs as root and can write to any directory.
In contrast, when running as a service, MongoDB typically runs as a limited-privilege user to prevent any security issue to escalate to root level access.
The solution is to chmod or chown the intended dbpath directory so that it's writeable by the service's user.
Note: you may want to check out the Production Notes for tips on running MongoDB optimally.
I am using CentOS 7.3 as a guest VM from Oracle VirtualBox. The host is Windows 7 and I have a physical USB stick (aka flash drive) to house the data directory for Postgres. I can use a USB stick as a mounted directory in Linux. I can read and write files to it.
I expect to be able to have Postgres databases on my USB stick. But I cannot get Postgres databases on my USB stick. I installed Postgres on the Linux VM.
To change the default data directory of Postgres, I followed these directions.
If you do not have time to go to the link, I simply installed Postgres with these two commands:
yum -y install postgresql-server postgresql-contrib
postgresql-setup initdb
then I ran these two commands:
mv /var/lib/pgsql/data/* /mnt/windows-share/data
ln -s /mnt/windows-share /var/lib/pgsql/data
Afterward I try to start the Postgres service, I get an error.
Here is the command that I try (as root):
systemctl start postgresql
Here is the error:
Job for postgresql.service failed because the control process exited
with error code. See "systemctl status postgresql.service" and
"journalctl -xe" for detail.
I tried systemctl status postgresql.service and I found this:
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled
vendorpreset: disabled)
Active: failed (Result exit-code)... Process ...
ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGDATA} (code=exited,
status=1/FAILURE)
... failed to start PostgreSQL... ...Unit postgresql.service...
...postgresql.service failed
I used journalctl -xe but that did not tell me anything meaningful.
To change the default data directory of Postgres, I tried this:
postgresql-setup initdb --pgdata=/mnt/windows-share/
But I got
failed to find PGDATA setting in --pgdata=/mnt/mar/data.service
How do I get Postgres installed with a customized data directory? I need it to be in a the "/mnt/" directory. I want to create all my databases on a USB stick.
To install Postgres on a customized location (e.g. home/postgres directory) follow these steps
install the required version of Postgres e.g. 13
create postgres directory in Home. and grant its access to posgres user
mkdir postgres
chown postgres:postgres postgres
usermod -m -d /home/postgres postgres
Move data directory to the new location as:
rsync -av /var/lib/pgsql/ /home/postgres/
update the location in postgres server as:
find / -name postgresql-9.5.service
vi /usr/lib/systemd/system/postgresql-9.5.service
update the data location in the file:
from the old location, e.g.
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/13/data/
to the new location, e.g.
# Location of database directory
Environment=PGDATA=/home/postgres/13/data/"
Stop postgres, reload deamon and start postgres
stop postgres
systemctl daemon-reload
start postgres
Done...
I' ve solved the same problem on CentOS 6
Maybe u can try it.
Add your disk
Check your disk is existing (in my case new disk is /dev/sdb1/)
# fdisk -l
Mount new disk
# mkdir /hdd2
# mount -t ext3 /dev/sdb1 /hdd2/
Auto mount hard disk by add new line:
# vi /etc/fstab
Add line: /dev/sdb1 /hdd2 ext3 defaults 0 0
Config postgres
# service postgresql stop
# vi /etc/sysconfig/pgsql/postgresql
Add line: PGDATA=/hdd2/data
# service postgresql start
Hope it useful to you!!
We would like to monitor our CouchDB installation using the default pid file method with MONIT, however although couchdb is working fine there is no pid file generated under /var/run/couchdb, there is only a couch.uri file.
Permissions on /var/run/couchdb are good (couch:couch) and service couchdb stop and start work fine, although for MONIT to stop/start we would need the /etc/init.d/couchdb start/stop option (which again isn't present).
For info we just installed using apt-get install couchdb on Ubuntu 14.04.
Any advice appreciated.
Best regards
RichBos
I have done this with an older version (1.3) of CouchDB installed from source. Please check if this is working for you:
check process couchdb with pidfile
/usr/local/var/run/couchdb/couchdb.pid
group database
start program = "/etc/init.d/couchdb start -u couchdb"
stop program = "/etc/init.d/couchdb stop -u couchdb"
if failed host 127.0.0.1 port 5984 then restart
if cpu is greater than 40% for 2 cycles then alert
if cpu > 60% for 5 cycles then restart
if 10 restarts within 10 cycles then timeout
If you have installed it via a package manager, you will most likely find the pid in /var/run/couchdb/couchdb.pid
The place of the pid file did not change since 1.3. So chances are good, that it's working for you.
I've using the standard init.d script that comes with CouchDB. I'm using it on Ubuntu.
On server restart, this is printed on local console:
* Starting database server couchdb [ OK ]
So, it's assumed that CouchDB was started, but not. CouchDB is not started.
I must log into the server and start service with service couchdb start, then CouchDB was started correctly.
Any idea in how to debug why CouchDB is not started on reboot ? Already done the update-rc.d command.