Sunday, December 4, 2016

Ubuntu "No space left on device" for /home, df shows 100% full, ds shows much, much less








On an Ubuntu 12.04 server, normal users can no longer create or add to files in /home, encountering a "No space left on device" error.



The /home directory has a capacity of 1.7 terabytes and as far as I can tell is nowhere near full in terms of actual data stored or inodes used.



df -h shows:



Filesystem      Size  Used Avail Use% Mounted on

/dev/md2 1.0T 18G 955G 2% /
udev 7.7G 4.0K 7.7G 1% /dev
tmpfs 3.1G 320K 3.1G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 7.7G 0 7.7G 0% /run/shm
cgroup 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/md3 1.7T 1.7T 0 100% /home
/dev/md1 496M 45M 426M 10% /boot



/home indeed looks rather full.



du -hs /home suggests otherwise:



1.4G    /home


There appears no inode issue - df -i:



Filesystem        Inodes  IUsed     IFree IUse% Mounted on

/dev/md2 67108864 75334 67033530 1% /
udev 2013497 527 2012970 1% /dev
tmpfs 2015816 440 2015376 1% /run
none 2015816 2 2015814 1% /run/lock
none 2015816 1 2015815 1% /run/shm
cgroup 2015816 9 2015807 1% /sys/fs/cgroup
/dev/md3 113909760 105981 113803779 1% /home
/dev/md1 131072 239 130833 1% /boot



I recently deleted a many gigabytes of application cache and log data from /home, however this was in the tens of gigabytes at best and nowhere near the capcity of /home.



Update 1:



du -hs --apparent-size /home
1.2G /home
du -hs /home
1.4G /home



What might be going on here?

ssh - How to get full control of umask/PAM/permissions?



// Updated Feb 8 - Outstanding issues in brief:




  • How to umask directories differently from files?

  • How to umask on Nautilus copy/paste?

  • How to set umask for SSHFS?




OUR SITUATION



Several people from our company log in to a server and upload files. They all need to be able
to upload and overwrite the same files. They have different usernames, but are all part of the
same group. However, this is an internet server, so the "other" users should have (in general) just
read-only access. So what I want to have is these standard permissions:



files: 664
directories: 771



My goal is that all users do not need to worry about permissions. The server should be configured in such

a way that these permissions apply to all files and directories, newly created, copied, or over-written. Only
when we need some special permissions we'd manually change this.



We upload files to the server by SFTP-ing in Nautilus, by mounting the server using sshfs and accessing it in Nautilus
as if it were a local folder, and by SCP-ing in the command line. That basically covers our situation and what we aim
to do.



Now, I have read many things about the beautiful umask functionality. From what I understand umask (together with PAM) should allow me
to do exactly what I want: set standard permissions for new files and directories. However, after many many hours of reading and trial-and-error,
I still do not get this to work. I get many unexpected results. I really like to get a solid grasp of umask and have many question unanswered. I will post these questions below,

together with my findings and an explanation of my trials that led to these questions. Given that many things appear to go wrong, I think that
I am doing several things wrong. So therefore, there are many questions.



NOTE: I am using Ubuntu 9.10 and therefore can not change the sshd_config to set the umask for the SFTP server. Installed SSH OpenSSH_5.1p1 Debian-6ubuntu2 < required OpenSSH 5.4p1. So here go the questions.



1. DO I NEED TO RESTART FOR PAM CHANGS TO TAKE EFFECT?



Let's start with this. There were so many files involved and I was unable to figure out what does and what does not affect things, also because I did not
know whether or not I have to restart the whole system for PAM changes to take effect. I did do so after not seeing the expected results, but is this really
necessary? Or can I just log out from the server and log back in, and should new PAM policies be effective? Or is there some 'PAM' program to reload?




2. IS THERE ONE SINGLE FILE TO CHANGE THAT AFFECTS ALL USERS FOR ALL SESSIONS?



So I ended up changing MANY files, as I read MANY different things. I ended up setting the umask in the following files:



~/.profile -> umask=0002
~/.bashrc -> umask=0002
/etc/profile -> umask=0002
/etc/pam.d/common-session -> umask=0002
/etc/pam.d/sshd -> umask=0002

/etc/pam.d/login -> umask=0002


I want this change to apply to all users, so some sort of system-wide change would be best. Can it be achieved?



3. AFTER ALL, THIS UMASK THING, DOES IT WORK?



