顯示具有 KFS 標籤的文章。 顯示所有文章
顯示具有 KFS 標籤的文章。 顯示所有文章

2012年8月20日 星期一

handout about building hypertable-0.9.6.1 (tarball)

Evironment:
       host : CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        7891424 kB(/proc/meminfo)
       CPU(Quad core)      : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
       HDD: 1TB*2 (LVM ==> 2T)
       

       guest: CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        1G
       CPU *1
       HDD: 100GB 

yum install gcc gcc-c++ make ntpdate cmake java-1.6.0-openjdk java-1.6.0-openjdk-devel
yum install icu libicu libicu-devel   #for libboost_regex.so
rpm -Uvh http://ftp.sjtu.edu.cn/sites/download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
yum install log4cpp log4cpp-devel expat expat-devel uuid uuid-devel libuuid libuuid-devel python python-devel fuse fuse-libs fuse-devel openssl openssl-devel ant zlib-devel

rpm -ivh xfsprogs-3.1.1-7.el6.x86_64.rpm xfsprogs-devel-3.1.1-7.el6.x86_64.rpm

yum install sigar sigar-devel bzip2 bzip2-devel rrdtool libevent-devel cronolog libedit-devel readline readline-devel
#if you need jemalloc jemalloc-devel , then install it via yum instal...

/usr/sbin/ntpdate -b time.stdtime.gov.tw;/sbin/hwclock --systohc --utc

cd /usr/local
wget http://hi.baidu.com/cpuramdisk/item/3410d0ccc53e3f0b0ad93a00
#or
#wget http://download.oracle.com/berkeley-db/db-4.8.26.tar.gz
tar -zxvf db-4.8.26.tar.gz
cd db-4.7.25/build_unix/
../dist/configure --enable-cxx (--enable-java;)(root permission is neccessary)
make
make install
echo “/usr/local/BerkeleyDB.4.8/lib” >> /etc/ld.so.conf.d /BerkeleyDB.conf
sudo /sbin/ldconfig

#I had been installed for boost-1.41.x via yum, but hypertable may not be built successful, an error
#hypertable struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >
#when you re-install boost_1_49_0 as below, you may need to re-build kfs too.
#I recommend you remove /usr/local/kfs-0.5/build , and re-build it . Otherwise, you will get errors.
#That errors will be something link "libboost_regex-mt.so ..."
cd /usr/local
wget http://nchc.dl.sourceforge.net/project/boost/boost/1.49.0/boost_1_49_0.tar.gz
tar -zxvf boost_1_49_0.tar.gz
cd boost_1_49_0/tools/build/v2/
./bootstrap.sh
./b2 install --prefix=/usr/local
cd /usr/local/boost_1_49_0/
./bootstrap.sh --with-icu --with-libraries=regex,filesystem,chrono,date_time,exception,iostreams,locale,program_options,python,random,serialization,signals,system,test,thread,timer,wave
./b2
./b2 install
ln -s /usr/local/boost_1_49_0/stage/lib/libboost_regex.a /usr/lib64/libboost_regex.a
ln -s /usr/local/boost_1_49_0/stage/lib/libboost_regex.so /usr/lib64/libboost_regex.so
ln -s /usr/local/boost_1_49_0/stage/lib/libboost_regex.so.1.49.0 /usr/lib64/libboost_regex.so.1.49.0


cd /usr/local
wget http://ftp.heanet.ie/mirrors/sourceforge/k/project/ko/kosmosfs/kosmosfs/kfs-0.5/kfs-0.5.tar.gz
tar -zxvf kfs-0.5.tar.gz
mkdir -p kfs-0.5/build
cd kfs-0.5/build
vi ../CMakeLists.txt
#line 110(after  'set (CMAKE_BUILD_TYPE "Debug")' ) : add 2 lines java setting
    set (JAVA_INCLUDE_PATH "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include")
   set (JAVA_INCLUDE_PATH2 "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include")

#line 137: fill fuse setting
SET(Fuse_LIBRARY_DIR "/lib64")
SET(Fuse_INCLUDE_DIR "/usr/include")

cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo /usr/local/kfs-0.5
gmake
gmake install

cd ..
ant jar

vi ~/.bashrc
export CLASSPATH=${CLASSPATH}:/usr/local/kfs-0.5/build/kfs-0.5.jar

