[Ubuntu] Enable power saving in Lenovo X61

Ref: http://www.webupd8.org/2014/04/prevent-your-laptop-from-overheating.html

Because I installed Ubuntu 14.04 in my Lenovo X61.
Although it could switch into the sleep mode after closing the lid. It’s not really using the power saving mode.
So we must edit the GRUB file.

sudo vim /etc/default/grub

Find the “GRUB_CMDLINE_LINUX_DEFAULT”, and add “intel_pstate=enable” at the end, like this.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_pstate=enable"

Then update the grub config

sudo update-grub

Finally, we must reboot and use powertop to check its status.

Posted in Ubuntu | Leave a comment

ACID & CAP

  • ACID: 資料庫管理系統(DBMS)在寫入/異動資料的過程中,為保證交易(transaction)是正確可靠的,所必須具備的四個特性:原子性(atomicity,或稱不可分割性)、一致性(consistency)、隔離性(isolation,又稱獨立性)、持久性(durability)。 ….. source: Wiki – ACID
    • Atomicity(原子性)
      一個交易(transaction)中的所有操作,要麼全部完成,要麼全部不完成,不會結束在中間某個環節。事務在執行過程中發生錯誤,會被回滾(Rollback)到事務開始前的狀態,就像這個事務從來沒有執行過一樣。
    • Consistency(一致性) 在事務開始之前和事務結束以後,資料庫的完整性沒有被破壞。這表示寫入的資料必須完全符合所有的預設規則,這包含資料的精確度、串聯性以及後續資料庫可以自 發性地完成預定的工作。
    • Isolation(隔離性)
      當兩個或者多個事務並發訪問(此處訪問指查詢和修改的操作)資料庫的同一數據時所表現出的相互關係。事務隔離分為不同級別,包括讀未提交(Read uncommitted)、讀提交(read committed)、可重複讀(repeatable read)和串列化(Serializable)。
    • Durability(持久性) 在事務完成以後,該事務對資料庫所作的更改便持久地保存在資料庫之中,並且是完全的。

  • CAP: 又被稱作布魯爾定理(Brewer’s theorem),它指出對於一個分布式計算系統來說,不可能同時滿足以下三點:一致性(Consistency)、可用性(Availability)、容忍網路分區(Partition tolerance);根據定理,分佈式系統只能滿足三項中的兩項而不可能滿足全部三項。 ….. source: Wiki – CAP定裡
    • Consistency(一致性): 等同於所有節點訪問同一份最新的數據副本
    • Availability(可用性): 對數據更新具備高可用性
    • Partition tolerance(容忍網路分區): 以實際效果而言,分區相當於對通信的時限要求。系統如果不能在時限內達成數據一致性,就意味著發生了分區的情況,必須就當前操作在C和A之間做出選擇。
Posted in 名詞解釋 | Leave a comment

[Elasticsearch] Delete index by search syntax

  1. check the search syntax
curl -XGET 'http://{ElasticSearch_Server_IP}:{ElasticSearch_Server_Port}/{Index}/{Type}/_search?q={Search Syntax}

ex:

curl -XGET 'http://localhost:9200/logstash-2015.01.26/syslog/_search?q="Rhttpproxy"'
  1. Delete index by search syntax
curl -XDELETE 'http://{ElasticSearch_Server_IP}:{ElasticSearch_Server_Port}/{Index}/{Type}/_query?q={Search Syntax}

ex:

curl -XDELETE 'http://localhost:9200/logstash-2015.01.26/syslog/_query?q="Rhttpproxy"'
Posted in Elasticsearch | Leave a comment

[Logstash] LoadError: no such file to load — i18n

In CentOS 5.5, I want to install the logstash agent to forward logs.
Because it was older system and no one would upgrade it, the original java version is 1.6.
I always got the error about “LoadError: no such file to load — i18n” when I started the logstash service.
After upgrading the java version, it’s work.
So the minimum requirements for java version is 1.7, I got….

Posted in Logstash | Leave a comment

[Apache] Proxypass

Because the default web port of Elasticsearch is 9200.
And I want to change it with 80.
Maybe I could use the proxypass function.

  1. enable the proxy, and restart apache
a2enmod proxy
a2enmod proxy_http
service apache2 restart
  1. add following into the /etc/apache2/sites-enabled/000-default.conf

       ProxyPreserveHost On
       ProxyVia full

       
         Order deny,allow
         Allow from all
       

       ProxyPass        /kibana9200  http://localhost:9200

  1. edit the kibana config (vim /var/www/kibana/config.js)