So after changing umask to 0002 at every possible place, I run tests.



------------SCP-----------




TEST 1:



scp testfile (which has 777 permissions for testing purposes) server:/home/
testfile 100% 4 0.0KB/s 00:00


Let's check permissions:



user@server:/home$ ls -l

total 4
-rwx--x--x 1 user uploaders 4 2011-02-05 17:59 testfile (711)


UPDATE: fixed by ONLY setting umask in pam.d/common-sessions (see comments)



---------SSH------------



TEST 2:




ssh server
user@server:/home$ touch anotherfile
user@server:/home$ ls -l
total 4
-rw-rw-r-- 1 user uploaders 0 2011-02-05 18:03 anotherfile (664)


--------SFTP-----------



Nautilus: sftp://server/home/




Copy and paste newfile from client to server (777 on client)



TEST 3:



user@server:/home$ ls -l
total 4
-rwxrwxrwx 1 user uploaders 3 2011-02-05 18:05 newfile (777)



Create a new file through Nautilus. Check file permissions in terminal:



TEST 4:



user@server:/home$ ls -l
total 4
-rw------- 1 user uploaders 0 2011-02-05 18:06 newfile (600)


I mean... WHAT just happened here?! We should get 644 every single time. Instead I get 711, 777, 600, and then once 644. And the 644 is only achieved

when creating a new, blank file through SSH, which is the least probable scenario.



So I am asking, does umask/pam work after all?



UPDATE: fixed test 4 by ONLY setting umask in pam.d/common-sessions (see comments)



4. SO WHAT DOES IT MEAN TO UMASK SSHFS?



Sometimes we mount a server locally, using sshfs. Very useful. But again, we have permissions issues.




Here is how we mount:



sshfs -o idmap=user -o umask=0113 user@server:/home/ /mnt


NOTE: we use umask = 113 because apparently, sshfs starts from 777 instead of 666, so with 113 we get 664 which is the desired file permission.



But what now happens is that we see all files and directories as if they are 664. We browse in Nautilus to /mnt and:





  • Right click -> New File (newfile) --- TEST 5

  • Right click -> New Folder (newfolder) --- TEST 6

  • Copy and paste a 777 file from our local client --- TEST 7



So let's check on the command line:



user@client:/mnt$ ls -l
total 8
-rw-rw-r-- 1 user 1007 3 Feb 5 18:05 copyfile (664)

-rw-rw-r-- 1 user 1007 0 Feb 5 18:15 newfile (664)
drw-rw-r-- 1 user 1007 4096 Feb 5 18:15 newfolder (664)


But hey, let's check this same folder on the server-side:



user@server:/home$ ls -l
total 8
-rwxrwxrwx 1 user uploaders 3 2011-02-05 18:05 copyfile (777)
-rw------- 1 user uploaders 0 2011-02-05 18:15 newfile (600)

drwx--x--x 2 user uploaders 4096 2011-02-05 18:15 newfolder (711)


What?! The REAL file permissions are very different from what we see in Nautilus. So does this umask on sshfs just create a 'filter' that shows unreal
file permissions? And I tried to open a file from another user but the same group that had real 600 permissions but 644 'fake' permissions, and I could
still not read this, so what good is this filter??



5. UMASK IS ALL ABOUT FILES. BUT WHAT ABOUT DIRECTORIES?



From my tests I can see that the umask that is being applied also somehow influences the directory permissions. However, I want my files to be 664 (002)

and my directories to be 771 (006). So is it possible to have a different umask for directories?



6. PERHAPS UMASK/PAM IS REALLY COOL, BUT UBUNTU IS JUST BUGGY?



On the one hand, I have read topics of people that have had success with PAM/UMASK and Ubuntu. On the other hand,
I have found many older and newer bugs regarding umask/PAM/fuse on Ubuntu:





So I do not know what to believe anymore. Should I just give up? Would ACL solve all my problems?

Or do I have again problems using Ubuntu?




One word of caution with backups using
tar. Red Hat /Centos distributions
support acls in the tar program but
Ubuntu does not support acls when
backing up. This means that all acls
will be lost when you create a backup.





I am very willing to upgrade to Ubuntu 10.04 if that would solve my problems too, but first I want to understand what is happening.


Answer



Many things could be going on here.