cd /usr/local/kfs-0.5/src/cc/access
vi kfs_setup.py
kfsext = Extension('kfs',
                include_dirs = ['/usr/local/kfs-0.5/src/cc/', '/usr/local/include/boost/'],
## use full path name in it.

python kfs_setup.py /usr/local/kfs-0.5/build/lib/ build
python kfs_setup.py /usr/local/kfs-0.5/build/lib/ install
python kfs_setup.py /usr/local/kfs-0.5/build/lib/ install --home=/usr/local/kfs-0.5/build/lib


vi ~/.bashrc
export PYTHONPATH=${PYTHONPATH}:/usr/local/kfs-0.5/build/lib/lib64/python
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/kfs-0.5/build/lib


wget http://mirror.yandex.ru/mandriva/devel/cooker/SRPMS/contrib/release/re2-0-1.src.rpm
rpm -ivh re2-0-1.src.rpm
cd ~/rpmbuild/SOURCES/
tar -zxvf re2.tar.gz
cd re2
make;make install

cd /usr/local
wget http://snappy.googlecode.com/files/snappy-1.0.4.tar.gz
tar -zxvf snappy-1.0.4.tar.gz
cd snappy-1.0.4
./configure; make; make install

#<optional> if you don't need ceph file system, skip this step
cd /usr/local
wget http://ceph.newdream.net/download/ceph-0.22.2.tar.gz
tar xzvf ceph-0.49.tar.gz
cd ceph-0.49
./configure; make; make install

cd /usr/local
wget http://archive.apache.org/dist/thrift/0.8.0/thrift-0.8.0.tar.gz
tar -zxvf thrift-0.8.0.tar.gz
cd  thrift-0.8.0
./configure
make
make install
/sbin/ldconfig

wget http://magelan.googlecode.com/files/hyperic-sigar-1.6.4.zip
unzip hyperic-sigar-1.6.4.zip
cp hyperic-sigar-1.6.4/sigar-bin/include/*.h /usr/local/include
cp hyperic-sigar-1.6.4/sigar-bin/lib/libsigar-amd64-linux.so /usr/local/lib


echo "/usr/local/lib" >> /etc/ld.so.conf.d/normal.conf
/sbin/ldconfig


cd /usr/local
http://hypertable.googlecode.com/files/hypertable-0.9.6.1-src.tar.gz
tar -zxvf hypertable-0.9.6.1-src.tar.gz
cd hypertable-0.9.6.1

#if you don't wanna kosmosBroker, skip this step
vi CMakeLists.txt
#update "find_package(Kfs)" into
find_package(Kfs REQUIRED)

vi cmake/FindKfs.cmake
#Add a line about Line 33: (after "find_path(Kfs_INCLUDE_DIR kfs/KfsClient.h "...)
  /usr/local/kfs-0.5/build/include

#Update  Line 42:  (after  "find_library(${lib}_LIB NAMES ${lib}")
#before
  find_library(${lib}_LIB NAMES ${lib}
    PATHS /opt/kfs/lib/static /opt/kfs/lib /opt/local/lib /usr/local/lib
#after
  find_library(${lib}_LIB NAMES ${lib}
    PATHS /opt/kfs/lib/static /opt/kfs/lib /opt/local/lib /usr/local/lib /usr/local/kfs-0.5/build/lib

#Add a line about Line 54: (after "find_library(Crypto_LIB "...)
find_library(regex_LIB NAMES boost_regex PATHS /usr/local/lib)

#Update  Line 59:  (after  "if (Kfs_INCLUDE_DIR AND kfsClient_LIB)...")
#before
if (Kfs_INCLUDE_DIR AND kfsClient_LIB)
  set(Kfs_FOUND TRUE)
  set( Kfs_LIBRARIES ${kfsClient_LIB} ${kfsIO_LIB} ${kfsCommon_LIB}
                     ${qcdio_LIB} ${Crypto_LIB})

#after
if (Kfs_INCLUDE_DIR AND kfsClient_LIB)
  set(Kfs_FOUND TRUE)
  set( Kfs_LIBRARIES ${kfsClient_LIB} ${kfsIO_LIB} ${kfsCommon_LIB}
                     ${qcdio_LIB} ${Crypto_LIB} ${regex_LIB})

mkdir build
cd build
cmake ../
gmake
gmake install
#all bin file default will copy to /opt/hypertable/.

--------------------------KFS Deployment----------------------------------------------------


ssh-keygen -t dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

cd /usr/local/kfs-0.5/scripts

vi ../webui/all-machines.txt
HT248

vi machines.cfg
# KFS Machine configuration file
[metaserver]
node: HT248
clusterkey: kfs
rundir: /home/kfs/meta
baseport: 20000
[chunkserver1]
node: HT248
rundir: /home/kfs/chunk1
baseport: 30000
space: 200 G
[chunkserver2]
node: HT248
rundir: /home/kfs/chunk2
baseport: 40000
space: 200 G


#single node
python kfssetup.py -f machines.cfg -b ../build -w ../webui -s

#multiple nodes
python kfssetup.py -f machines.cfg  -b ../build -w ../webui

#startup

python kfslaunch.py -f machines.cfg  -s
# after startup kfs , if webui didn't listen 20050 port . you should :
# (1) stop kfs
# (2) remove /home/kfs directory
# (3) re-setup kfs (python kfssetup.py -f machines.cfg ...)
# (4) check server.conf and all-machines.txt are exist at /home/kfs/meta/webui/
# (5) if webui config is ok , startup kfs . you could elinks to 20050 port
#      otherwise , go step (1) again.


#stop
python kfslaunch.py -f machines.cfg  -S

#Checking
/usr/local/kfs-0.5/build/bin/tools/kfsping -m -s HT248 -p 20000
Up servers: 2
s=192.168.65.155, p=30000, rack=65, used=0(GB), free=43.8144(GB), util=0%, nblocks=0, lastheard=8 (sec), ncorrupt=0, nchunksToMove=0, numDrives=1
s=192.168.65.155, p=40000, rack=65, used=0(GB), free=43.8144(GB), util=0%, nblocks=0, lastheard=8 (sec), ncorrupt=0, nchunksToMove=0, numDrives=1

/usr/local/kfs-0.5/build/bin/tools/kfsping -c -s HT248 -p 20000
Meta-server:  0
Total-space: 0 (MB)
Used-space: 0 (MB)

/usr/local/kfs-0.5/build/bin/tools/kfsping -c -s HT248 -p 30000
Meta-server: kfs 20100
Total-space: 44866 (MB)
Used-space: 0 (MB)

/usr/local/kfs-0.5/build/bin/tools/kfsping -c -s HT248 -p 40000
Meta-server: kfs 20100
Total-space: 44866 (MB)
Used-space: 0 (MB)


elinks -dump http://HT248:20050/

                                    KFS Status

   Started at               : Tue Aug 21 11:32:37 2012
   Total space              : 400.00 GB
   Used space               : 0.00 bytes
   WORM mode                : Disabled
   Number of alive nodes    : 2
   Number of dead nodes     : 0
   Number of retiring nodes : 0

                                All Nodes
    Chunkserver  # of drives Used   Free   Used% # of blocks Last heard
   172.16.43.248      1      0(GB) 200(GB) 0.00            0   11 (sec)
   172.16.43.248      1      0(GB) 200(GB) 0.00            0   11 (sec)

cd /usr/local/kfs-0.5/build/bin/tools

[root@kfs tools]# ./cptokfs -s HT248 -p 20000 -d ~/install.log -k /
08-17-2012 12:44:19.994 DEBUG - (KfsClient.cc:636) Connecting to metaserver at: kfs:20000

[root@kfs tools]# ./cpfromkfs -s HT248 -p 20000 -d ~/sean.ply -k /install.log
08-17-2012 12:46:32.648 DEBUG - (KfsClient.cc:636) Connecting to metaserver at: kfs:20000
[root@kfs tools]# diff ~/sean.ply ~/install.log


[root@kfs tools]# dd if=/dev/urandom of=/root/random bs=65536 count=1024
1024+0 records in
1024+0 records out
67108864 bytes (67 MB) copied, 7.49119 s, 9.0 MB/s
[root@kfs tools]# ./cptokfs -s kfs -p 20000 -d ~/random -k /
08-17-2012 13:22:14.467 DEBUG - (KfsClient.cc:636) Connecting to metaserver at: kfs:20000
[root@kfs tools]# ./cpfromkfs -s kfs -p 20000 -d ~/random.back -k /random
08-17-2012 13:22:44.098 DEBUG - (KfsClient.cc:636) Connecting to metaserver at: kfs:20000
[root@kfs tools]# md5sum ~/random
9c9bc92c27e40ef7e54b6f858d3d2852  /root/random
[root@kfs tools]# md5sum ~/random.back
9c9bc92c27e40ef7e54b6f858d3d2852  /root/random.back


[root@kfs tools]# ./kfsshell -s HT248 -p 20000
KfsShell> ls -l
aabb/   Aug 16 17:23    (dir)
boost_1_40_0.tar.gz     Aug 16 18:07    4096
cshrc   Aug 16 16:43    100
db-4.8.26.tar.gz        Aug 16 16:37    4096
dumpster/       Aug 16 16:29    (dir)
install.log     Aug 17 12:44    15470
testkfs Aug 17 10:01    4096
user/   Aug 16 17:16    (dir)

或者

[root@kfs tools]# cd /root/code/kfs/scripts
[root@kfs scripts]# vi kfsshell.py
#    cmd = "%s/tools/KfsShell -s %s -p %d" % (bindir, node, port)
    cmd = "%s/tools/kfsshell -s %s -p %d" % (bindir, node, port)
[root@kfs scripts]# python kfsshell.py -f machines.cfg -b /root/code/kfs/build/bin
KfsShell>

------------------------------Mount Fuse----------------------------------------------------


vi /usr/local/kfs-0.5/build/bin/kfs.prp
metaServer.name=HT248
metaServer.port=20000

cd /usr/local/kfs-0.5/scripts
python kfslaunch.py -f machines.cfg  -s


[root@kfs scripts]# cd ../build/bin
[root@kfs bin]# mkdir /mnt/kfs
[root@kfs bin]# ./kfs_fuse /mnt/kfs -f

--------------------------KFS MakeFile of Examples------------------------------------------

AR=ar
ARFLAGS=-cr
RL=ranlib
RLFLAGS=
CC=g++
CXXFLAGS=-I. -Wall
CP=cp
LDFLAGS=
ifneq ($(RELEASE),yes)
CXXFLAGS += -g
LDFLAGS += -g
endif
CXXFLAGS += -I../src/cc/ -I/usr/include/ -I../src/cc/libkfsClient/
LDFLAGS += -L../build/lib/static/
EXTLIBS=-lkfsClient -lkfsCommon -lkfsIO -lqcdio -lpthread -lrt -lssl
DOWNLOAD_SRC= \ KfsSample_main.cc OBJ_DOWNLOAD=$(DOWNLOAD_SRC:.cpp=.o,.cc=.o)
TARGETS=testkfs
all: $(TARGETS)
testkfs: $(OBJ_DOWNLOAD)
    $(CC) $(LDFLAGS) $(CXXFLAGS) -o $@ $^ $(EXTLIBS)
%.o:%.cpp
    $(CC) $(CXXFLAGS) -c -o $@ $<
clean:
    rm -f *~ $(OBJS) $(TARGETS)

#testing
./testkfs  -s 192.168.65.155 -p 20000


[FAQ]

(1)boost version maybe cause problem(error) when hypertable making source code , such as
       hypertable struct std::basic_string<char, std::char_traits<char>, std::allocator<char> > ...
   see boost installation recommend above.
(2)libboost_regex.so may cause a error in 98% progression. because kosmosBroker could not find it.
   vi /usr/local/hypertable-x.x.x.x/cmake/FindKfs.cmake , and reference above see what you could do in it.
(3) rpm and yum
   1) find something in yum server, for example libcrypto.so.6
     yum provides \*/libcrypto.so.6
   2) find something in rpm that already installed
     rpm -ql vsftpd

     <if not installed , and you got the rpm file>
     rpm -qpl vsftpd.x.x.rpm

     <rpm infomation>
     rpm -qi(p) vsftpd(.x.x.rpm)

     <what rpm package do the shell command when installing>
     rpm -q(p) --scripts vsftpd(.x.x.rpm)

     <rpm version number>
     rpm -q(p) --qf '%{VERSION}' vsftpd(.x.x.rpm)
          
    

