Develop a habit, like first and then watch! ! ! !
Distributed file storage system fastdfs installation steps
- 1. Upload the compressed package to the opt directory
- 2. Unzip the file
- 3. Compile the file
- 4. Recompile and install our files
- 5. Copy all files in the conf configuration directory to /etc/fdfs
- 6. Configure tracker.conf in the /etc/fdfs directory. This file is mainly to set the software data and log directory
- 7. Configure the storage.conf file, which is mainly the storage file
- 8. Configure the startup service of fdfs_storaged and fdfs_trackerd
- 9. Test file upload service
1. Upload the compressed package to the opt directory
2. Unzip the file
cd /opt
tar -zxvf FastDFS_v5.05.tar.gz
3. Compile the file
cd FastDFS
./make.sh
If the following error occurs, then we need to install this environment libfastcommon first
3.1 install libfastcommon
3.2 Upload files to the /usr/local directory and unzip
tar -zxvf libfastcommonV1.0.7.tar.gz
3.3 Enter the unzipped folder and start compiling
cd libfastcommon-1.0.7
./make.sh
If ./make.sh is not recognized, then run the following code
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
After that you can compile with the ./make.sh command
3.4 Compile and install
./make.sh install
Here we can see that he installed this thing in the /usr/lib64 directory by default, but the Fastdfs program will refer to the files in the /usr/lib directory by default, so we need to l ibfastcommon.so in the directory File assignment and paste to the /usr/lib directory
cp /usr/lib64/libfastcommon.so /usr/lib
4. Recompile and install our files
./make.sh
./make.sh install
So even if the compilation is successful.
Even if the installation is successful.
5. Copy all files in the conf configuration directory to /etc/fdfs
At this time, let’s check if there is such a directory. After checking, we found that there is none.
But when we choose to create the directory, we will find that the directory actually already exists.
mkdir /etc/fdfs
We can enter the directory to check, we can find that we can enter the directory,
cd fdfs
This means that when we installed Fastdfs, he already created it for us by default, and the knowledge directory is hidden
So we can directly copy all the files in the conf directory to the /etc/fdfs directory
cp * /etc/fdfs
6. Configure tracker.conf in the /etc/fdfs directory. This file is mainly to set the software data and log directory
We need to create a directory to store fastdfs data and logs
mkdir /opt/fastdfs
cd /etc/fdfs
vi tracker.conf
Modify this directory to the directory we just created to store data and logs
Then save and exit
7. Configure the storage.conf file, which is mainly the storage file
We mainly modify the following three places
This is the directory where our data and logs are stored
This place is where our files will be stored in the future. We can see that multiple file storage locations can be set here
Here is to modify the IP of the server where the tracker was deployed just now, because our tracker and storage are deployed on the same server, so we can directly use the local IP, because we are the Alibaba Cloud server , So we need to configure the firewall and open the security group rules later , otherwise the 22122 port will not be accessible
Configure firewall port number:
service firewalld start
firewall-cmd --zone=public --permanent --add-port=22122/tcp
firewall-cmd --reload
firewall-cmd --list-all
Open a security group:
Remember that both the incoming and outgoing directions need to be configured
8. Configure the startup service of fdfs_storaged and fdfs_trackerd
Create /usr/local/fdfs first, then copy the two services in the installation directory to the /usr/local/fdfs directory
mkdir /usr/local/fdfs
cd /opt/FastDFS
cp stop.sh /usr/local/fdfs
cp restart.sh /usr/local/fdfs
After that, we can go to the /etc/init.d directory to modify the startup services of fdfs_storaged and fdfs_trackerd. Here, since we have installed the startup services of fdfs_storaged and fdfs_trackerd for us during the installation of fastdfs, we only need to modify them Can be configured
This is where the fdfs_trackerd
file needs to be modified
cd /etc/init.d
vi fdfs_trackerd
This is what fdfs_storaged
needs to be modified
cd /etc/init.d
vi fdfs_storaged
Add the service to the system service and start
chkconfig --add fdfs_storaged
chkconfig --add fdfs_trackerd
service fdfs_storaged start
service fdfs_trackerd start
ps -ef|grep fdfs
If you can see the following page, it means fdfs服务
you have successfully started
9. Test file upload service
Fastdfs has a special directory for us to test. We can test whether our file service is really successful by modifying this directory.
First, modify the following configuration of the file etc/fdfs/client.conf:
vim /etc/fdfs/client.conf
Here we use the following command to upload pictures to test
/usr/bin/fdfs_test /etc/fdfs/client.conf upload test.jpg
/usr/bin/fdfs_test is a test demo that comes with
fastdfs /etc/fdfs/client.conf is the configuration of the test we just configured, the command will read the information of this configuration file
test.jpg represents the file name you want to upload , It is a file in the current directory,
but an error is reported here. At first glance, we know that port 23000 is not open, so we need to open this port. The steps are the same as the steps for opening port 22122 above. After opening the port, we re-tested and found that our file has been uploaded successfully,
and here he returned us a picture URL. But currently this URL is not accessible, because my server has not added Nginx for reverse proxy, this will be added later, but we can check whether the file exists by entering the corresponding directory. After checking, it was found that the file had indeed been stored. At this point, the installation of fastdfs has been basically completed.
The code word is not easy, if you think it is helpful to you, you can follow my official account, the newcomer up needs your support! ! !