First thoughts:




  • yes, pam.d changes take effect immediately

  • /etc/pam.d/common-session is the best place to set a default umask


  • any pam.d umask would get overridden by any entry in .bashrc,
    but .bashrc only gets read under certain circumstances (interactive, non-login shell)

  • testfile (711) is very strange


    • how is /home mounted, and are you using ACLs?
      (e.g. what do ls -ld /home and getfacl /home print?)

    • did testfile already exist before you did the copy,
      because scp won't change the permissions on a file that already existed (unless you use the -p flag)


  • Nautilus is known to create files a different way, not sure why, or what the rules are

  • umask=0113 will probably cause problems


  • are the server and client running the same operating system?
    for example, if the client has ACLs enabled, or is Cygwin, the behavior can be different

  • the best way to force sane permissions is to use default ACLs, exactly because,
    as you discovered, umask can be overridden by the user in .bashrc and .bash_profile.



Update:




  • umask=0113 for sshfs is wrong.



    1. Try mounting without specifying a umask

    2. Create a new file inside the mount point using touch.

    3. You should see it only gets e.g. -rw-r--r--, without x bits

    4. By masking out x bits, you might break directories
      and compilers may be unable to create executable files properly




Workaround:




If we can't think of anything better, you could either use fam or gamin to watch for new files being created and fix the permissions on them, or even just a script that runs periodically and sets the permissions on all files.


How to create a CNAME for a domain's root name

I'd like to set a domain's root name to a CNAME instead of the usual A record.



Here's a perfect example of what I'm trying to do:



dig lrnskls.com



Notice the answer section:



;; ANSWER SECTION:

lrnskls.com. 300 IN CNAME partner.adjix.com.

partner.adjix.com. 300 IN A 67.121.212.61



The reason I'm trying to do this is so I can point a domain's root name, via a CNAME alias, to Amazon's S3. Using an A record doesn't work because S3's IPs change every few minutes for load balancing purposes.



PS - This seems to be legal under section 3.6.2 of RFC 1034 (note the USC-ISIC.ARPA example):
http://www.faqs.org/rfcs/rfc1034.html

domain name system - Redirect prefixed site named in DNS Forward Lookup Zones in Windows DNS Server

I have named a domain internally in my forward lookup zone in windows dns for my internal network. There is one prefix that i need for it to look up using the named external DNS (like google DNS 8.8.8.8). I host many intranet sites/locations, but i dont host our public web server in house. The issue is that we use a CDN, so the IP is never static, and I cant define it with a A record.



For Example:



Forward Lookup Zone Defined for: Contoso.com
department1.contoso.com = 192.168.x.5  
department2.contoso.com = 192.168.x.6  
www.contoso.com = [dynamic ip that needs to be looked up by 8.8.8.8]
contoso.com = [dynamic ip that needs to be looked up by 8.8.8.8]

I am stumped.
If i dont define www at all, my dns lookup comes back without an ip

Saturday, December 3, 2016

linux - Why is my post-commit Apache Subversion hook failing?

So I am trying to get a post-commit hook working on my Apache Subversion server, specifically I'm trying to send email to my Google account as described on this link.



After setting the permissions for the script and the working copy to the same user and read/write access it started causing MERGE errors when users tried to commit.



After some reading I found out that it was because of the post-commit hook not working and found out that by typing



svn - ./post-commit commit  ../ 250 mailer.conf



I get this error:



> annerajb@annerajb-desktop:~/Desktop/TotEM_SVN/hooks$ env - ./post-commit.test commit ../ 250

/var/lib/python-support/python2.6/svn/fs.py:27: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.

import sys as _sys, os as _os, popen2 as _popen2, tempfile as _tempfile

Traceback (most recent call last):


File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 1351, in
svn.core.run_app(main, cmd, config_fname, repos_dir, sys.argv[3:3+expected_args])

File "/var/lib/python-support/python2.6/svn/core.py", line 288, in run_app
return apply(func, (application_pool,) + args, kw)

File "/usr/share/subversion/hook-scripts/mailer/mailer.py", line 80, in main
revision = int(cmd_args[0])

ValueError: invalid literal for int() with base 10: ''


./post-commit.test: 5: ../: Permission denied


I am not sure why cmd_args[0] is empty if I am passing it a value.



#!/bin/sh
REPOS="$1"
REV="$2"
/usr/share/subversion/hook-scripts/mailer/mailer.py commit "$REPOS" \