2012年8月10日 星期五

[KFS](KosmosFS) 安裝方法二

這次修改原本的安裝,多數以rpm packages安裝為主
(1)系統環境準備
    此次使用的環境,使用為virtual machine來實現
       host : CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        7891424 kB(/proc/meminfo)
       CPU(Quad core)      : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
       HDD: 1TB*2 (LVM ==> 2T)
       

       guest: CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        1G
       CPU *1
       HDD: 100GB

       KFS的環境使用virtual machine的NAT環境,也把dhcp打開
       guest總共佈建4台,1台metaserver, 3台chunkserver
       這4台/etc/hosts設定如下
         192.168.65.1 mserver    #yum/ftp server
         192.168.65.150 t01nn    #metaserver
         192.168.65.151 t01d1    #chunkserver1
         192.168.65.152 t01d2    #chunkserver2
         192.168.65.153 t01d3    #chunkserver3
(2)系統安裝
使用kickstart檔來進行初期的部署(4台guest都照此安裝),所有rpm在這個階段都安裝完成,簡單描述幾個重點
        :
        selinux --disabled
        firewall --disabled
        :

        bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
        :
        #在host,我們佈建了vsftpd以及httpd,
        #預設在/var/ftp/pub,/var/www/html(soft link to /var/ftp/pub)
        install
        url --url=http://192.168.65.1/pub
        :
        clearpart --drives=sda --all --initlabel
        part / --asprimary --fstype="ext4" --ondisk=sda --grow --size=1024
        part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
        part swap --fstype="swap" --ondisk=sda --recommended
        :


        #這裡將要安裝的套件一併在下面一一指定安裝
        %packages
        @core
        @server-policy
        ftp
        telnet
        ntpdate
        gcc
        gcc-c++
        make
        cmake
        log4cpp
        boost
        boost-devel
        expat
        openssl-devel
        java-1.6.0-openjdk
        java-1.6.0-openjdk-devel
        uuid
        uuid-devel
        libuuid
        libuuid-devel
        ant
        python
        python-devel

        fuse-devel
        fuse-libs
        %end

        %post
        #接下來的設定,可依個人喜好,把系統預設安裝的設定項,在這裡一併完成
        #筆者在這裡接連把下列的設定一併完成
        # 1.  /etc/sysconfig/network-scripts/ifcfg-eth0  設定網卡
        # 2.  /etc/sysconfig/network   設定hostname
        #      /etc/hosts
        #      /etc/resolv.conf
        # 3.  安裝xfsprogs相關套件,由於預設CentOS 6.0的安裝光碟沒有,於是下載後
        #      置入yum/ftp server上,在%post時補充安裝
        #      xfsprogs-3.1.1-7.el6.x86_64.rpm
        #      xfsprogs-devel-3.1.1-7.el6.x86_64.rpm

        # 4.  kfs-0.5.tar.gz的安裝 --> /usr/local/kfs-0.5
        #      詳細安裝可見[KFS](KosmosFS) 安裝方法一
        # 5.  /usr/local/kfs-0.5/scripts/machines.cfg
        # 6.  /usr/local/kfs-0.5/conf/machines.txt
        # 7.  /usr/local/kfs-0.5/conf/ChunkServer.prp
        # 8.  Fuse掛載KFS
        #      詳細安裝可見KFS mount by Fuse
        # 9.  設定方便的scripts, 可將kfs setup, start, stop及mount等 指令設置成scripts
        # 10. 更新套件,如果在這個步驟啟動KFS,fuse mount KFS時,
        #       可能會發生coredump。有可能的原因Centos 6.0是預設rpm套件太舊。
        #       筆者經過以下套件更新後,KFS mount即恢復正常(沒有一一試過是哪個太舊)
        #       如果不想輸入這麼長的一串更新套件,可以直接連上Centos 預設的yum server
        #       進行yum update即可
        #        rpm -Uvh ~/pkgs/boost-1.41.0-11.el6_1.2.x86_64.rpm  \
        #                       ~/pkgs/boost-date-time-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-devel-1.41.0-11.el6_1.2.x86_64.rpm  \
        #                       ~/pkgs/boost-filesystem-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-graph-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-iostreams-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-program-options-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-python-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-regex-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-serialization-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-signals-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-system-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-test-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-thread-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/boost-wave-1.41.0-11.el6_1.2.x86_64.rpm \
        #                       ~/pkgs/cpp-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/expat-2.0.1-11.el6_2.x86_64.rpm \
        #                       ~/pkgs/fuse-devel-2.8.3-4.el6.x86_64.rpm \
        #                       ~/pkgs/fuse-libs-2.8.3-4.el6.x86_64.rpm \
        #                       ~/pkgs/gcc-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/gcc-c++-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/libblkid-2.17.2-12.7.el6.x86_64.rpm \
        #                       ~/pkgs/libgcc-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/libgomp-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/libstdc++-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/libstdc++-devel-4.4.6-4.el6.x86_64.rpm \
        #                       ~/pkgs/libuuid-2.17.2-12.7.el6.x86_64.rpm \
        #                       ~/pkgs/libuuid-devel-2.17.2-12.7.el6.x86_64.rpm \
        #                       ~/pkgs/make-3.81-20.el6.x86_64.rpm \
        #                       ~/pkgs/ntpdate-4.2.4p8-2.el6.centos.x86_64.rpm \
        #                       ~/pkgs/openssl-1.0.0-20.el6_2.5.x86_64.rpm \
        #                       ~/pkgs/openssl-devel-1.0.0-20.el6_2.5.x86_64.rpm \
        #                       ~/pkgs/python-2.6.6-29.el6_2.2.x86_64.rpm \
        #                       ~/pkgs/python-devel-2.6.6-29.el6_2.2.x86_64.rpm \
        #                       ~/pkgs/python-libs-2.6.6-29.el6_2.2.x86_64.rpm \
        #                       ~/pkgs/telnet-0.17-47.el6.x86_64.rpm \
        #                       ~/pkgs/util-linux-ng-2.17.2-12.7.el6.x86_64.rpm \
        #                       ~/pkgs/java-1.6.0-openjdk-1.6.0.0-1.48.1.11.3.el6_2.x86_64.rpm \
        #                       ~/pkgs/java-1.6.0-openjdk-devel-1.6.0.0-1.48.1.11.3.el6_2.x86_64.rpm

 (3)系統啟動
     系統啟動需要再執行以下作業
     1)ssh password-less
        利用這篇ssh password-less session config的做法 ,將t01nn, t01d1, t01d2, t01d3這幾台都設定為彼此不需要密碼登入
     2)在t01d1, t01d2, t01d3都執行以下指令
           rsync -av /usr/local/kfs-0.5/ t01d1:/usr/local/kfs-0.5/
           rsync -av /usr/local/kfs-0.5/ t01d2:/usr/local/kfs-0.5/
           rsync -av /usr/local/kfs-0.5/ t01d3:/usr/local/kfs-0.5/
    3)setup your KFS
         cd /usr/local/kfs-0.5/scripts
          python kfssetup.py -f machines.cfg -m ../conf/machines.txt -b ../build -w ../webui
    4) start up your KFS
          python /usr/local/kfs-0.5/scripts/kfslaunch.py -f /usr/local/kfs-0.5/scripts/machines.cfg -m /usr/local/kfs-0.5/conf/machines.txt -s

    5) mount your KFS
         /usr/local/kfs-0.5/build/bin/kfs_fuse /mnt/kfs -f -o allow_other
     
