Check containers
# docker ps -a
Connect to a container
# docker start <ID> # docker attach <ID>
Exit from a container
-> type 'exit'
Remove all of Docker containers:
docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)
Check containers
# docker ps -a
Connect to a container
# docker start <ID> # docker attach <ID>
Exit from a container
-> type 'exit'
Remove all of Docker containers:
docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)
DNS queries can be an issue on Cloud infrastructure, where SaaS are generally configured using FQDN instead of IP. This means that every time your application needs MySQL or Redis or any of the Platform/Software as a service, a DNS query will be issued.
Sometimes this could hammer the local DNS and service providers might block your DNS traffic.
To minimise this, you could use nscd to cache the DNS queries and reduce the traffic to the local DNS servers.
>> Test if port 53 has been blocked tcpdump -vvv -s 0 -l -n port 53 >> Check what is currently cached nscd -g (and check hosts cache) >> Configuration file grep -v "^#" /etc/nscd.conf (leaving only 'hosts' details) server-user nscd debug-level 0 paranoia no enable-cache hosts yes positive-time-to-live hosts 3600 negative-time-to-live hosts 20 suggested-size hosts 211 check-files hosts yes persistent hosts yes shared hosts yes max-db-size hosts 33554432
/etc/apt/sources.list #Infinality Fonts deb http://ppa.launchpad.net/no1wantdthisname/ppa/ubuntu saucy main apt-get install fontconfig-infinality cd /etc/fonts/infinality/ bash infctl.sh setstyle chose 3 (i.e. linux). In /etc/profile.d/infinality-settings.sh --> search for “USE_STYLE” or scroll (around line 710) till you see the option to set the style => USE_STYLE=”UBUNTU” Settings -> Appearance. Tick the checkbox to Enable anti-aliasing Set Sub-pixel order to RGB Set Hinting to Slight ====================================== Personally installed before also: cabextract fonts-liberation ttf-mscorefonts-installer ====================================== Other fonts: 1) Install pretty fonts (you'll need non-free for mscorefonts): apt-get install ttf-dejavu ttf-liberation ttf-mscorefonts-installer xfonts-terminus 2) dpkg-reconfigure fontconfig-config, select Autohinter, Automatic and No 3) dpkg-reconfigure fontconfig 4) Restart Xorg 5) Gnome-specific (these are largely personal preferences): System -> Preferences -> Appearances -> Fonts: Enable 'Best Shapes', Details -> Dots per Inch: 110, Smoothing -> Grayscale ======================================
apt-get purge nova-client apt-get update && apt-get upgrade Used this script to re-install nova-agent: https://github.com/rackerlabs/openstack-guest-agents-unix/blob/master/tools/nova-agent-builder.sh >> extract the tar and ./install.sh sed '1i### BEGIN INIT INFO\n# Provides: Nova-Agent\n# Required-Start: $remote_fs $syslog\n# Required-Stop: $remote_fs $syslog\n# Default-Start: 2 3 4 5\n# Default-Stop: 0 1 6\n# Short-Description: Start daemon at boot time\n# Description: Enable service provided by daemon.\n### END INIT INFO\n' /usr/share/nova-agent/1.39.1/etc/generic/nova-agent > /usr/share/nova-agent/1.39.1/etc/generic/nova-agent.lsb cp /usr/share/nova-agent/1.39.1/etc/generic/nova-agent.lsb /etc/init.d/nova-agent chmod +x /etc/init.d/nova-agent service xe-linux-distribution stop service xe-linux-distribution start service nova-agent start # ps aux | grep nova root 7874 0.0 0.7 143984 7464 ? Ssl 09:02 0:00 /usr/sbin/nova-agent -q -p /var/run/nova-agent.pid -o /var/log/nova-agent.log -l debug /usr/share/nova-agent/nova-agent.py root 7890 0.0 0.0 11980 928 pts/0 S+ 09:03 0:00 grep --color=auto nova Sources: http://www.syntheticworks.com/rackspace-cloud/linux-rackspace-cloud/all-about-nova-agent-linux/ https://github.com/rackerlabs/openstack-guest-agents-unix/blob/master/tools/nova-agent-builder.sh http://bootrackspacecom.readthedocs.org/en/latest/nova_agent/
There is an agent called “nova-agent” which runs on all Rackspace cloud virtualised servers. This agent handles all communication between the hypervisor and guest OS, and is used for decloning.
Because it is used during decloning, it owns the /etc/hosts file and many files related to DNS and networking (/etc/resolv.conf , /etc/sysconfig/network-scripts/ifcfg-eth0 ,etc)
It is unlikely, but possible, that the host reboot triggered nova-agent to reset your hosts file.
To prevent nova-agent from overwriting your files, you can change the attributes of the file using the following command:
# chattr +i /etc/hosts
This will make the file unwriteable even to root! To remove this restriction, use the following:
# chattr -i /etc/hosts
>> set your variables: TOKEN="" REGION="lon" DDI="" < this is the account number >> Generate a list of backup agents curl -sH "X-Auth-Token: $TOKEN" -H "Content-type: application/json" -X GET https://$REGION.backup.api.rackspacecloud.com/v1.0/$DDI/user/agents | python -m json.tool | egrep "MachineName|MachineAgentId" | awk -F":" '{print $2}' | sed 's/ //g' | sed '{N;s/\n//}' > list.txt >> Manually remove WANTED backup agents (leave only the ones you want to remove): vim list.txt >> Generate remove list awk -F, '{print $1}' list.txt > remove.txt >> generate the exec file to review for AGENTID in `cat remove.txt`; do echo curl -sH \"X-Auth-Token: $TOKEN\" -H \"Content-type: application/json\" -X POST https://$REGION.backup.api.rackspacecloud.com/v1.0/$DDI/agent/delete -d \'{\"MachineAgentId\": $AGENTID}\' ; done >> exec_me >> exec the API calls /bin/bash exec_me
If your php application requires sessions and it’s hosted on a scaled high available infrastructure, it’s required to have these sessions stored on a decentralised and HA platform as well, in order to avoid to rely on session persistent options on the load balancer or another Cloud Server.
Redis as a Service is a nice fit for this purpose.
Here an example using Rackspace Object Rocket http://www.rackspace.co.uk/objectrocket/redis
To achieve this it’s required to install the right package.
In Centos/RHEL, there is the IUS package available:
yum install php56u-pecl-redis
After that, the php.ini should be changed like this:
session.save_handler = redis session.save_path = "tcp://REDISOBJECTROCKETFQDN:PORT?auth=REDISPASSWORD"
To increase performance and reduce the “noise” for repetitive DNS queries (especially in case of SaaS which uses FQDN instead of an IP) it is also recommended to install nscd to cache the DNS queries.
USERNAME=<username> APIKEY=<api_key> curl -s -d \ '{ "auth": { "RAX-KSKEY:apiKeyCredentials": { "username": "$USERNAME", "apiKey": "$APIKEY"} } }' \ -H 'Content-Type: application/json' \ 'https://identity.api.rackspacecloud.com/v2.0/tokens' | python -m json.tool | grep -i token -A5
This script allows you to migrate a Linux Server from one server to another one. It uses rsync and it could be use when you need to resize down a server for example, or if you want to migrate onto another Cloud Provider.
git clone git://github.com/cloudnull/InstanceSync.git
Source:
http://cloudnull.io/2012/07/cloud-server-migration/
https://github.com/cloudnull/InstanceSync
mkdir /home/deployment chown apache:apache /home/deployment
cat > /home/deployment/git.sh <<EOF #!/bin/bash if [ $# -eq 0 ]; then echo "Git wrapper script that can specify an ssh-key file Usage: git.sh -i ssh-key-file git-command " exit 1 fi # remove temporary file on exit trap 'rm -f /home/deployment/.git_ssh.$$' 0 if [ "$1" = "-i" ]; then SSH_KEY=$2; shift; shift echo "ssh -o StrictHostKeyChecking=no -i $SSH_KEY \$@" > /home/deployment/.git_ssh.$$ chmod +x /home/deployment/.git_ssh.$$ export GIT_SSH=/home/deployment/.git_ssh.$$ fi # in case the git command is repeated [ "$1" = "git" ] && shift # Run the git command git "$@" EOF
~# su - apache -s /bin/bash Last login: Tue Apr 5 16:03:53 BST 2016 on pts/0 -bash-4.2$ cd /var/www/vhosts/ -bash-4.2$ /home/deployment/git.sh -i /home/deployment/.ssh/id_rsa clone [email protected]:repository01.git
Make sure to get into the folder with .git subfolder
(in this case we did the clone into /var/www/vhosts/ BUT the code is stored into a new subfolder pulled with the domain name. So we cd into that one)
-bash-4.2$ cd /var/www/vhosts/blog.com && /home/deployment/git.sh -i /home/deployment/.ssh/id_rsa pull --rebase Could not create directory '/usr/share/httpd/.ssh'. Failed to add the host to the list of known hosts (/usr/share/httpd/.ssh/known_hosts). Current branch master is up to date. -bash-4.2$
echo "*/5 * * * * apache cd /var/www/vhosts/blog.com && /home/deployment/git.sh -i /home/deployment/.ssh/id_rsa pull --rebase > /dev/null 2>&1" >> /etc/crontab