"$REV" /usr/share/subversion/hook-scripts/mailer/mailer.conf

Friday, December 2, 2016

memory - RAM compatibility for the HP Proliant DL320e Gen8 v2

I've got a handful of servers to assemble. I've got a few HP Proliant DL320e Gen8 V2 servers with the 2 LFF hard drive slots and 4 RAM slots.



It came with a stick of PC3 12800E 11-13-E3 RAM, and I'm not sure what those last couple of things are supposed to designate, if anything.




I checked the PDF and it doesn't seem to detail whether or not I need to use HPE SmartMemory or I can use any old UDIMM sticks, just that it supports up to 32GB for 8GBx4 config.



Can I use any kind of RAM? The only hard requirement is that it seems to need ECC. Can it be any brand? I'm not sure, and I can't seem to find a solid answer in the product's online-available documentation in its PDF or online memory configurator. Near the end of the PDF it shows some HPE-provided RAM options that are all ECC. The wording for rules and guidelines obfuscates this more without detailing if using their specific memory is a guideline or a rule.



I need to know if using HP/HPE SmartMemory is an actual hard requirement, or just a best practice. I appreciate your advice, but I'm looking for an answer, not an opinion.




Standard Memory Plus Optional Memory Up to 32 GB memory is available with the optional installation of 4 x 8GB PC3-12800E UDIMM ECC DDR3 UDIMM Memory kits, operating at 1600MHz when fully populated at 2 DIMMs per Channel in 4 slots. NOTE: The below chart does not represent all possible memory configurations. NOTE: For best performance, it is recommended that customer installs memory in identical pairs



General Memory Population Rules and Guidelines:




• The HPE ProLiant DL320e Gen8v2Server has four memory slots



• There are two channels per server with two DIMM slot per channel



• Memory channel A consists of the two (2) DIMMs that are closest to the
processor
• Memory channel B consists of the two (2) DIMMs that are furthest from the
processor




• Different types of processors have different types of memory support.



• Support for single/dual-rank 1333/1600 MT/s ECC UDIMM (unbuffered DIMMS)



• The server supports up to 32 GB (4 x 8-GB) for Unbuffered DIMMs



• No support for RDIMMs; Non-ECC UDIMMs



• Do not install DIMMs if the processor is not installed




• Populate DIMMs from heaviest load (double-rank) to lightest load (single-rank)



Always use HPE qualified DIMM


Thursday, December 1, 2016

iis 7.5 - How many simultaneous requests can be handled by a medium class server on the average?




I have bought a PRIMERGY TX100 S1 Server with a trial version of Windows Server 2008 R2 Web Edition.



My internet connection with a static IP is very very fast (about 50 mega bit per second) for both downloading and uploading.




My site serves text based contents only, no streaming.



How many simultaneous requests can be handled by a medium class server on the average?
Can it handle at least 1000 simultaneous requests?



Edit 1



For those have experiences in this field, they might have a rough prediction.


Answer



Let's throw some numbers around:





  • 1,000 at a time should be no problem at all, in general.

  • 10,000 at a time will work but you have to know your entire setup intimately and never block any of the CPU's waiting for any I/O, as well as not be limited by your bandwidth. (assuming 10KB per http request and response @10,000 requests per second, that's 97 MB per second)



The rest of this answer is just some discussion to just point you in some direction



I've thought of this question a few times, and because you are looking for ball park figures then this might help you:




Looking at front end dedicated servers that handle a specific task (but talk to other services to do work for them, like the google search infrastructure which would call on many other machines to get pieces of information), then your front end machines that handle the actual client sockets should be able to handle about 15,000 users concurrently (ballpark, assuming binary protocol) because if you look at how many players play per server on WOW, depending on the strength of the machine, they have from 6-30,000 users per "world" - which I assume is one machine supported by other services at the back. I can't find the page now that lists servers and players per server. This isn't a web site though, but you are looking for ballpark information and this might lead you to the right place.



Have a look at wikipedia's server stats if you are interested in some architecture numbers - http://stats.wikimedia.org they show every detail you might be interested in regarding http requests.



Looking at IIS stats, take this site for example, stackoverflow.com - they were doing 16 million hits per month on 2 web machines and I'm sure more than 1000 people must have been on it at a time. There's an article on HighScalability.com about stackoverflow's servers. Update -- now at 95+ million per month.


linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...