後記:
目前的安裝方法,己經縮短安裝時間, 約20分鐘即可在Virtual Machine將這4台KFS架設完成,但為求日後便利:
1)可以製作便利的ssh password-less scripts, 日後在主機異動時,可以快速設定
2)  可以製作便利的server-cnf-update scripts, 便利日後主機異動時,更新設定
     machines.txt machines.cfg ChunkServer.prp
     rsync...
3)自製kfs rpm,讓安裝更快速便利(目前kfs安裝約要5分鐘左右)且更適合大量部署
     

2012年7月31日 星期二

hadoop with hdfs and kfs on CentOS 6 x86_64 -- single node


(1)Environment: (@vmware)

    host : CentOS-6.0
    kernel: 2.6.32-71.el6.x86_64 #1 SMP
    MemTotal: 7891424 kB(/proc/meminfo)
    CPU(Quad core) : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
    HDD: 1TB*2 (LVM ==> 2T)

    guest: CentOS-6.0 *2 (hadoop/hdfs and kfs)
    kernel: 2.6.32-71.el6.x86_64 #1 SMP
    MemTotal: 1G
    CPU *1
    HDD: 100GB
    hostname for kfs : metaserver

    hostname for hdfs/hadoop : nn-01
    /etc/hosts
        192.168.65.142 nn-01 hadoop1 ## single node for  hadoop with hdfs
        192.168.65.135 metaserver ## single node for kfs

