原创文章:转载请注明出处http://wangwei3.iteye.com/blog/905856
安装软件
一、安装依赖软件
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
安装软件还有一个简单的方法:apt-get install 软件名。例如(apt-get install rails)
如果是桌面版那么安装软件会容易的多。
只需要 system->Administration->Synaptic Package Manager 搜索到你需要安装的软件后 右键Mark for Installation
SSH
检查ssh localhost命令是否需要密码。 如果没有,执行下列命令:
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
二、开始编译
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
官网建议用4.3来生成
5. gmake
6. gmake install
如果gmake不行用make也是一样的
生成如下文件夹
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
)
开始部署
有两种部署方式:
-单机部署: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
"-m" 只支持 KFS-0.2.3 或更高版本
运行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来创建文件等等。