分布式文件系统

litedfs的Python项目详细描述


文学作品

一个分布式文件系统,基于Python3,tornado,灵感来自HDFS。在

它是用于数据处理缓存,而不是永久存储!在

所有基于Python3的代码,不要使用Python2!在

它还在开发中,所以,可能有一些错误或不够稳定!在

更多详细信息请访问https://github.com/fiefdx/LiteDFS

特点

  1. 每文件副本设置,支持动态副本更改,目前没有数据重装功能

  2. 可通过添加/删除节点进行扩展

  3. 轻量级的纯python实现

  4. 支持命令行界面

概念

  1. 名称节点(ldfsname):群集的中心节点,管理所有文件和目录索引。在

  2. 数据节点(ldfsdata):集群的数据节点,存储真实文件的块数据。在

  3. 命令行客户机(ldfs):用于与集群通信的命令行工具。在

  4. 图形客户端(ldfsviewer):与集群通信的图形工具。在

部署

安装LiteDFS

# this will install 4 commands: ldfsname, ldfsdata, ldfs, ldfsviewer
$ pip3 install litedfs

运行名称节点

配置

^{pr2}$

运行

# generate configuration file & scripts
mkdir ./litedfs_name
cd ./litedfs_name
# this will generate configuration.yml and other scripts
ldfsname -g ./

# run manually
ldfsname -c ./configuration.yml or nohup ldfsname -c ./configuration.yml > /dev/null 2>&1&# install systemd service, user and group set to use which user and group to run ldfsname
sudo ./install_systemd_service.sh user group

# start
systemctl start litedfs-name

# stop
systemctl stop litedfs-name

# uninstall systemd service
sudo ./uninstall_systemd_service.sh

# test
$ curl localhost:9000
{"message": "LiteDFS name service"}

运行节点

配置

log_level:NOSET# NOSET, DEBUG, INFO, WARNING, ERROR, CRITICALlog_path:/home/pi/litedfs_data/logs# log file directory, can auto generate by ldfsdatahttp_host:0.0.0.0# data node's http hosthttp_port:8002# data node's http portname_http_host:127.0.0.1# name node's http hostname_http_port:9000# name node's http portname_tcp_host:127.0.0.1# name node's tcp hostname_tcp_port:6061# name node's tcp portheartbeat_interval:1# heartbeat interval, 1 secondsheartbeat_timeout:30# heartbeat timeout, 30 secondsretry_interval:5# retry to connect name node interval, when lost connection, 5 secondsdata_path:/home/pi/litedfs_data/data# data node data store directory, can auto generate by ldfsdata

运行

# generate configuration file & scripts
mkdir ./litedfs_data
cd ./litedfs_data
# this will generate configuration.yml and other scripts
ldfsdata -g ./

# run manually
ldfsdata -c ./configuration.yml or nohup ldfsdata -c ./configuration.yml > /dev/null 2>&1&# install systemd service, user and group set to use which user and group to run ldfsdata
sudo ./install_systemd_service.sh user group

# start
systemctl start litedfs-data

# stop
systemctl stop litedfs-data

# uninstall systemd service
sudo ./uninstall_systemd_service.sh

# test
$ curl localhost:8002
{"message": "LiteDFS data service"}

运行查看器

此查看器必须运行在本地计算机上,它不是公共服务,而是基于web技术的图形客户端。在

配置

log_level:NOSET# NOSET, DEBUG, INFO, WARNING, ERROR, CRITICALlog_path:/home/pi/litedfs_viewer/logs# log file directory, can auto generate by ldfsviewerhttp_host:0.0.0.0# viewer's http hosthttp_port:8088# viewer's http portname_http_host:192.168.199.149# name node's http hostname_http_port:9000# name node's http portdata_path:/home/pi/litedfs_viewer/data# viewer data store directory, can auto generate by ldfsviewer

运行

# generate configuration file & scripts
mkdir ./litedfs_viewer
cd ./litedfs_viewer
# this will generate configuration.yml and other scripts
ldfsviewer -g ./

# run manually
ldfsviewer -c ./configuration.yml or nohup ldfsviewer -c ./configuration.yml > /dev/null 2>&1&# install systemd service, user and group set to use which user and group to run ldfsviewer
sudo ./install_systemd_service.sh user group

# start
systemctl start litedfs-viewer

# stop
systemctl stop litedfs-viewer

# uninstall systemd service
sudo ./uninstall_systemd_service.sh

# test# use web browser open: http://localhost:8088

使用LiteDFS群集操作

# list root directory
$ ldfs localhost:9000 directory list -r /
# | id | type | size | name# create test directory
$ ldfs localhost:9000 directory create -r /test
create directory[/test] success

# list root directory again
$ ldfs localhost:9000 directory list -r /
# | id | type      | size | name1|| directory |0|test# create a file
$ ldfs localhost:9000 file create -r /test/test.tar.gz -l ./examples.tar.gz 
create file[/test/test.tar.gz] success

# list test directory
$ ldfs localhost:9000 directory list -r /test
# | id                                   | type | size      | name       1| 878b17d4-cc11-4bba-88b0-2186b77ef552 | file |110237727| test.tar.gz

# create test2 directory
$ ldfs localhost:9000 directory create -r /test2
create directory[/test2] success

# list root directory again
$ ldfs localhost:9000 directory list -r /
# | id | type      | size | name 1|| directory |0|test2|| directory |0| test2

# move test.tar.gz into test2 directory
$ ldfs localhost:9000 file move -s /test/test.tar.gz -t /test2
move file[/test/test.tar.gz] to /test2 success

# list test directory again
$ ldfs localhost:9000 directory list -r /test
# | id | type | size | name# list test2 directory again
$ ldfs localhost:9000 directory list -r /test2
# | id                                   | type | size      | name       1| 878b17d4-cc11-4bba-88b0-2186b77ef552 | file |110237727| test.tar.gz

# create file with replica 2
$ ldfs localhost:9000 file create -r /test/test.tar.gz -l ./examples.tar.gz -R 2
create file[/test/test.tar.gz] success

# update file replica 3
$ ldfs localhost:9000 file create -r /test/test.tar.gz -l ./examples.tar.gz -R 3
update file[/test/test.tar.gz] success

# download /test/test.tar.gz to local file ./test.tar.gz
$ ldfs localhost:9000 file download -r /test/test.tar.gz -l ./test.tar.gz
download file[/test/test.tar.gz => ./test.tar.gz] success

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
无法在Netbeans 8.2 JDK8u231中创建java Maven项目(Web应用程序)   java如何以设定的时间间隔生成随机数?   java从socket和inputStream的慢速读取   spring SCORM:Java中基于Web的SCORM播放器   Java将函数传递给方法   java绑定通用服务及其实现和子类型   java如何在运行时从选择列表框中动态选择选项?爪哇硒   java Selenium WebDriver什么是“Selenium客户端和WebDriver语言绑定”   elasticsearch需要elasticsearch高级Java客户端更新ByQueryRequest API帮助   JAVA哈希表查找最大值   WSDL操作中的java soapAction属性为空   java访问封闭类或父类方法的一般方法   eclipse在java中运行带有SeleneTestCase的ANT。lang.NoClassDefFoundError   java Hazelcast不会在节点启动时填充ReplicatedMap   如何在Java中从excel中读取特定行?   html JAVA将本地时间(GMT+8)转换为UTC时间   java将自定义端点添加到Spring数据REST存储库中,并以大摇大摆的方式显示   java计算未来位置