Monday, October 8, 2012

couldn't connect to server 127.0.0.1 shell/mongo.js

Hello,

So I've decided to learn a new database application in an effort to further pad my resume.  And with most things in Linux at the very beginning I get stuck; but it only took 2 minutes for me to fix the issue.

First my setup:

Lenovo Thinkpad
Linux Distro : Fuduntu
Kernel: 3.4.11-1.fu2012.x86_64

k,

So when you try to enter the MongoDB shell you're immediately hit with the error:

>mongo
MongoDB shell version: 2.2.0
connecting to: test
Monday Oct 8 2012 18:56:59 Error: couldn't connect to server 127.0.0.1:27017 /src/mongo/shell/ mongo.js:91
exception: connection failed

Ok, there's a couple things you should try to do:

1: Try to start mongo

If this doesn't work and you get the error below try step 2:
>/etc/init.d/mongo start
/etc/init.d/mongod: line 69 ulimit: open files: cannot modify limit: Operation not permitted
Starting mongod: runuser:  using restricted shell /bin/false
runuser: cannot set groups: operation not permitted

2:  > sudo rm /var/lib/mongo/mongod.lock
then
>  sudo -u mongod mongod -f /etc/mongod.conf --repair

You may get the following error:

can't open [ /var/log/mongo/mongod.log] for log file: errno:2 No such file or directory

I checked and the directory and file didn't exist so I created both

> mkdir /var/log/mongo
>touch /var/log/mongo/mongod.log

then change ownership of the log file to the mongod user
>chown mongod.mongod /var/log/mongo/mongod.log

then run the mongo repair again:

> sudo -u mongod mongod -f /etc/mongod.conf --repair

If it worked correctly you'll get the following:

forked process: 6956
all output going to: /var/log/mongo/mongod.log
child process started sucessfully, parent exiting

When you check MongoDB's status it should be running now:

> /etc/init.d/mongod status

mongod (pid 67584) is running ...

Then run the Mongo shell

> mongo
MongoDB shell version 2.2.0
connecting to test
>

I hope this helps someone!

Sunday, April 22, 2012

Broken Yum (temporary fix)

I went to update my system (Fedora 16) and apparently Yum is broken due to 404 errors for the repository.  See below:

[thenderson@ENAIC yum.repos.d]$ yum update


