2014年7月17日 星期四

yum install nginx

To add nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:
CentOS:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
RHEL:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/$releasever/$basearch/
gpgcheck=0
enabled=1
Due to differences between how CentOS, RHEL, and Scientific Linux populate the $releasever variable, it is necessary to manually replace $releasever with either "5" (for 5.x) or "6" (for 6.x), depending upon your OS version.
source:http://wiki.nginx.org/Install

2014年6月28日 星期六

Posftix Permission denied problem

http://www.spidersoft.com.au/2011/posftix-permission-denied-problem/
After investigation tail -f /var/log/messages I founded a pleasant line of code with really nice explanation:
1sendmail: fatal: chdir /var/spool/postfix: Permission denied
In theory this should be a problem for sysadmin, but – I wanted to find faster solution.
After short adventure with Google I found a clue:
1/usr/sbin/getsebool httpd_can_sendmail
My result was obvious:
1httpd_can_sendmail --> off
Problem was solved by
1setsebool httpd_can_sendmail 1

2014年6月22日 星期日

MySQL & MariaDB 指令備忘

  • 新裝的資料庫設定root權限
  • mysqladmin -u root password '你的密碼'
  • or
  • mysqladmin -u root password
  • 修改使用者密碼(自已)或來源主機
  • mysql>set password for 'username'@'localhost' = password('密碼');
  • mysql>flush privileges;
  • NOTE:若是開放全域存取的話只要將localhost改成% 但是非常之不建議
  • flush privilegs這指令也建議搭配使用。
  • 修改使用者密碼(他人)或來源主機
  • mysql>UPDATE user SET Password=PASSWORD("密碼") WHERE User='目標使用者';
  • mysql>flush privileges;
  • 使用者分配與權限
  • GRANT ALL ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Linux 指令備忘

find "path name" -name "file name" -exec grep -H "search content" {} \;

find原本是用「檔案名稱」來搜尋在哪些地方有這些檔案,將這些路徑結果餵給grep後,就可以拿來搜尋檔案內部的文字片段。

Ex:
find ./kernel -name "*.c" -exec grep -H "main" {} \;
以上這段指令,是要搜尋./kernel底下所有的.c檔,內容含有"main"的地方。

find的參數:
  -name 要搜尋哪些檔名
  -exec utility name [argument...] {} \;
    搜尋出的檔名 交給哪個執行檔(utility name)處理
    {} 會被find搜尋後的檔名路徑名稱所取代
    \; 代表exec的參數到此為止

grep的參數:
  -H 列出搜尋到的檔案名稱路徑

CentOS安裝MariaDB

 vim /etc/yum.repos.d/mariadb.repo
#自行決定要安裝5.5版或10版

# MariaDB 5.5 CentOS repository list - created 2014-01-10 13:53 UTC  
# http://mariadb.org/mariadb/repositories/ 
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/5.5/centos6-amd64 
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1 

# MariaDB 10.0 CentOS repository list - created 2014-01-10 13:54 UTC  
# http://mariadb.org/mariadb/repositories/ 
[mariadb] 
name = MariaDB 
baseurl = http://yum.mariadb.org/10.0/centos6-amd64 
gpgkey = https://yum.mariadb.org/RPM-GPG-KEY-MariaDB 
gpgcheck=1

更新套件庫
# yum update

安裝 MariaDB
# yum -y install MariaDB-server MariaDB-client

啟動 MariaDB
# service mysql start

開機後啟動
# chkconfig --level 3 mysql on

來源:http://blog.ilc.edu.tw/blog/blog/25793/post/78462/471141

2014年6月1日 星期日

尋找yum安裝程式的 預設的安裝位置

例如:httpd

rpm -qa | grep httpd #至少大概知道自已yum install 了什麼吧…不然會找到死="=
以上指令產出的資訊
httpd-2.2.15-30.el6.centos.x86_64
httpd-devel-2.2.15-30.el6.centos.x86_64
httpd-tools-2.2.15-30.el6.centos.x86_64

rpm -ql httpd-2.2.15-30.el6.centos.x86_64
以上指令產出的資訊
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
/etc/logrotate.d/httpd
/etc/rc.d/init.d/htcacheclean
/etc/rc.d/init.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd
/usr/lib64/httpd
/usr/lib64/httpd/modules
----略......一大堆資訊;建議加個 more 方法="=

httpd + tomcat 整合

環境:CentOS

1、下載最新的的Apache Tomcat Connector
http://tomcat.apache.org/connectors-doc/

2、安裝http-devel
yum -y install httpd-devel gcc

