Rocky Linux 9 での FastDFS スタンドアロン環境構築

Yum によるインストール方法

# リポジトリ追加
rpm -ivh http://www.fastken.com/yumrepo/el8/noarch/FastOSrepo-1.0.0-1.el8.noarch.rpm

# パッケージインストール
yum install fastdfs-server fastdfs-tool fastdfs-config -y

ソースコードからのコンパイルインストール

1. 依存関係のインストール

dnf install git gcc gcc-c++ make automake autoconf libtool pcre pcre-devel zlib zlib-devel openssl-devel wget vim -y

2. データ格納ディレクトリの作成

mkdir /opt/fdfs_data -p

3. libfastcommon のインストール

git clone https://github.com/happyfish100/libfastcommon.git --depth 1
cd libfastcommon/
./make.sh && ./make.sh install

4. libserverframe のインストール

git clone https://github.com/happyfish100/libserverframe.git --depth 1
cd libserverframe/
./make.sh && ./make.sh install

5. FastDFS 本体のインストール

git clone https://github.com/happyfish100/fastdfs.git --depth 1
cd fastdfs/
./make.sh && ./make.sh install

cp ./conf/http.conf /etc/fdfs/
cp ./conf/mime.types /etc/fdfs/

6. Nginx モジュールの設定

git clone https://github.com/happyfish100/fastdfs-nginx-module.git --depth 1
cp fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs

Nginx のセットアップ

# 必要なソースコード
pcre-8.45.tar.gz
nginx-1.24.0.tar.gz
openssl-1.1.1w.tar.gz
jemalloc-5.3.0.tar.bz2

# jemalloc のインストール
tar xjf jemalloc-5.3.0.tar.bz2
cd jemalloc-5.3.0
./configure
make && make install

ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig

# Nginx ユーザーの作成
useradd -M -s /sbin/nologin nginx

# ログディレクトリの準備
mkdir -p /var/log/nginx

# ソースコードの展開
tar xzf pcre-8.45.tar.gz
tar xzf openssl-1.1.1w.tar.gz
tar xzf nginx-1.24.0.tar.gz

# コンパイル設定
cd nginx-1.24.0
./configure --prefix=/usr/local/nginx \
            --user=nginx \
            --group=nginx \
            --with-http_ssl_module \
            --with-stream \
            --with-http_gzip_static_module \
            --with-openssl=../openssl-1.1.1w \
            --with-pcre=../pcre-8.45 \
            --with-ld-opt='-ljemalloc' \
            --add-module=../fastdfs-nginx-module/src

make && make install

# 環境変数の設定
echo 'export PATH=/usr/local/nginx/sbin:$PATH' >> /etc/profile
source /etc/profile

# サービス設定
cat > /etc/systemd/system/nginx.service <<EOF
[Unit]
Description=NGINX web server
After=network.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP \$MAINPID
ExecStop=/bin/kill -s QUIT \$MAINPID

[Install]
WantedBy=multi-user.target
EOF

systemctl enable --now nginx
</code>

スタンドアロン環境の構築

1. Tracker の設定

vi /etc/fdfs/tracker.conf
---
port=22122
base_path=/opt/fdfs_data
---

systemctl enable --now fdfs_trackerd

2. Storage の設定

vi /etc/fdfs/storage.conf
---
port=23000
base_path=/opt/fdfs_data
store_path0=/opt/fdfs_data
tracker_server=127.0.0.1:22122
http.server_port=8888
---

systemctl enable --now fdfs_storaged

3. クライアントテスト

vi /etc/fdfs/client.conf
---
base_path=/opt/fdfs_data
tracker_server=127.0.0.1:22122
---

fdfs_upload_file /etc/fdfs/client.conf /etc/hosts

4. Nginx 連携設定

vi /etc/fdfs/mod_fastdfs.conf
---
tracker_server=127.0.0.1:22122
url_have_group_name=true
store_path0=/opt/fdfs_data
---

vi /usr/local/nginx/conf/nginx.conf
---
server {
    listen 8888;
    location /group1/M00 {
        ngx_fastdfs_module;
    }
}
---

systemctl restart nginx

タグ: rockylinux FastDFS nginx 分散ファイルシステム ストレージシステム

5月21日 11:08 投稿