* Connected to rpm.aegisco.com (107.21.192.53) port 80 (#0)
> GET /aegisco/rhel/16/x86_64/repodata/repomd.xml HTTP/1.1
User-Agent: urlgrabber/3.9.1 yum/3.4.3
Host: rpm.aegisco.com
Accept: */*

* The requested URL returned error: 404
* Closing connection #0
* HTTP response code said error
2012-04-22 15:37:08,046 exception: [Errno 14] HTTP Error 404 - Not Found : http://rpm.aegisco.com/aegisco/rhel/16/x86_64/repodata/repomd.xml
INFO:urlgrabber:exception: [Errno 14] HTTP Error 404 - Not Found : http://rpm.aegisco.com/aegisco/rhel/16/x86_64/repodata/repomd.xml
2012-04-22 15:37:08,046 calling callback: (<bound method YumBaseCli.failureReport of <cli.YumBaseCli object at 0x2201e10>>, (), {})
INFO:urlgrabber:calling callback: (<bound method YumBaseCli.failureReport of <cli.YumBaseCli object at 0x2201e10>>, (), {})
http://rpm.aegisco.com/aegisco/rhel/16/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found : http://rpm.aegisco.com/aegisco/rhel/16/x86_64/repodata/repomd.xml
Trying other mirror.
2012-04-22 15:37:08,047 MIRROR: failed
INFO:urlgrabber:MIRROR: failed
2012-04-22 15:37:08,047 GR   mirrors: [] 0
INFO:urlgrabber:GR   mirrors: [] 0
2012-04-22 15:37:08,047 MAIN mirrors: [http://rpm.aegisco.com/aegisco/rhel/16/x86_64/] 0
INFO:urlgrabber:MAIN mirrors: [http://rpm.aegisco.com/aegisco/rhel/16/x86_64/] 0
Error: failure: repodata/repomd.xml from aegisco: [Errno 256] No more mirrors to try.

From what I can tell this error came about after adding a repository to my /etc/yum.repos.d directory.  The exact repo was:

http://rpm.aegisco.com/aegisco/rhel/16/x86_64/repodata/repomd.xml

So I removed it from yum.repos.d:


[meeky@ENAIC ~]$ cd /etc/yum.repos.d/
[meeky@ENAIC yum.repos.d]$ ls
aegisco.repo  dropbox.repo  fedora.repo  fedora-updates.repo  fedora-updates-testing.repo  google-chrome.repo  rbel6.repo
[meeky@ENAIC yum.repos.d]$ sudo mv aegisco.repo /tmp
[thenderson@ENAIC yum.repos.d]$ yum check-update

If this works correctly you should get a bunch of update notices (if you haven't updated in a while like me)

selinux-policy.noarch                                                   3.10.0-84.fc16                                                        updates
selinux-policy-targeted.noarch                                          3.10.0-84.fc16                                                        updates
shotwell.x86_64                                                         0.10.1-4.fc16                                                         updates
spice-glib.x86_64                                                       0.11-4.fc16                                                           updates
spice-gtk3.x86_64                                                       0.11-4.fc16                                                           updates
system-config-users.noarch                                              1.2.114-1.fc16                                                        updates
tzdata.noarch                                                           2012c-1.fc16                                                          updates
usbredir.x86_64                                                         0.4.3-1.fc16                                                          updates
virtuoso-opensource.x86_64                                              1:6.1.5-2.fc16                                                        updates
[message truncated]


Saturday, April 7, 2012

Fedora 16 :: Adding A User to the Sudoers file

Fedora 16 installs without giving the default user sudo rights...unlike some other Linux distributions, and I needed admin rights to update my system.  I did a little Google search and came across www.mjmwired.net's tutorial for adding a user to the sudoer's file

The tutorial esentially states to change the sudoers fileto write permissions that you can echo  '"user ALL=(ALL) ALL and appened it into the /etc/sudoers file. 

 [thenderson@localhost Documents]$ ls -l /etc/sudoers
-r--r-----. 1 root root 3338 Nov 30  2010 /etc/sudoers
[root@localhost Documents]$ chmod +w /etc/sudoers

[root@localhost Documents]$
[root@localhost Documents]$ echo "user ALL=(ALL) ALL >> /etc/sudoers
[user@localhost Documents]$
[root@localhost Documents]$ su user 
[user@localhost Documents]$ sudo ls /root
[user@localhost Documents]$ Operation not permitted  



Unfortunately this didn't work for me.  As you can see the error "Operation not permitted." So I figured I"d write about a little blurb on how I got this to work in Fedora 16.

Using 'visudo' worked for me.  Here's how simply this was done:

#visudo

** If you need a VI editor cheatsheet click here

At the bottom of the sudoers file enter in your username in the following format

user ALL=(ALL) ALL

 Let's explain this full line

user - pretty self explaintory, this is your username
1st ALL - User can execute as all users
(ALL) - User can act as any user
3d ALL - user can run all commands

Append this line to bottom of /etc/sudoers file users ALL=(ALL) ALL then save the file.  That's it!  Now test it with something like this: 

[user@localhost ~]$ sudo ls /root
anaconda-ks.cfg
[user@localhost ~]$ 


If you get the following, you've done something wrong, so go back and check your syntax:

[user@localhost ~]$ ls /root
ls: cannot open directory /root: Permission denied


Any questions concerns, or critizism let me know.

Friday, March 9, 2012

SSH Tips

Using Compression

SSH supports compression which is useful if you are connection to a remote server at Starbucks <--shameless plug

#ssh -C user@remote_host -p <portnumber>
(this will temporarily set compression on your SSH connection)

To permanently setup SSH compression requires a little work on your remote server and your local computer. You will need to add a 'Compression yes' line in your /etc/ssh/sshd_config file on the remote server and a 'Compression yes' line in your local config file.  The local file should be located in either ~/.ssh/config if user configuration files are enabled, otherwise add the line to the system-wide config file located at /etc/ssh/ssh_config.

Here's a screenshot of my local machine.  I'm running Linux Mint


Here's a screenshot of my remote host:



I'll add to this blog post later with a few more of my favorite ssh tips/tricks to included Sshfs - mounting a remote file system via ssh which is handy for ...mounting a remote file system, and SSH Tunneling.  If you have any questions or comments please leave them below.