(2)kfs installation
    see [KFS](KosmosFS) 安裝方法一

(3) hadoop installation and startup
    useradd -u 1000 hadoop

    su - hadoop
    mkdir ~/.ssh; ssh-keygen -t dsa
    mv ~/.ssh/id_dsa.pub ~/.ssh/authorized_keys ## for ssh password-less
    yum install java-1.6.0-openjdk.x86_64 java-1.6.0-openjdk-devel.x86_64 -y
    wget wget http://archive.cloudera.com/cdh/3/hadoop-0.20.2-cdh3u3.tar.gz
    tar -zxvf hadoop-0.20.2-cdh3u3.tar.gz
    ln -s hadoop-0.20.2-cdh3u3 hadoop

    ## append the following line into /etc/profile(by root user) , ~/.bashrc(by hadoop user) , /home/hadoop/hadoop/conf/hadoop-env.sh(by hadoop user)

    export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64

    ## configure (by hadoop user)
    vi /home/hadoop/hadoop/conf/core-site.xml
        <?xml version="1.0"?>

        <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
        <configuration>
            <property>
                <name>fs.default.name</name>
                <value>hdfs://localhost:9000</value>
            </property>
        </configuration>

        value of fs.default.name also could be hdfs://hadoop1:9000


    vi /home/hadoop/hadoop/conf/hdfs-site.xml
        <?xml version="1.0"?>
        <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
        <configuration>
            <property>
                <name>dfs.replication</name>
                <value>1</value>
            </property>
        </configuration>

    vi /home/hadoop/hadoop/conf/mapred-site.xml
        <?xml version="1.0"?>
        <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
        <configuration>
            <property>
                <name>mapred.job.tracker</name>
                <value>localhost:9001</value>
            </property>
        </configuration>

    value of mapred.job.tracker also could be hadoop1:9001

    vi /home/hadoop/hadoop/conf/masters
        localhost

        "hadoop1" is also fine.

    vi /home/hadoop/hadoop/conf/slaves
        localhost

        "hadoop1" is also fine.

    ## startup hadoop (by hadoop user)
    su - hadoop; cd ~/hadoop
    bin/hadoop namenode -format
    #if you got error , it might be your JAVA_HOME is not setting correct.

    bin/start-all.sh

    bin/hadoop fs -ls /

    bin/hadoop fs -put conf/core-site.xml /test.xml
    bin/hadoop fs -ls /

    netstat -tplnu | grep 9000 ## check hdfs listen port

    bin/stop-all.sh   # stop hdfs for changing filesystem to kfs
 