3、解壓tomcat-connectors-1.2.37-src.tar,然後進行如下操作
cd native/
./configure --with-apxs=/usr/sbin/apxs
make
make install

4、在httpd.conf中添加模塊
LoadModule jkmodule modules/mod_jk.so

5、vi /etc/httpd/conf/httpd.conf底下新增以下
# Load mod_jk module
# Update this path to match your modules location
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/httpd/conf/workers.properties

# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /var/log/httpd/mod_jk.shm

# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile /var/log/httpd/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "


6、新增 vi /etc/httpd/conf/worker.properties
# Define 2 workers, using ajp13
worker.list=worker1, worker2
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=127.0.0.1
worker.worker1.port=8009
# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=localhost
worker.worker2.port=8009
worker.worker2.connection_pool_timeout=600
worker.worker2.socket_timeout=60

7、httpd VirtualHost設定
<VirtualHost *:80>
    DocumentRoot /var/www/html/jc #如果直接要"根"丟給worker1作業的話應該不用設定這裡httpd的位置
    ServerName www.example.com.tw
    ErrorLog logs/www.example.com.tw-error_log
    CustomLog logs/www.example.com.tw-access_log common
    JkMount /* worker1 ##做什麼樣的資料夾存取時去啟用worker1的方法

</VirtualHost>

8、新增tomcat Host 以及 關閉預設的8080並開啟AJP-Port 8009
    <!--Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" /--> 註解掉

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 這預設應該是打開的

      <Host name="www.example.com.tw"  appBase="webapps" #存取webapps/ROOT中網頁
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">
      </Host>
9、重啟httpd 以及 tomcat

**若有要做Load Balance 可以參照來源的網友教學嘗試建置~
即可測試

來源:
http://eoffice.im.fju.edu.tw/phpbb/viewtopic.php?t=6603
http://rritw.com/a/caozuoxitong/OS/20130919/426012.html


2011年12月7日 星期三

【轉貼文章】自己動手寫HTML5網頁

自己動手寫HTML5網頁
文/胡仁禮 (技術編輯) 2011-12-07



HTML5不僅加強了對多媒體的支援,還新增了canvas畫布,實現了在網頁上繪圖的功能,開發者也能利用HTML5提供的API,開發網頁應用程式

由W3C負責制定的HTML是用來編寫網頁的標記語言,而目前我們所使用的版本為4.01。如果開啟網頁的原始檔查看,會發現到很多類似<html>這樣由<及>符號包含文字的標籤,這就是HTML語言。其實說穿了,網頁就是一堆標籤的組合。

HTML標籤通常都有起始標籤與結束標籤,例如<html>與</html>,而要構成一個網頁,最基本的標籤有<html>、<head>、 <title>與<body>。<html>及</html>一定是放在程式的第一行與最後一行,告訴瀏覽器這是一份HTML文件。而<head>則是檔 頭宣告,定義這一個網頁的屬性,例如使用何種編碼方式,裡面的內容除了<title>外,不會出現在網頁上。title標籤被包含在head內,主要是顯 示網頁標題,裡面的文字會出現在網頁最上方的標題欄。而<body>標籤的內容則是要呈現在網頁上的資訊。

由於HTML 4.01只能傳達文字或圖片等的靜態資訊,於是為了讓網頁能有動態的效果,開始出現了像JavaScript語言這樣的技術,達成與使用者互動的



詳細內容請至→http://www.ithome.com.tw/itadm/article.php?c=71041&s=2

【Linux】 壓縮打包指令

  • 壓 縮:tar -jcv -f filename.tar.bz2 要被壓縮的檔案或目錄名稱
  • 查 詢:tar -jtv -f filename.tar.bz2
  • 解壓縮:tar -jxv -f filename.tar.bz2 -C 欲解壓縮的目錄
選項與參數:
-c  :建立打包檔案,可搭配 -v 來察看過程中被打包的檔名(filename)
-t  :察看打包檔案的內容含有哪些檔名,重點在察看『檔名』就是了;
-x  :解打包或解壓縮的功能,可以搭配 -C (大寫) 在特定目錄解開
      特別留意的是, -c, -t, -x 不可同時出現在一串指令列中。
-j  :透過 bzip2 的支援進行壓縮/解壓縮:此時檔名最好為 *.tar.bz2
-z  :透過 gzip  的支援進行壓縮/解壓縮:此時檔名最好為 *.tar.gz
-v  :在壓縮/解壓縮的過程中,將正在處理的檔名顯示出來!
-f filename:-f 後面要立刻接要被處理的檔名!建議 -f 單獨寫一個選項囉!
-C 目錄    :這個選項用在解壓縮,若要在特定目錄解壓縮,可以使用這個選項。

其他後續練習會使用到的選項介紹:
-p(小寫) :保留備份資料的原本權限與屬性,常用於備份(-c)重要的設定檔
-P(大寫) :保留絕對路徑,亦即允許備份資料中含有根目錄存在之意;
--exclude=FILE:在壓縮的過程中,不要將 FILE 打包! 
 
原文章:鳥哥的 Linux 私房菜

【Linux】 網路環境(懶人法)

[root@localhost ~]# system-config-network

**setup 指令也可以~~會被養壞阿…

2011年11月25日 星期五

【Tools】強大的密碼發生器(Strong Password Generator)

http://163.21.2.95/class96/class9602/Strong%20Password%20Generator.files/
www.google.com/ig/directory?type=gadgets...tor.xml&hl=zh-tw
http://www.ifreesite.com/password/

【Linux】 查看使用者最後登入時間 (last、lastlog)

查詢機器所有登入紀錄使用lastlog
子方法
Options:
  -b, --before DAYS     print only lastlog records older than DAYS
  -h, --help            display this help message and exit
  -t, --time DAYS       print only lastlog records more recent than DAYS
  -u, --user LOGIN      print lastlog record for user with specified LOGIN
查詢自己的登入歷史紀錄, 使用 last 查看

2011年11月24日 星期四

【Hadoop】指令備忘

hadoop jar /usr/lib/hadoop-0.20/hadoop-*-examples.jar grep input output 'dfs[a-z.]+'

hadoop dfsadmin -safemode leave

hadoop namenode -format

hadoop dfsadmin -report

hadoop fs -ls
hadoop fs -lsr
hadoop fs -rmr

bin/sqoop import --connect jdbc:mysql://hds01:3306/sqoop --table student  --username hadoop -P

【Hadoop】建置Hadoop(三)設定sqoop

修改vim sqoop/bin/configure-sqoop

將HBASE跟ZOOKEEPER 關閉((除非有使用那些服務))
#if [ ! -d "${HBASE_HOME}" ]; then
#  echo "Error: $HBASE_HOME does not exist!"
#  echo 'Please set $HBASE_HOME to the root of your HBase installation.'
#  exit 1
#fi
#if [ ! -d "${ZOOKEEPER_HOME}" ]; then
#  echo "Error: $ZOOKEEPER_HOME does not exist!"
#  echo 'Please set $ZOOKEEPER_HOME to the root of your ZooKeeper installation.'
#  exit 1
#fi

【Hadoop】疑難排除

在安裝完sqoop之後準備要跑import Mysql,
出現錯誤訊息
It seems as though you are running sqoop with a JRE.

因起先使用的JAVA是JDE  -----
所以造成這個問題,最後改成JRE後啟動正常,但依然出現錯誤訊息
cannot restore segment prot after reloc: Permission denied

解決方法:
chcon -t texrel_shlib_t /usr/java/jdk1.7.0_01//jre/lib/i386/client/libjvm.so


若發現master跟slaves機器node沒有串起來,
先查看/etc/hosts是不是有相衝的domain name對兩個ip
然後關閉iptables,然後重啟hadoop,再report看一下

串起來後還有一個問題是mysql的連接,因為分散掉資料運算,所以除了本機機器外,其它機器需授權讀取master本機的資料庫,所以要到資料庫中設定一組新的專用於hadoop讀取用的機器

解決方法:

GRANT ALL PRIVILEGES ON *.* TO <帳號>@'<本機ip或domain name>' IDENTIFIED BY '<密碼>';  --------注意! 此指令權限是全開的
以上指令要做兩次
第二次的指令為
GRANT ALL PRIVILEGES ON *.* TO <帳號>@'%' IDENTIFIED BY '<密碼>';  --------注意! 此指令權限是全開的

%代表外部所有連入接受

Mysql資料來源:http://itzone.hk/article/article.php?aid=200406230146464878

如果輸出時已有該資料夾會造成hadoop error
例如:曾輸出資料夾output,要再輸出一個新的資料夾output的話,需要把舊的刪除或是用新的名字輸出 

【JAVA】JDK和JRE的差別

JDK和SDK其實我們通常指的都是同一個東西, 而JDK與JRE的差別是, JDK可以拿來編譯你所寫的Java程式, 如果你想要學Java, 就請裝JDK, 如果只是要執行Java的程式, 你只要裝JRE就可以了. (JRE是JDK的子集) 

資料來源:http://chuan.no-ip.org/blog/?p=215