All posts by Maksim Malchuk

MySQL console client tuning

сделаем красивое удобное приглашение

mysql> prompt (\u@\h) [\d] >
PROMPT set to '(\u@\h) [\d] >'
(root@localhost) [database] >

где \u — пользователь, \h — хост и \d — база данных

(root@localhost) [database] >pager less -iMSx4 -FX
PAGER set to 'less -iMSx4 -FX'

тепереь у нас есть удобная навигация стрелочками туда-сюда и влево-вправо ;)

# cat ~/.my.cnf
[client]
default-character-set=utf8
 
[mysql]
pager = 'less -iMSx4 -FX'
prompt = '(\u@\h) [\d] > '

добавим в конфиг чтобы так было всегда. в раздел [mysql] иначе остальные клиенты (mysqldump или mysqladmin) будут ругаться.

MySQL console client and multi-byte output problem

mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)
 
mysql> set NAMES utf8;
Query OK, 0 rows affected (0.00 sec)
 
mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)

Как видим set NAMES utf8 не помог. оказывается это старая проблема.

# mysql --default-character-set=utf8
 
mysql> SELECT 'John Doe' as 'Джон Доу';
+-----------------+
| Джон Доу        |
+-----------------+
| John Doe        |
+-----------------+
1 row in set (0.00 sec)

создаем конфиг для клиента

# cat ~/.my.cnf
[client]
default-character-set=utf8

Vesta Control Panel

About:

  • open source hosting control panel
  • easy and focused interface
  • innovative web technologies

Features:

  • Web Server
  • DNS server
  • Database Server
  • Mail Server
  • FTP Server
  • Nginx out of the box
  • SSL certificates & SNI
  • Wildcard support
  • Configuration Templates
  • DKIM support
  • Fast Backups
  • System Monitoring
  • AntiSpam / Antivirus
  • WHMCS billing support
  • EPEL integration
  • Simple and Clean GUI
  • Powerfull CLI
  • Reliable Platform
  • Open Data Format
  • GPL v3 License

Install:

# Connect to your server as root via SSH
ssh [email protected]
# Download installation script
curl -O http://vestacp.com/pub/vst-install.sh
# Run it
bash vst-install.sh

Links:
Official site
Habrahabr
Vesta Installation Screencast

ISPManager и ошибка «Конвертация в ‘UTF-8′ не поддерживается на стороне сервера»

Лечится так:

# echo "FSEncoding UTF-8" >>/usr/local/ispmgr/etc/ispmgr.conf
# killall ispmgr

Стоит так же провертить есть ли в системе iconv и правильные ли кодировки в /usr/local/ispmgr/etc/filemgr.enc

# iconv -l | cut -d" " -f1 | sed "s|//||g" >/usr/local/ispmgr/etc/filemgr.enc

pdsh на MacOS

Ни в системе ни в портах нет очень нужной штуки для администрирования… такой как “пыдыщь” :(
У нас конечно же стоит XCode и порты, так что собрать самим не составит труда:

$ cd ~/Downloads
$ curl -O http://pdsh.googlecode.com/files/pdsh-2.29.tar.bz2
$ tar jxvf pdsh-2.29.tar.bz2
$ cd pdsh-2.29
$ ./configure --prefix=/usr/local --with-ssh
$ sudo make install

проверяем:

$ pdsh -Rssh -w cp1,cp2,cp3 uptime
cp3:  15:05:25 up 7 days, 17:23,  0 users,  load average: 0.07, 0.32, 0.18
cp1:  15:05:25 up 7 days,  6:21,  0 users,  load average: 0.43, 0.92, 0.92
cp2:  15:05:25 up 7 days, 15:00,  0 users,  load average: 0.63, 1.68, 1.26
$

вот так одной коммандой убили трех зайцев :)

ISPmanager и SSL через nginx

С недавнего времени ISPmanager умеет настраивать SSL черз nginx. Все бы ничего но сайты с SSL перестали открываться, оказывается причиной тому “логика” панели – в зависимости от установленной версии nginx панель добавляет строку