(4)chang to kfs
    ## root@metaserver
    cd /usr/loca/kfs-0.5
    ant jar       # see build/kfs-0.5.jar
    scp build/kfs-0.5.jar hadoop1:/home/hadoop/hadoop/lib/.
    scp build/lib/* hadoop1:/home/hadoop/hadoop/lib/native/Linux-adm64-64
 
   
 
    ## root@hadoop1
    cd /home/hadoop/hadoop/lib
    mv kfs-0.x.y.jar kfs-0.x.y.jar.bak ## rename old version
    chown hadoop.hadoop kfs-0.5.jar
    chown -R hadoop.hadoop /home/hadoop/hadoop/lib/native/Linux-adm64-64
    vi /etc/profile

            :
            :
        export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64

        export LD_LIBRARY_PATH=/home/hadoop/hadoop/lib/native/Linux-adm64-64

        export HADOOP_PID_DIR=/home/hadoop/hadoop/tmp
        #if you changed config file path , modified this parameter
        #export HADOOP_CONF_DIR=/home/hadoop/hadoop/conf

    ## hadoop@hadoop1

    vi ~/.bashrc & vi ~/hadoop/conf/hadoop-env.sh
            :

            :
        export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64
        export LD_LIBRARY_PATH=/home/hadoop/hadoop/lib/native/Linux-adm64-64
        export HADOOP_PID_DIR=/home/hadoop/hadoop/tmp
        #if you changed config file path , modified this parameter
        #export HADOOP_CONF_DIR=/home/hadoop/hadoop/conf

    vi ~/hadoop/conf/core-site.xml
        <?xml version="1.0"?>

        <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
        <configuration>
            <property>
                <name>fs.default.name</name>
                <value>kfs://metaserver:20000</value>
            </property>
            <property>
                <name>fs.kfs.metaServerHost</name>
                <value>metaserver</value>
                <description>The location of the KFS meta server.</description>
            </property>
            <property>
                <name>fs.kfs.metaServerPort</name>
                <value>20000</value>
                <description>The location of the meta server's port.</description>
            </property>
        </configuration>

    ## testing
    cd ~/hadoop
    bin/hadoop fs -fs kfs://metaserver:20000 -ls /

    ## and then you could start the hadoop up as well , command is the same as hadoop/hdfs

reference: http://wangwei3.iteye.com/blog/895867
        http://archive.cloudera.com/cdh/3/hadoop-0.20.2-cdh3u3/single_node_setup.html
        http://sourceforge.net/apps/trac/kosmosfs/wiki/UsingWithHadoop
        http://trac.nchc.org.tw/cloud/wiki/Hadoop_Lab1

2012年7月26日 星期四

KFS mount by Fuse

assumed you already installed KFS, and  KFS could be started as well. Then you could keep follow few steps below for mount it. KFS setup please refer to[KFS](KosmosFS) 安裝方法一
(1)stop metaservers and chunkservers
(2)yum install fuse-devel.x86_64 fuse-libs.x86_64 -y
(3)make sure CMakeLists.txt setting
    rpm -ql fuse-devel
   /lib64/libfuse.so
   /lib64/libulockmgr.so
   /usr/include/fuse
   /usr/include/fuse.h
   /usr/include/fuse/cuse_lowlevel.h
   /usr/include/fuse/fuse.h
   :
   :

    vi /usr/local/kfs-0.5/CMakeLists.txt
    # Fill in the path to fuse library
    SET(Fuse_LIBRARY_DIR "/lib64")          #go to line 136,137, XX_DIR should be the same with what rpm(fuse...rpm) you just installed
    SET(Fuse_INCLUDE_DIR "/usr/include")
(4)re-build KFS
    cd /usr/local/kfs-0.5/build
    cmake -D CMAKE_BUILD_TYPE=Release /usr/local/kfs-0.5/
        or
    cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo /usr/local/kfs-0.5/
    gmake
    gmake install

    #kfs_fuse will be built in /usr/local/kfs-0.5/build/bin

    cd /usr/local/kfs-0.5/scripts
    python kfssetup.py -f machines.cfg -m ../conf/machines.txt -b ../build -w ../webui

    #start you KFS
    python kfslaunch.py -f machines.cfg -m ../conf/machines.txt -s
(5)build a new prp file for fuse mounting


  look at the code src/cc/libkfsClient/KfsClient.cc:
  KfsClientPtr
  KfsClientFactory::GetClient(const char *propFile)
  {
      bool verbose = false;
  #ifdef DEBUG
      verbose = true;
  #endif
      if (theProps().loadProperties(propFile, '=', verbose) != 0) {
          KfsClientPtr clnt;
     return clnt;
      }

      return GetClient(theProps().getValue("metaServer.name", ""),
                       theProps().getValue("metaServer.port", -1));

  }

    cd /usr/local/kfs-0.5/build/bin
    vi kfs.prp     #it should be named kfs.prp compulsorily
    metaServer.name = metaserver    #not metaServer.host
    metaServer.port = 20000
(6)mount KFS
    cd /usr/local/kfs-0.5/build/bin
    mkdir -p /mnt/kfs
    ./kfs_fuse /mnt/kfs -f -o allow_other
    # -f : force the system to run the process in foreground
    # -o allow_other : allow other user to access the mount point

    mount
    :
    /dev/mapper/vg_01-lv_home on /home type ext4 (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    kfs_fuse on /mnt/kfs type fuse.kfs_fuse (rw,nosuid,nodev,allow_other)


    ls -l /mnt/kfs
    total 0
    d--------- 0 root root    0 2012-07-25 11:00 dumpster
    d--------- 0 root root 9987 2012-07-26 15:12 hypertable

(7) FAQ
     1) Q:  kfs_fuse: /usr/include/boost/smart_ptr/shared_ptr.hpp:418:  T* boost::shared_ptr< >::operator->() const [with T = KFS::KfsClient]: Assertion `px != 0' failed.
        A:  look at your kfs.prp(exist ? typo ?), make sure metaServer.name (not metaServer.host)

     2) Q:  fuse: bad mount point `/mnt/kfs': Transport endpoint is not connected
         A:  if you had fixed all config files , but error again. Try to restart kfs service
            umount /mnt/kfs
            cd /usr/local/kfs-0.5/scripts
            python kfslaunch.py -f machines.cfg -m ../conf/machines.txt -S
            python kfslaunch.py -f machines.cfg -m ../conf/machines.txt -s
            cd /usr/local/kfs-0.5/build/bin
            ./kfs_fuse /mnt/kfs -f -o allow_other

reference :   http://yaronspace.cn/blog/archives/799



 

2012年7月24日 星期二

[KFS](KosmosFS) 安裝方法一

近來接獲一個任務,想要建置一套Distrubution File System, 在討論結果後,捨棄HDFS而改採KFS,據說他是用c++實現,所以在Support上應該跟我們比較Match(畢竟我們也都用c++),而它能支援c++,Java,以及python的用戶端
在安裝上,初期也吃了不少苦頭,這裡先把第1次安裝成功的過程PO出來,原則上,只是確認服務啟動, 但實際驗證還得後續處理
(1)系統環境準備
    1)此次使用的環境,使用為virtual machine來實現
       host : CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        7891424 kB(/proc/meminfo)
       CPU(Quad core)      : Intel(R) Core(TM) i3-2130 CPU @ 3.40GHz
       HDD: 1TB*2 (LVM ==> 2T)
       
 
       guest: CentOS-6.0
       kernel: 2.6.32-71.el6.x86_64 #1 SMP
       MemTotal:        1G
       CPU *1
       HDD: 100GB

       KFS的環境使用virtual machine的NAT環境,也把dhcp打開
       guest總共佈建4台,1台metaserver, 3台chunkserver
       這4台/etc/hosts設定如下
       192.168.65.1     mserver               #host's ip
       192.168.65.135 metaserver
       192.168.65.136 chunkserver1
       192.168.65.137 chunkserver2
       192.168.65.138 chunkserver3
    2)使用kickstart檔來進行初期的部署較容易也較快(4台guest都照此安裝),簡單描述幾個重點
        :
        selinux --disabled
        firewall --disabled
        :

        bootloader --location=mbr --driveorder=sda --append="rhgb quiet"
        :
        #在host,我們佈建了vsftpd以及httpd,
        #預設在/var/ftp/pub,/var/www/html(soft link to /var/ftp/pub)
        install
        url --url=http://192.168.65.1/pub
        :
        clearpart --drives=sda --all --initlabel
        part / --asprimary --fstype="ext4" --ondisk=sda --grow --size=1024
        part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
        part swap --fstype="swap" --ondisk=sda --recommended
        :
       
        #安裝極為陽春,主要到時候才能抓到需要的安裝包,日後製作安裝光碟才好處理
        %packages
        @core
        @server-policy
        ftp
        %end


  
        #後面就純粹個人覺得方便的設定
       
        %post
        echo "----------------------kickstart post-install-----------------------" >> /root/kickstart-cmd.log

        ipaddr=`/sbin/ifconfig eth0 | awk -F'[ :]+' '/Bcast/{print $4}'`
        gateway=`/sbin/route -n | sed '/^0.0.0.0/!d' | awk '{print $2}'`
        netmask=`/sbin/ifconfig eth0 | awk -F'[ :]+' '/Bcast/{print $8}'`
        echo "DEVICE=eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0
        echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
        echo "IPADDR=$ipaddr" >> /etc/sysconfig/network-scripts/ifcfg-eth0
        echo "NETMASK=$netmask" >> /etc/sysconfig/network-scripts/ifcfg-eth0
        echo "GATEWAY=$gateway" >> /etc/sysconfig/network-scripts/ifcfg-eth0

        hostname="cent""$(/sbin/ifconfig eth0 | awk -F'[ :]+' '/Bcast/{print $4}' | cut -d '.' -f 4)"



        echo "NETWORKING=yes" > /etc/sysconfig/network
        echo "NETWORKING_IPV6=no" >> /etc/sysconfig/network
        echo "HOSTNAME=$hostname" >> /etc/sysconfig/network

        echo "nameserver=168.95.1.1 > /etc/resolv.conf"

        echo "/usr/sbin/ntpdate -b time.stdtime.gov.tw;/sbin/hwclock --systohc --utc" >> /etc/rc.local

(2)安裝與設定
    1)作業系統安裝完成後,便可以開始KFS的安裝(4台都作一樣安裝)
       (A)安裝boost
             yum install boost.x86_64 boost-devel.x86_64 -y
       (B)安裝gcc/gcc-c++以及 make套件
             yum install gcc.x86_64 gcc-c++.x86_64 make.x86_64 -y
       (C)安裝cmake(tarball)
             cd /usr/local/src
             wget http://www.cmake.org/files/v2.6/cmake-2.6.4.tar.gz
             tar -zxvf cmake-2.6.4.tar.gz
             cd /usr/local/src/cmake-2.6.4
             ./bootstrap --prefix=/usr/local
             make
             make install
       (D)安裝log4cpp(tarball)
             cd /usr/local/src
             wget http://downloads.sourceforge.net/project/log4cpp/log4cpp-1.0.x%20%28current%29/log4cpp-1.0/log4cpp-1.0.tar.gz
             tar zxvf log4cpp-1.0.tar.gz
             cd log4cpp-1.0
             ./configure
             make
             make install

             在make時可能會遇到第一個error
             BasicLayout.cpp:37: error: expected constructor, destructor, or type conversion before'< 'token
             原因是因為GCC4.4的預設不包含某些程式庫,所以如果要使用這些程式庫的語法時,需要#include。打開src/BasicLayout.cpp,加入如下標示紅斜體字部份

              :
       #include "PortabilityImpl.hh"
       #include < log4cpp /BasicLayout.hh >
       #include < log4cpp /Priority.hh >
       #include < log4cpp /FactoryParams.hh >
       #ifdef LOG4CPP_HAVE_SSTREAM
       #include < sstream >
       #endif
       #include < memory > 
       namespace log4cpp {
       :
             再make時可能會遇到第二個error
      PatternLayout.cpp:373: error: call of overloaded 'abs(int&)' is ambiguous
             這個問題自GCC4.3版以來己經存在,解決方法將原本的abs(int&)取代成如下
      component = new FormatModifierComponent(component, std::abs(minWidth), maxWidth, minWidth < 0);
         取代如下
      component = new FormatModifierComponent(component, minWidth > 0 ? minWidth : -minWidth, maxWidth, minWidth < 0);

              如果其他設定沒問題,再make就應該會通過
       (E)安裝xfs相關套件
             yum install xfsprogs.x86_64 xfsprogs-devel.x86_64 -y
       (F)安裝其他剩下套件
             yum install expat.x86_64 -y
             yum install openssl-devel.x86_64 -y
             yum install java-1.6.0-openjdk.x86_64 java-1.6.0-openjdk-devel.x86_64 -y
             yum install uuid.x86_64 uuid-devel.x86_64 libuuid.x86_64 libuuid-devel.x86_64 -y
             yum install python.x86_64 python-devel.x86_64 -y
             yum install ntpdate.x86_64 -y

            設定每次開機均進行一次校時,或在排程中加入
            vi /etc/rc.local
            :
            /usr/sbin/ntpdate -b time.stdtime.gov.tw;/sbin/hwclock --systohc --utc

            crontab -e
            */1 * * * * * /usr/sbin/ntpdate -b time.stdtime.gov.tw;/sbin/hwclock --systohc --utc
        
            請注意java相關include的目錄位置
            shell>rpm -ql java-1.6.0-openjdk-devel.x86_64
            :
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/wsimport
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/bin/xjc
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/classfile_constants.h
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/jawt.h
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/jdwpTransport.h
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/jni.h
            /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/jvmti.h
            :

       (G)安裝KFS(tarball)
            在接下來安裝KFS之前,有個注意事項提醒。原本筆者安裝kfs-0.3版,在make(gmake),會遇到error, 發現是KFS舊版寫法(uint64_t的用法問題),後來筆者去下載最新的tarball檔,發現KFS的開發團隊己經改了寫法(改用int),後續的make都解決了,所以以下直接說明新版KFS的安裝
            cd /usr/local/
            wget http://kosmosfs.googlecode.com/files/kfs-0.5.tar.gz
            tar zxvf kfs-0.5.tar.gz
            cd kfs-0.5
            mkdir build
            cd build


            vi /usr/local/kfs-0.5/CMakeLists.txt (跳到110行,在緊接set (CMAKE_BUILD_TYPE "Debug")之後,加入以下2行)
            set (JAVA_INCLUDE_PATH "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include")
            set (JAVA_INCLUDE_PATH2 "/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include")




             cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo /usr/local/kfs-0.5/
             gmake
             gmake install

             上面紅字的部分,就是在rpm -ql java-....查到的include路徑
             上述安裝過程就是時間給他,他給你make完成

    2)設定
       以下設定,也是4台做一模一樣的設定。以下設定,筆者都是在host上設好後,放到ftp目錄,讓4台guest去下載到自己的目錄裡
       (A)設定machines.cfg
           mkdir /export/kosmix
           vi /usr/local/kfs-0.5/scripts/machines.cfg
           [metaserver]
           node: metaserver             #這裡請注意你的meta server hostname
           clusterkey: kfs-test-cluster
           rundir: /export/kfsmix/kfs/meta
           baseport: 20000
           loglevel: INFO
           numservers: 3
           [chunkserver_defaults]
           rundir: /export/kfsmix/kfs/chunk
           chunkDir: /export/kfsmix/kfs/chunk/bin/kfschunk
           baseport: 30000
           space: 3400 G
           loglevel: INFO

           設定完成後,請確認4台都有這份相同的設定檔

       (B)設定machines.txt
           vi /usr/local/kfs-0.5/conf/machines.txt
           #這裡不用設定meta server
           chunkserver1               #這裡請注意你的3台chunk server hostname
           chunkserver2
           chunkserver3

           設定完成後,請確認4台都有這份相同的設定檔

       (C) 設定ChunkServer.prp
           vi /usr/local/kfs-0.5/conf/ChunkServer.prp
           # Configuration for chunk server:
           # meta server location
           chunkServer.metaServer.hostname = metaserver #這裡請注意你的meta server hostname
           chunkServer.metaServer.port = 30000
           # port to open for client connections
           chunkServer.clientPort = 22000
           # Directory for storing the chunks
           chunkServer.chunkDir = ./chunks
           chunkServer.logDir = ./logs
           # provide 300G of storage space
           chunkServer.totalSpace = 300000000000

           設定完成後,請確認4台都有這份相同的設定檔(主要是3台chunk server一定要有,筆者就只設定在3台chunk server上而已)

    3)同步與啟動

       (A)同步作業
           這裡的同步作業使用rsync,請在3台的chunk server上都執行以下指令
           rsync -av /usr/local/kfs-0.5/ chunkserver1:/usr/local/kfs-0.5/
           rsync -av /usr/local/kfs-0.5/ chunkserver2:/usr/local/kfs-0.5/
           rsync -av /usr/local/kfs-0.5/ chunkserver3:/usr/local/kfs-0.5/
           過程要跑一下,也會要你輸入一堆密碼,想要解決不用輸入密碼的問題,就請上網查一下相關設定方法(password-less ssh),或日後再補充說明

       (B)啟動與關閉
           啟動前需要先執行一次以下指令
           cd /usr/local/kfs-0.5/scripts
           python kfssetup.py -f machines.cfg -m ../conf/machines.txt -b ../build -w ../webui

           跑完後如果沒有錯誤,接下指令就可以啟動1台meta server以及3台chunk server(在1台上執行即可)
           python kfslaunch.py -f machines.cfg -m ../conf/machines.txt -s
           注意:最後一個參數是小s。過程會要你輸入一堆密碼

           你可以在meta server上觀察到
           [root@metaserver scripts]# ps -ef | grep server
           root      9727     1  0 13:30 ?        00:00:00 bin/metaserver bin/MetaServer.prp logs/metaserver.log
           [root@metaserver scripts]# netstat -tplnu | grep 20000
           tcp        0      0 0.0.0.0:20000               0.0.0.0:*                   LISTEN      9727/metaserver    

           你可以在chunk server上觀察到
           [root@chunkserver2 scripts]# ps -ef | grep server
           root     11159     1  0 13:29 ?        00:00:00 bin/chunkserver bin/ChunkServer.prp logs/chunkserver.log
           [root@chunkserver2 scripts]# netstat -tplnu | grep 30000
           tcp        0      0 0.0.0.0:30000               0.0.0.0:*                   LISTEN      11159/chunkserver  




           關閉的方法跟啟動很像,一樣只要在一台執行
           python kfslaunch.py -f machines.cfg -m ../conf/machines.txt -S

           注意:最後一個參數是大S。過程會要你輸入一堆密碼

  後記:之後的處理可以朝(1)全RPM,以利安裝光碟的建置
                                     (2)集中配置各node,方便維護與新增
                                     (3)password-less ssh
   參考:http://www.pginjp.org/modules/newbb/viewtopic.php?topic_id=775
             http://now-code.com/archives/118    

