Rackspace cloud server – create swap file

Most Rackspace cloud servers now have swap off by default and while it’s not a good idea to use it a lot, you also don’t want ugly stuff to happen once you get close to the physical memory limit, so in some cases, it’s good to allow for some swap. You can set a memory alert so you know how often you are using it and make changes as required.

see: http://www.rackspace.com/knowledge_center/article/create-a-linux-swap-file

sudo fallocate -l 1G /mnt/1GB.swap
# OR #
sudo dd if=/dev/zero of=/mnt/1GB.swap bs=1024 count=1048576
sudo mkswap /mnt/1GB.swap
sudo swapon /mnt/1GB.swap
# Add this line to the end of /etc/fstab to make the change permanent:
sudo echo '/mnt/1GB.swap  none  swap  sw 0  0' >> /etc/fstab
# To change the swappiness value edit /etc/sysctl.conf and add/EDIT the following line.
# vm.swappiness=10
# Check that the swap file was created.
sudo swapon -s
# Reboot the server to ensure that the changes go into effect:
/sbin/shutdown -r now

Add local Node JS module to CLI path

To run a local Node module as if it was installed globally, add this to your login profile (or set up a script to run/reset as needed):

export PATH=$PATH:./node_modules/.bin

Linux memory usage command

cat /proc/meminfo

particularly useful in cases where you can’t use top.

more see: cyberciti.biz/faq/ram-size-linux/

Docker: fix for “Cannot connect to the Docker daemon”

Mac OS X (or similar VM’d docker environment) if your docker command stops working, check that it indeed works inside boot2docker, and if so, then run:

sudo route -nv add -net 192.168.59 -interface vboxnet1

Docker search retrieve tag info

Docker CLI doesn’t show all tags for images, you can use the Docker API to search and retrieve tag names, then use that tag to pull the specific image.

curl https://registry.hub.docker.com//v1/repositories/centos/tags | python -mjson.tool

CentOS 7 / RHEL firewalld settings

CentOS 7 has adopted firelwalld by default over the previous iptables, which will require some new steps to configure your firewall:

# new CentOS/RHEL 7 Firewall: 
	(see https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html )
# create a new service e.g. for webmin:
$ cat /etc/firewalld/services/webmin.xml 
<?xml version="1.0" encoding="utf-8"?>
  <description>Server admin service. Do not leave running.</description>
  <port protocol="tcp" port="10000"/>
# add service to zone:
nano /etc/firewalld/zones/public.xml 
# OR
$ firewall-cmd --permanent --zone=public --add-service=webmin
# reload to add:
$ firewall-cmd --reload
# check:
$ firewall-cmd --zone=public --list-all
## apache / httpd:
$ firewall-cmd --permanent --add-service=http
$ firewall-cmd --permanent --add-service=https
$ systemctl restart firewalld

## more info: see:



« Previous Entries