<

pre lang=”bash”>
elasticsearch: “http://”+window.location.hostname+”/kibana9200”,

Posted in Apache, Elasticsearch, Kibana | Leave a comment

[FreeRADIUS] Build RPM files in CentOS 6.X

WTF, I wasted all my morning doing it…..

Environment: CentOS 6.6 x64 minimal server

  1. install wget
yum install wget
  1. create rpmbuild/SOURCES and rpmbuild/SPECS folder under your home directory
mkdir -p /root/rpmbuild/SOURCES
  1. get into this folder and download the source file from freeradius.org
cd /root/rpmbuild/SOURCES
wget ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-2.2.6.tar.gz
  1. extract this compressed file and edit the source what you want, i want to edit the “MAX_SQL_SOCKS” limit. then you can delete the original compressed file
tar zxvf freeradius-server-2.2.6.tar.gz
vim freeradius-server-2.2.6/src/modules/rlm_sql/conf.h
// original
// #define MAX_SQL_SOCKS                   256
// edited
#define MAX_SQL_SOCKS                   2048
del zxvf freeradius-server-2.2.6.tar.gz
  1. use tar to compress this folder and then bzip2 it
tar cf freeradius-server-2.2.6.tar freeradius-server-2.2.6
bzip2 freeradius-server-2.2.6.tar
  1. copy the required files
cp freeradius-server-2.2.6/redhat/freeradius-* .
cp freeradius-server-2.2.6/redhat/freeradius.spec ../SPECS/
  1. start to build RPM files
rpmbuild -bb ../SPECS/freeradius.spec
  1. then the RPM files will be here
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-utils-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-ldap-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-krb5-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-perl-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-python-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-mysql-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-postgresql-2.2.6-1.el6.x86_64.rpm
Wrote: /root/rpmbuild/RPMS/x86_64/freeradius-unixODBC-2.2.6-1.el6.x86_64.rpm

note: the default path in CentOS 5.x is /usr/src/redhat

Posted in Radius | Leave a comment

[OpenVPN] Build RPM in CentOS 6.5

CentOS 6.5 x64

  1. yum update -y
  2. install openssl openssl-devel lzo lzo-devel pam_devel -y
  3. wget http://swupdate.openvpn.org/community/releases/openvpn-2.3.6.tar.gz
  4. rpm-build -tb openvpn-2.3.6.tar.gz
Posted in OpenVPN | Leave a comment

[FreeRADIUS] 修改 SQL 連線數上限

因為 FreeRADIUS 在 Source 就指定了對 SQL 的連線數上限為 256
因此可能會發生因為連線數以達上限造成連線失敗的事件

沒有其他方法~唯一解~就是修改 code 重新 build
下載 FreeRADIUS 的 tar.gz
修改 src/modules/rlm_sql/conf.h 檔案,將
#define MAX_SQL_SOCKS 256
改為你想要的數字
#define MAX_SQL_SOCKS 2048
然後重新 build 安裝即可

之後在到 raddb/sql.conf 設定需要的連線數即可
由於這數字是 FreeRADIUS 一啟動就會建立連線數
所以也不要設定太高~

Posted in Radius | Leave a comment

[FreeRadius] Refusing to start with libssl version OpenSSL

當使用 tar.gz 安裝完 FreeRADIUS 後要啟動時,可能會發生錯誤
這時後再使用 radiusd -X 以 debug 模式進行
可能得到下面這個錯誤
Refusing to start with libssl version OpenSSL 1.0.1e-fips 11 Feb 2013 (in range 1.0.1 - 1.0.1f). Sec urity advisory CVE-2014-0160 (Heartbleed)
這時候就需要去編輯 radiusd.conf 檔案
將 security section 的 allow_vulnerable_openssl = no 改為 allow_vulnerable_openssl = yes

Posted in Radius | Leave a comment

[FreeRADIUS] failed locating OpenSSL headers

在使用 tar.gz 安裝 FreeRadius 的時候可能會發生下列這個錯誤

configure: error: in `/usr/source/freeradius-server-2.2.6':
configure: error: failed locating OpenSSL headers

這時候就必須要安裝 openssl-devel、libtalloc-devel

yum install openssl-devel
yum install libtalloc-devel

Posted in Radius | Leave a comment