後記:如果只想裝一台chunkserver + metaserver,可以試著將上述幾個設定修改如下,以下將原本metaserver變成加上chunkserver,獨立一台達成KFS
(1)修改/etc/hosts
192.168.65.1 mserver #host's ip

192.168.65.135 metaserver
192.168.65.135 chunkserver

192.168.65.136 chunkserver1
192.168.65.137 chunkserver2
192.168.65.138 chunkserver3

(2)設定machines.txt

vi /usr/local/kfs-0.5/conf/machines.txt
#這裡不用設定meta server
chunkserver #只剩1台,而已是chunkserver 


(3)設定machines.cfg
vi /usr/local/kfs-0.5/scripts/machines.cfg
 [metaserver]
node: metaserver
clusterkey: kfs-test-cluster
rundir: /export/kfsmix/kfs/meta
baseport: 20000
loglevel: INFO
numservers: 1
[chunkserver_defaults]
rundir: /export/kfsmix/kfs/chunk
chunkDir: /export/kfsmix/kfs/chunk/bin/kfschunk
baseport: 30000
space: 3 G
loglevel: INFO

(4)同步作業
rsync -av /usr/local/kfs-0.5/ chunkserver:/usr/local/kfs-0.5/
如果(1)password-less ssh沒做,也請補上
       (2)如果1台變多台,或系統的server數量有變化,請再上述修改完設定後,再執行一次
           python kfssetup.py -f machines.cfg -m ../conf/machines.txt -b ../build -w ../webui


其他就都跟上述一樣, 完成後啟動KFS,可以發現Chunkserver & Metaserver同時在執行









文章分類