本教學使用14.04 LTS進行示範

  1. Python
  2. Apache Solr
  3. PostgreSQL
  4. CKAN 

 

建置流程


下載相關套件

Install the required packages

sudo apt-get install python-dev postgresql libpq-dev python-pip python-virtualenv git-core solr-jetty openjdk-6-jdk

 

Install CKAN into a Python virtual environment

sudo mkdir -p /usr/lib/ckan/default
sudo chown 'whoami' /usr/lib/ckan/default
virtualenv --no-site-packages /usr/lib/ckan/default
. /usr/lib/ckan/default/bin/activate

 

 

Create a Python virtual environment (virtualenv) to install CKAN into, and activate it

 

sudo mkdir -p /usr/lib/ckan/default
sudo chown `whoami` /usr/lib/ckan/default
virtualenv --no-site-packages /usr/lib/ckan/default

 

Install the CKAN source code into your virtualenv To install the latest stable release of CKAN (CKAN 2.4.0)

 

pip install -e 'git+https://github.com/ckan/ckan.git@ckan-2.4.0#egg=ckan'
pip install -r /usr/lib/ckan/default/src/ckan/requirements.txt

 


安裝設定 PostgreSQL

Setup a PostgreSQL database 

sudo -u postgres psql -l

sudo -u postgres createuser -S -D -R -P ckan_default
sudo -u postgres createdb -O ckan_default ckan_default -E utf-8

Create a CKAN config file

sudo mkdir -p /etc/ckan/default
sudo chown -R `whoami` /etc/ckan/

cd /usr/lib/ckan/default/src/ckan
paster make-config ckan /etc/ckan/default/development.ini

設定Jetty

Edit development.ini ( 1 / 3)

Edit development.ini ( 2 / 3)

 

Edit development.ini ( 3 / 3)

Edit the Jetty configuration file

/etc/default/jetty

Restart jetty

sudo service jetty start


安裝設定 Solr

下載 solr

wget http://archive.apache.org/dist/lucene/solr/4.7.2/solr-4.7.2.tgz

tar solr-4.7.2.tgz

tar –zxvf solr-4.7.2.tgz

 

Install Solr ( 1 / 6 )

sudo cp solr-4.7.2.war /usr/share/jetty/webapps/solr

複製以下目錄至指定位置:
複製 ./example/solr 至 /usr/share
複製 ./contrib 至 /usr/share/solr/bin
複製 ./dist 至 /usr/share/solr
修改 solr 目錄權限,使 jetty 可以存取:

Install Solr ( 3 / 6 )

sudo chown -R jetty:adm /usr/share/solr

Install Solr ( 4 / 6 )

sudo mv /usr/share/solr/collection1/conf/schema.xml /usr/share/solr/collection1/conf/schema.xml.bak
sudo ln -s /usr/lib/ckan/default/src/ckan/ckan/config/solr/schema-2.0.xml /usr/share/solr/collection1/conf/schema.xml

Install Solr ( 5 / 6 )

jar -xvf solr.war

Install Solr ( 6 / 6 )

複製 b. 所下載之 solr 壓縮檔中之 ./example/lib/ext 下的所有 jar 檔案至 /usr/share/jetty8/webapps/solr/WEB-INF/lib

承上,複製 ./example/resources/log4j.properties 至 /usr/share/jetty8/webapps/solr/WEB-INF/classes

Install IKAnalyzer ( 1 / 2)

Sudo weget IKAnalyzer https://ik-analyzer.googlecode.com/files/IK%20Analyzer%202012FF_hf1.zip
unzip …

Install IKAnalyzer ( 2 / 2)

複製 IKAnalyzer2012FF_fh1.jar 至 /var/lib/jetty8/webapps/solr/WEB-INF/lib

複製 IKAnalyzer.cfg.xml 和 stopword.dic 至 /var/lib/jetty8/webapps/solr/WEB-INF/class

modify schema.xml

fieldType name=”text” replay

<fieldType name="text" class="solr.TextField">
   <analyzer type="index" class="org.wltea.analyzer.lucene.IKAnalyzer" isMaxWordLength="false"/>
   <analyzer type="query" class="org.wltea.analyzer.lucene.IKAnalyzer" isMaxWordLength="false"/>
   <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
   <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
   <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
   <filter class="solr.LowerCaseFilterFactory"/>
   <filter class="solr.ASCIIFoldingFilterFactory"/>
</fieldType>

schema.xml 位於 /usr/share/solr/collection1/conf/schema.xml

Restart  jetty

sudo service jetty start

確認Solr是否安裝成功

在瀏覽器輸入 http://127.0.0.1:8983/sol 測試是否安裝成功。


配置啟動CKAN

cd /usr/lib/ckan/default/src/ckan
paster db init -c /etc/ckan/default/development.ini

Add ckan Adminstrator

paster sysadmin add admin -c /etc/ckan/default/development.ini

透過 paster serve 新安裝的 ckan instance

paster serve /etc/ckan/default/development.ini

CKAN 安裝完成

預設PORT 為 5000。http://{IP}:5000/

arrow
arrow
    文章標籤
    opendata
    全站熱搜
    創作者介紹
    創作者 Lung-Yu,Tsai 的頭像
    Lung-Yu,Tsai

    Lung-Yu,Tsai 的部落格

    Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣()