KFS部署與應用

[b][color=red]原創文章:轉載請註明出處http://wangwei3.iteye.com/blog/905856[/color][/b]

[b]安裝軟件[/b]

[b]一、安裝依賴軟件[/b]
1、安裝log4cpp
tar xvzf log4cpp-1.0.tar.gz
cd log4cpp-1.0
./configure
make
make install

2、安裝xfs
tar xvzf xfsprogs-3.0.1.tar.gz
cd xfsprogs-3.0.1
./configure
make
make install
make install-dev

3、安裝cmake
tar xvzf cmake-2.6.4.tar.gz
cd cmake-2.6.4
./bootstrap
make
make install

4、安裝boost
tar xvzf boost_1_39_0.tar.gz
cd boost_1_39_0

5、安裝fuse

[color=red]
安裝軟件還有一個簡單的方法:apt-get install 軟件名。例如(apt-get install rails)

如果是桌面版那麼安裝軟件會容易的多。
只需要 system->Administration->Synaptic Package Manager 搜索到你需要安裝的軟件後 右鍵Mark for Installation[/color]

SSH
檢查ssh localhost命令是否需要密碼。 如果沒有,執行下列命令:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

[b]二、開始編譯[/b]
mkdir ~/code
cd ~/code
安裝SVN
用SVN下載項目svn co https://kosmosfs.svn.sourceforge.net/svnroot/kosmosfs/trunk kfs
上面的kfs是下載到的目錄

本文假設KFS目錄: ~/code/kfs. 爲了支持FUSE(fuse version 2.7.3 or higher). 編輯 ~/code/kfs/CMakeLists.txt

SET(Fuse_LIBRARY_DIR "/usr/local/lib")
SET(Fuse_INCLUDE_DIR "/usr/local/include")


1. cd ~/code/kfs
2. mkdir build
3. cd build

選擇下列三個其中一個
4.1 cmake ~/code/kfs/ #-- will build DEBUG binaries by default
4.2 cmake -DCMAKE_BUILD_TYPE:STRING="Release" ~/code/kfs #-- will build Release binaries by default
4.3 cmake -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" ~/code/kfs #-- will build reldbg binaries by default
[color=red]官網建議用4.3來生成[/color]

5. gmake
6. gmake install
[color=red]如果gmake不行用make也是一樣的[/color]

生成如下文件夾

Executables will be in: ~/code/kfs/build/bin
Libraries will be in: ~/code/kfs/build/lib


生成JAVA支持:

1. cd ~/code/kfs
2. ant jar

得到如下文件
* ~/code/kfs/build/classes --- This will contain the Java class files
* ~/code/kfs/build/kfs.jar --- The jar file containing the Java classes

將jar加到 CLASSPATH 環境變量

#export CLASSPATH=${CLASSPATH}:~/code/kfs/build/kfs-[version].jar

生成 Python 支持

1. cd to ~/code/kfs/src/cc/access
2. 編輯 kfs_setup.py ,設置include 路徑
kfsext = Extension('kfs', include_dirs ['~/code/kfs/src/cc/', '<path to boost>'])
3. python kfs_setup.py ~/code/kfs/build/lib/ build #生成共享庫文件_kfs.so_.
4. python kfs_setup.py ~/code/kfs/build/lib/ install #To install in site-packages for python:

(
安裝在其它路徑如: ~/code/kfs/build/lib
python kfs_setup.py ~/code/kfs/build/lib install --home=~/code/kfs/build/lib

如果安裝在其它路徑,更新 PYTHONPATH 、LD_LIBRARY_PATH環境變量:
export PYTHONPATH=${PYTHONPATH}:~/code/kfs/build/lib/lib64/python
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:~/code/kfs/build/lib
)

[b]開始部署[/b]
有兩種部署方式:
-單機部署:metaserver/chunkserver都運行在同一臺機器
-分佈式部署:服務運行在一組機器

爲了區分兩種部署方式,配置文件定義了三個變量:
* node: This defines the machine name where the binary should run
* rundir: This defines the directory on the machine where KFS binaries will be installed.
* baseport: This port at which the metaserver/chunkserver process will listen for connection from clients
* loglevel: The level for outputting messages. Since KFS uses log4cpp, the values are INFO/DEBUG

metaserver的配置變量:
* backup_path: This can be used to specify the (remote) location to
which the metaserver checkpoint files should be backed up to.

* clusterkey : A key that is shared between metaserver/chunkserver.

chunkservers的配置變量:
* space: The storage space exported by a chunkserver for storing chunks (units are 'G' for GigaBytes and 'M' for MegaBytes)
* chunkDir : The list of directories used to store chunk files on the chunkserver nodes.
For a JBOD configuration, this would be a space separated list of directory names.

默認
- meta 服務的 checkpoint/log文件存儲路勁
${rundir}/bin/kfscp and ${rundir}/bin/kfslog
- chunkserver 服務的 checkpoint/log文件存儲路勁
${rundir}/bin/logs
- chunkserver's chunks are stored in ${rundir}/bin/kfschunk. This
value is overridden when "chunkdir" variable is defined for a chunkserver.


NOTE: It is not advisable to change the default location for either
server's checkpoint/log files. Changing them adversely affects the
other helper scripts that are provided (such as, backing up the meta
server's logs/checkpoint files, periodically cleaning out old
checkpoint/log files).

以下文件都在/code/kfs/scripts目錄下
兩種配置文件格式. 定義所有服務環境的配置文件:machines.cfg:

[metaserver]
node: machine1(機器名或者IP)
clusterkey: kfs-test-cluster
rundir: /mnt/kfs/meta
baseport: 20000
loglevel: INFO
numservers: 2
[chunkserver_defaults]
rundir: /mnt/kfs/chunk
chunkDir: /mnt/kfs/chunk/bin/kfschunk
baseport: 30000
space: 3400 G
loglevel: INFO

例出所有節點的配置文件:machines.txt. (自己手工寫)

10.2.3.1(IP)
10.2.3.2(IP)
10.2.3.3(IP)

To install the KFS binaries, perform the following steps:

1. cd ~/code/kfs/scripts
2. 設置好配置文件
3. 運行:
#--所有服務在同一臺主機--
python kfssetup.py -f machines.cfg -m machines.txt -b ../build -w ../webui -s
#--服務在多臺主機--
python kfssetup.py -f machines.cfg -m machines.txt -b ../build -w ../webui
[color=red]"-m" 只支持 KFS-0.2.3 或更高版本[/color]

運行KFS

cd ~/code/kfs/scripts
python kfslaunch.py -f machines.cfg -m machines.txt -s

如果想單獨關閉某個 chunkserver ,則可以在 chunkserver 中執行以下命令:
sudo scripts/kfsrun.sh -S -c -f bin/ChunkServer.prp
這樣只會關閉這個 chunkserver ,而不影響其他 server.

關閉後重新啓動: scripts/kfsrun.sh -s -c -f bin/ChunkServer.prp

停止KFS

cd ~/code/kfs/scripts
python kfslaunch.py -f machines.cfg -m machines.txt -S

監控界面
http://ip(metaserver):20050/

進入shell
cd ~/code/kfs/build/bin
tools/kfsshell -s ip(metaserver) -p 端口(默認爲20000)
用help查看下命令吧
你可以用mkdir test來創建文件等等。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章