Amazing guide on how to change timezone for your nginx server:
http://www.oneminuteinfo.com/2013/06/how-to-change-timezone-of-nginx-web-log.html
середа, 6 листопада 2013 р.
понеділок, 7 жовтня 2013 р.
пʼятниця, 14 червня 2013 р.
MySQL - formatting output
Hey!
If you need to preserve fancy table output for your mysql queries, use the following switch: -t.
Reference:
http://stackoverflow.com/questions/9745547/get-mysqls-fancy-table-format-as-stdout
If you need to preserve fancy table output for your mysql queries, use the following switch: -t.
--table, -t
Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.
Reference:
http://stackoverflow.com/questions/9745547/get-mysqls-fancy-table-format-as-stdout
середа, 8 травня 2013 р.
Human friendly time format in dmesg
I have wondered is there any way to represent timings from dmesg in easy and clear, human-readable way. Now I have discovered "-T" switch :-)
References:
http://serverfault.com/questions/366392/how-to-convert-dmesg-time-format-to-real-time-format
-T, --ctime
Print human readable timestamps. The timestamp could be inaccu‐
rate!
The time source used for the logs is not updated after system
SUSPEND/RESUME.
So simply issue: dmesg -T.
And you're done!References:
http://serverfault.com/questions/366392/how-to-convert-dmesg-time-format-to-real-time-format
вівторок, 16 квітня 2013 р.
пʼятниця, 12 квітня 2013 р.
Test your network bandwidth
Want to check your network bandwidth?
No problem - there are a lot of files carefully prepared for you, just try:
http://www.thinkbroadband.com/download.html
No problem - there are a lot of files carefully prepared for you, just try:
http://www.thinkbroadband.com/download.html
четвер, 4 квітня 2013 р.
Run Chrome as root on Ubuntu
For some task you have to root on a system and some such tasks are made from browser.
If you use Google Chrome here is a simple way to lauch it as a root:
sudo -i
/opt/google/chrome/google-chrome --user-data-dir %U
Reference
http://ubuntuforums.org/showthread.php?t=1743565
If you use Google Chrome here is a simple way to lauch it as a root:
sudo -i
/opt/google/chrome/google-chrome --user-data-dir %U
Reference
http://ubuntuforums.org/showthread.php?t=1743565
середа, 3 квітня 2013 р.
Install Java on Ubuntu server 12.04
How to install Java on your Ubuntu server 12.04?
Follow this easy 3-step guide:
Now you can enjoy Java on your Ubuntu ;)
References:
http://askubuntu.com/questions/197248/java-on-ubuntu-server-12-04
Follow this easy 3-step guide:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Now you can enjoy Java on your Ubuntu ;)
References:
http://askubuntu.com/questions/197248/java-on-ubuntu-server-12-04
вівторок, 2 квітня 2013 р.
Renaming munin nodes and preserving history
Once you have changed your server naming convention or just decided to rename on (or all) of your servers you will also need to update server in name in your monitoring tools. If you are using munin - here is step-by-step solution for you.
We assume you are using example.com as your domain and want to rename oldhost.example.com to newhost.example.com.
1. Backup existing data and configs
2. Remove unneeded and legacy stuff (if any)
3. Disable munin cronjobs
I do strongly recommend you prepare all the changes before disabling cronjobs to minimize munin downtime! Just prepare all the changes and save once you have done Step 4.
That's all! Now just wait 5 minutes (default cronjob interval) to see updates on the munin web-interface.
References:
http://aaltonen.co/2010/12/30/change-munin-node-hostname/
http://beeznest.wordpress.com/2011/06/13/howto-rename-munin-node-without-loosing-history/
We assume you are using example.com as your domain and want to rename oldhost.example.com to newhost.example.com.
1. Backup existing data and configs
cd /backup/
tar cvpzf munin_lib.tar.gz.$(date +%Y%m%d) /var/lib/munin
tar cvpzf munin_html.tar.gz.$(date +%Y%m%d) /www/munin
cp /etc/munin/munin.conf munin.conf.$(date +%Y%m%d)
2. Remove unneeded and legacy stuff (if any)
cd /var/lib/munin/example.com
rm old* test* temp*
cd /var/vhosts/monitor/munin/clickmein.com
rm -R old* test* temp*
3. Disable munin cronjobs
mv /etc/cron.d/munin /etc/cron.d/munin.disabled
4. Rename actual rrd files
for file in /var/lib/munin/example.com/*.rrd; do mv $file `echo $file|sed 's/oldhost\.example\.com/newhost\.example\.com/'`; done5. Edit munin config
I do strongly recommend you prepare all the changes before disabling cronjobs to minimize munin downtime! Just prepare all the changes and save once you have done Step 4.
vi /etc/munin/munin.confAnd then type the following command sequence to replace all occurances in config file in vi editor.
:%s/oldhost\.example\.com/newhost\.example\.com/g6. Enable cronjob
mv /etc/cron.d/munin.disabled /etc/cron.d/munin
That's all! Now just wait 5 minutes (default cronjob interval) to see updates on the munin web-interface.
References:
http://aaltonen.co/2010/12/30/change-munin-node-hostname/
http://beeznest.wordpress.com/2011/06/13/howto-rename-munin-node-without-loosing-history/
понеділок, 11 березня 2013 р.
Using wget/curl to connect to specific server/vhost
One of DNS advantages is it's round-robin capability. But often you need to connect to specific server to specific vhost.
wget is capable of performing this task, just use --header switch:
References:
http://lists.gnu.org/archive/html/bug-wget/2011-03/msg00040.html
http://drewish.com/content/2010/03/using_curl_and_the_host_header_to_bypass_a_load_balancer
wget is capable of performing this task, just use --header switch:
wget http://2.2.2.2/the_url_to_test/ --header 'Host: www.example.com'curl also can ;-)
curl --verbose --header 'Host: www.example.com''http://2.2.2.2/the_url_to_test'Very handy features for shell programming!
References:
http://lists.gnu.org/archive/html/bug-wget/2011-03/msg00040.html
http://drewish.com/content/2010/03/using_curl_and_the_host_header_to_bypass_a_load_balancer
четвер, 7 березня 2013 р.
MySQL in scripting - using timeouts
If you are using any cron jobs with which connect to MySQL and do some work it will be wise decision to think about what will happen when MySQL daemon stops. I'll tell you! Your scripts will not be able to connect to database. And they will run until database returns. They may run forever!
Just look into man of mysqld.
Just look into man of mysqld.
· connect_timeout
The number of seconds before connection timeout. (Default value is
0.)
See that?! Default value is 0 - it means infinity!
No need to have such risk.
Hence quickly add the following parameter to your scripts (example below use 5 seconds timeout):
--connect_timeout=5
середа, 20 лютого 2013 р.
Correct MySQL permissions for backup user
Backups are rule #1 for any DBA. If you are using mysqldump utility you should take care of correct privileges for your backup user:
> GRANT SHOW DATABASES, SHOW VIEW, SELECT, LOCK TABLES, RELOAD ON *.* to 'backup_user'@'localhost' IDENTIFIED BY 'backup_password';It is expanded list of privileges found in the wonderful MySQL permissions for backup entry.
Мітки:
backup,
MySQL,
MySQL privileges,
permissions,
security
понеділок, 28 січня 2013 р.
Valid URI characters
Hey!
Do you know that only following chracters are valid for URI:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=
So now you know it! ;)
RegEx to determine only valid URI characters: /^[!#$&-;=?-[]_a-z~]+$/
References:
http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid
http://tools.ietf.org/html/rfc3986
Do you know that only following chracters are valid for URI:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=
So now you know it! ;)
RegEx to determine only valid URI characters: /^[!#$&-;=?-[]_a-z~]+$/
References:
http://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid
http://tools.ietf.org/html/rfc3986
пʼятниця, 18 січня 2013 р.
MySQL - Finding tables without primary keys
It is always important to have primary keys when you're in SQL world. I have found a nice way find to find those culprit tables who don't have it. And just modified a bit added "engine" column. So here it is:
SELECT table_catalog, table_schema, table_name, engine
FROM information_schema.tables
WHERE (table_catalog, table_schema, table_name) NOT IN
(SELECT table_catalog, table_schema, table_name
FROM information_schema.table_constraints
WHERE constraint_type = 'PRIMARY KEY')
AND table_schema NOT IN ('information_schema', 'pg_catalog');
SELECT table_catalog, table_schema, table_name, engine
FROM information_schema.tables
WHERE (table_catalog, table_schema, table_name) NOT IN
(SELECT table_catalog, table_schema, table_name
FROM information_schema.table_constraints
WHERE constraint_type = 'PRIMARY KEY')
AND table_schema NOT IN ('information_schema', 'pg_catalog');
Підписатися на:
Дописи (Atom)