2014年6月10日 星期二

[Linux] 使用 Openssl 做簡易的(DES3)加密、解密 @ Ubuntu 14.04

準備資料:

$ ls
my.data


加密:

$ dd if=my.data | openssl des3 -salt -k helloworld  | dd of=my.data.des3

解密:

$ dd if=my.data.des3 | openssl des3 -d -k helloworld | dd of=my.data

如此一來,就可以搭配 tar 的方式,把檔案先 tar 起來,在走 openssl 加密:

$ tar -zcvf - src | openssl des3 -salt -k helloworld | dd of=data.tar.gz.des3

解密: $ dd if=data.tar.gz.des3 | openssl des3 -d -k helloworld | tar -xzvf -

[Linux] 使用 find -exec 之 Commands 與 Pipe 用法

原先打算:

$ find -name "*.sql" -exec tar -zcf - {} | dd of={}.tgz \;
dd: find: missing argument to `-exec'
unrecognized operand `;'
Try `dd --help' for more information.


改用 sh 來包:

$ find -name "*.sql" -exec sh -c 'tar -zcf - {} | dd of={}.tgz' \;
40984+1 records in
40984+1 records out
20984096 bytes (21 MB) copied, 3.51398 s, 6.0 MB/s

[Linux] Apache Error Log: configuration error: couldn't perform authentication. AuthType not set!: / @ Ubuntu 12.04, Ubuntu 14.04

最近部署環境時,想要偷懶共用一個 apache 設定檔,由於 Ubuntu 14.04 預設是安裝 apache 2.4.7 而 Ubuntu 12.04 預設是安裝 Apache 2.2.2。

忘記是 apache 哪版開始,預設必須加上:

Order allow,deny
Allow from all



Require all granted

才能正常使用,然而這兩段剛好一個是 apache 2.2,另一個是 apache 2.4 使用,並且不相容,所幸,還有個解法...那就是 Satisfy Any 啦

<Directory /path/www>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None

        Order allow,deny
        allow from all

        Require all granted

        Satisfy Any
</Directory>

2014年6月6日 星期五

[Linux] PHPMyAdmin - Table 'phpmyadmin.pma_table_uiprefs' doesn't exist @ Ubuntu 14.04

主因是將某處 DB 搬遷後,統一用一個 PHPMyAdmin 管理多個 DB Server ,因此出現的問題。

解法:

$ locate create_tables.sql.
/usr/share/doc/phpmyadmin/examples/create_tables.sql.gz
$ cp /usr/share/doc/phpmyadmin/examples/create_tables.sql.gz /tmp
$ cd /tmp && gunzip /tmp/create_tables.sql.gz

$ mysql -h xxxx -u root -p < create_tables.sql
$ sudo vim /etc/phpmyadmin/config.inc.php
更新 'pma_bookmark' to 'pma__bookmark' 等一系列項目,如:
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';

[Linux] 使用 nc 測試 TCP Port 是否正常 @ Ubuntu 12.04

最近在構想一個架構,在遠方 Data Center 架一個 MySQL Server ,但又在本地端架一個備份機制。當連不到遠端時,改連本地機器,所以,就需要偵測遠方 MySQL Server 的狀態。

於是乎...就是用 nc 指令來達成:

$ nc -z -w 3 remote_server 3306 && echo "OK"

其中 -w timeout 機制。