安裝需要的軟件包
yum install -y yum-utils
設(shè)置yum源
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
安裝docker?
yum install -y docker-ce
查看docker版本驗證安裝是否成功?
docker -v
啟動docker
systemctl start docker
查看docker上的fastDFS鏡像信息
docker search fastdfs
[root@localhost ~]# docker search fastdfs
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
season/fastdfs FastDFS 87
ygqygq2/fastdfs-nginx 整合了nginx的fastdfs 29 [OK]
luhuiguo/fastdfs FastDFS is an open source high performance d… 25 [OK]
morunchang/fastdfs A FastDFS image 20
delron/fastdfs 15
qbanxiaoli/fastdfs FastDFS+FastDHT(單機+集群版) 14 [OK]
moocu/fastdfs fastdfs5.11 9
dodotry/fastdfs 更新到最新版本,基于Centos8/nginx1.19.8/Fast… 6
ecarpo/fastdfs-storage 4
imlzw/fastdfs-tracker fastdfs的tracker服務(wù) 3 [OK]
ecarpo/fastdfs 3
imlzw/fastdfs-storage-dht fastdfs的storage服務(wù),并且集成了fastdht的服務(wù)… 2 [OK]
manuku/fastdfs-fastdht fastdfs fastdht 2 [OK]
perfree/fastdfsweb go-fastdfs文件系統(tǒng)的web管理系統(tǒng) 2
manuku/fastdfs-tracker fastdfs tracker 1 [OK]
lionheart/fastdfs_tracker fastdfs file system‘s tracker node 1
appcrash/fastdfs_nginx fastdfs with nginx 1
basemall/fastdfs-nginx fastdfs with nginx 1 [OK]
leaon/fastdfs fastdfs 1
tsl0922/fastdfs FastDFS is an open source high performance d… 0 [OK]
manuku/fastdfs-storage-dht fastdfs storage dht 0 [OK]
manuku/fastdfs-storage-proxy fastdfs storage proxy 0 [OK]
germicide/fastdfs The image provides pptx\docx\xlsx to pdf,mp… 0
mypjb/fastdfs this is a fastdfs docker project 0 [OK]
chenfengwei/fastdfs
?拉取鏡像
docker pull delron/fastdfs
[root@localhost ~]# docker pull delron/fastdfs
Using default tag: latest
latest: Pulling from delron/fastdfs
469cfcc7a4b3: Downloading [====================================> ] 53.55MB/73.17MB
4b4f08bd0171: Downloading [===============================> ] 55.65MB/88.7MB
95eef9978b96: Download complete
aff83d00c747: Download complete
1e95dffa1075: Download complete
f114184ac28c: Download complete
649b2ad6afe2: Download complete
8ab2127a38c5: Download complete
4d12f9bd27c7: Download complete
bfc05d82f0a6: Download complete
76f2a6d84a19: Download complete
89bd9c4e6fea: Download complete
6c06548e40ac: Download complete
11186700b494: Download complete
創(chuàng)建fastDFS掛載路徑
[root@localhost ~]# mkdir DockerDFS
[root@localhost ~]# cd DockerDFS/
[root@localhost DockerDFS]# ll
total 0
[root@localhost DockerDFS]# mkdir tracker
[root@localhost DockerDFS]# mkdir storage
[root@localhost DockerDFS]# ls
storage tracker
[root@localhost DockerDFS]#
構(gòu)建Tracker容器
使用docker鏡像構(gòu)建tracker容器,用于啟動跟蹤服務(wù)器,起到調(diào)度的作用。
其中-v參數(shù)將本地的目錄與容器中的/var/fdfs目錄進行掛載
使用的網(wǎng)絡(luò)模式是–net=host
–name容器名
-d后臺啟動
docker run -d --network=host --name tracker -v /data/fastDFS/tracker/:/var/fdfs delron/fastdfs tracker
[root@localhost DockerDFS]# docker run -d --network=host --name tracker -v /data/fastDFS/tracker/:/var/fdfs delron/fastdfs tracker
c4c768ff0de669d4a5f82d402600e4aab280d79163991801f0e21681da9d016e
[root@localhost DockerDFS]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c4c768ff0de6 delron/fastdfs "/usr/bin/start1.sh …" 24 seconds ago Up 24 seconds
構(gòu)建Storage容器
使用docker鏡像構(gòu)建storage容器,用于啟動存儲服務(wù)器,提供容量和備份服務(wù)。
在執(zhí)行下面命令時特別需要提醒的時,對應(yīng)的IP地址,需要修改為tracker服務(wù)的IP地址,由于是在同一臺電腦上操作,這里使用本機的內(nèi)網(wǎng)地址即可,22122是tracker對應(yīng)的端口。
其中8888為Nginx對應(yīng)的訪問端口,23000是storage服務(wù)端口。
docker run -d --network=host --name storage -e TRACKER_SERVER=192.168.216.130:22122 -v /data/fastDFS/storage/:/var/fdfs -e GROUP_NAME=group1 delron/fastdfs storage
[root@localhost DockerDFS]# docker run -d --network=host --name storage -e TRACKER_SERVER=192.168.216.130:22122 -v /data/fastDFS/storage/:/var/fdfs -e GROUP_NAME=group1 delron/fastdfs storage
cd9de13334ebf8284b3088b08e7375c4cf43fe5c106db990ab37b877927ddaec
查看docker的服務(wù)情況
[root@localhost DockerDFS]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cd9de13334eb delron/fastdfs "/usr/bin/start1.sh …" About a minute ago Up About a minute storage
c4c768ff0de6 delron/fastdfs "/usr/bin/start1.sh …" 8 minutes ago Up 8 minutes tracker
修改配置
經(jīng)過上面的步驟,tracker和storage都啟動完成。我們可以進入對應(yīng)的docker容器查看一下默認(rèn)的配置情況。
進入docker的命令為:docker exec -it [CONTAINER ID]?bash
先進入storage,查看其對應(yīng)配置文件中關(guān)于http訪問的配置,配置文件在/etc/fdfs目錄下的storage.conf。在最后一行可以看到如下配置:http.server_port=8888
也就是說,這個docker鏡像中默認(rèn)監(jiān)聽的是8888端口,當(dāng)然此配置是需要修改的。如果修改為其他端口,對應(yīng)的Nginx配置也需要修改
[root@localhost DockerDFS]# docker exec -it cd9de13334eb bash
[root@localhost nginx-1.12.2]# ll
total 708
-rw-r--r--. 1 1001 1001 278202 Oct 17 2017 CHANGES
-rw-r--r--. 1 1001 1001 423948 Oct 17 2017 CHANGES.ru
-rw-r--r--. 1 1001 1001 1397 Oct 17 2017 LICENSE
-rw-r--r--. 1 root root 376 Apr 29 2018 Makefile
-rw-r--r--. 1 1001 1001 49 Oct 17 2017 README
drwxr-xr-x. 6 1001 1001 4096 Apr 29 2018 auto
drwxr-xr-x. 2 1001 1001 168 Apr 29 2018 conf
-rwxr-xr-x. 1 1001 1001 2481 Oct 17 2017 configure
drwxr-xr-x. 4 1001 1001 72 Apr 29 2018 contrib
drwxr-xr-x. 2 1001 1001 40 Apr 29 2018 html
drwxr-xr-x. 2 1001 1001 21 Apr 29 2018 man
drwxr-xr-x. 4 root root 187 Apr 29 2018 objs
drwxr-xr-x. 9 1001 1001 91 Apr 29 2018 src
[root@localhost nginx-1.12.2]# cd conf
[root@localhost conf]# ll
total 36
-rw-r--r--. 1 1001 1001 1077 Oct 17 2017 fastcgi.conf
-rw-r--r--. 1 1001 1001 1007 Oct 17 2017 fastcgi_params
-rw-r--r--. 1 1001 1001 2837 Oct 17 2017 koi-utf
-rw-r--r--. 1 1001 1001 2223 Oct 17 2017 koi-win
-rw-r--r--. 1 1001 1001 3957 Oct 17 2017 mime.types
-rw-r--r--. 1 1001 1001 2656 Oct 17 2017 nginx.conf
-rw-r--r--. 1 1001 1001 636 Oct 17 2017 scgi_params
-rw-r--r--. 1 1001 1001 664 Oct 17 2017 uwsgi_params
-rw-r--r--. 1 1001 1001 3610 Oct 17 2017 win-utf
修改后的內(nèi)容如下
vi nginx.conf
server {
listen 8888;
server_name localhost;
location ~/group[0-9]/ {
ngx_fastdfs_module;
#root html;
#index index.html index.htm;
}
}
查看storage.conf
確保storage.conf中的配置http.server_port=8888與剛剛nginxd的配置文件中監(jiān)聽的端口號一致
[root@localhost conf]# cd /etc/fdfs/
[root@localhost fdfs]# ll
total 88
-rw-rw-r--. 1 root root 1452 Nov 17 01:07 client.conf
-rw-r--r--. 1 root root 1461 Apr 29 2018 client.conf.sample
-rw-r--r--. 1 root root 955 Apr 29 2018 http.conf
-rw-r--r--. 1 root root 31172 Apr 29 2018 mime.types
-rw-r--r--. 1 root root 3680 Nov 17 01:07 mod_fastdfs.conf
-rw-rw-r--. 1 root root 7894 Nov 17 01:07 storage.conf
-rw-r--r--. 1 root root 7927 Apr 29 2018 storage.conf.sample
-rw-rw-r--. 1 root root 105 Apr 29 2018 storage_ids.conf
-rw-r--r--. 1 root root 105 Apr 29 2018 storage_ids.conf.sample
-rw-rw-r--. 1 root root 7307 Apr 29 2018 tracker.conf
-rw-r--r--. 1 root root 7389 Apr 29 2018 tracker.conf.sample
vi storage.conf
文章來源:http://www.zghlxwxcb.cn/news/detail-437517.html
?設(shè)置tracker,storage自啟動
退出docker
[root@localhost /]# exit
exit
?設(shè)置自啟動文章來源地址http://www.zghlxwxcb.cn/news/detail-437517.html
[root@localhost fastDFS]# docker update --restart=always tracker
tracker
[root@localhost fastDFS]# docker update --restart=always storage
storage
到了這里,關(guān)于在Docker里安裝FastDFS分布式文件系統(tǒng)詳細(xì)步驟的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!