listen xxx.xxx.xxx.xxx:443;

а должна добавлять

listen xxx.xxx.xxx.xxx:443 ssl;

поправить придется ручками (хотя наверно можно и через панель), но для начала надо обновить версию nginx до последней:

# echo "deb http://ftp2.debian.org.ua/debian-dou/ squeeze main" \
 >>/etc/apt/sources.list
# wget -qO - http://ftp2.debian.org.ua/debian-dou/archive.key |\
 sudo apt-key add -
# apt-get update && apt-get dist-upgrade

Bitrix и проблема SSL

Включаем SSL на хостинге сайта на 1C-Bitrix и получаем ошибку что страница не может быть безопасно отображена по непонятной причине ибо ни в шаблоне ни в страницах нет внешних ссылок.

Путем недолгих выяснений узнаем что сайт пытается небезопасно отобразить ссылку типа

http://domain.ru/bitrix/spread.php?s=QklUUklYX1NNX0...%3D&k=e75597...

Эту ссылку выводит функция ShowSpreadCookieHTML(). Параметры в строке закодированы через

$params = "s=".urlencode(base64_encode($params))."&k=".urlencode(md5($params.$salt));

Зачем все это и как работает можно подчерпнуть из документации или из курса Многосайтовость

Баг что ссылка без https или это фича разбираться будем потом, а пока что отключить такое поведение можно убрав галку с “распространять куки на все домены” в настройках Главного модуля.

Learning TeX (beginning)

This is my first experience with TeX and the document should consist of :

% lines started with % symbol are comments
\documentclass[options]{class}
% options - mandatory
% class - one of the from list (article, letter, report, book, proc, slides)
\begin{document}
%body of the document
\end{document}

An example:

\documentclass[10pt]{article}
\begin{document}
This is my first \LaTeX document.
 
Suppose we are given a rectangle with side lengths $(x+1)$ and $(x+3)$ . Than the equation $A=x^2+4x+3$ represents the area of the rectangle.
 
Suppose we are given a rectangle with side lengths $(x+1)$ and $(x+3)$ . Than the equation $$A=x^2+4x+3$$ represents the area of the rectangle.
\end{document}

Openstack VNC Security

If we want to secure connections to VNC ports we should add an iptables rules like:

-A INPUT -s MYNETWORK/24 -p tcp -m multiport –dports 5900:5910 -j  ACCEPT
-A INPUT -p tcp -m multiport –dports 5900:5910 -j REJECT

But in this case we should know how much VNC ports will be running on hardware node (5900+N)… Do you know that iptables can use extended packet matching modules? For example the OWNER module. This module attempts to match various characteristics of the packet creator, for locally generated packets. And we try to use it for block all outgoing (n.b. match is only valid in the OUTPUT and POSTROUTING chains) connections from all VNC servers:

-A OUTPUT -d MYNETWORK/24 -m owner –uid-owner qemu -j ACCEPT
-A OUTPUT -m owner –uid-owner qemu -j REJECT

AR8131 network card driver for Linux

Motherboard: ASUS P5G41T-M LX
Kernel: 2.6.18-6-pve

1. Download source code:

$ wget http://dlcdnet.asus.com/pub/ASUS/mb/socket775/P5G41T-M_LX/Linux_Driver.zip

2. Unpack archives:

$ unzip -o Linux_Driver.zip
$ cd Linux/LAN/
$ tar zxvf AR8131_AR8132-linux-v1.0.0.10.tar.gz
$ cd src/

3. Modify kcompat.h

--- kcompat.h   2009-05-22 06:40:10.000000000 +0400
+++ kcompat.h   2013-05-20 18:16:27.000000000 +0400
@@ -1556,7 +1556,8 @@
 #endif /* > 2.6.22 */
 
 /*****************************************************************************/
-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) )
+#if 0
+/* #if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) ) */
 /* NAPI API changes in 2.6.24 break everything */
 struct napi_struct {
        /* used to look up the real NAPI polling routine */

4. Compile and use:

$ sudo make install