前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Tomcat 集群 文件上传下载的共享问题 NFS配置

Tomcat 集群 文件上传下载的共享问题 NFS配置

作者头像
BUG弄潮儿
发布2022-06-30 15:06:04
5030
发布2022-06-30 15:06:04
举报
文章被收录于专栏:JAVA乐园

Tomcat 集群时上传文件时如何使得多部tomcat中的文件同步,Linux下可以通过NFS来解决这个问题。可以在一部linux server上配置NFS服务器,其他linux server当作NFS客户端。

客户端只需用nfs挂载服务端的目录即可,如:

mount -t nfs 192.168.1.80:/usr/local/share/tomcat/VOS/sharefolder /usr/share/tomcat/VOS/sharefolder

或者可以在/etc/fstab中設置:

192.168.1.80:/usr/local/share/tomcat/VOS/sharefolder /usr/share/tomcat/VOS/sharefolder nfs defaults 0 0

其中第一个sharefolder是服务器上目录,第二个目录是客户机挂载目录

[root@master ~]# yum -y install nfs-utils

[root@master ~]# vi /etc/idmapd.conf

# line 5: uncomment and change to your domain name

Domain = server.world

[root@master ~]# vi /etc/exports

# write like below *note

/home 10.0.0.0/24(rw,sync,no_root_squash,no_all_squash)

# *note

/home ⇒ shared directory

10.0.0.0/24 ⇒ range of networks NFS permits accesses

rw ⇒ writable

sync ⇒ synchronize

no_root_squash ⇒ enable root privilege

no_all_squash ⇒ enable users' authority

[root@master ~]# systemctl start rpcbind.service

[root@master ~]# systemctl start nfs-server.service

[root@master ~]# systemctl start nfs-lock.service

[root@master ~]# systemctl start nfs-idmap.service

[root@master ~]# systemctl enable rpcbind.service

[root@master ~]# systemctl enable nfs-server.service

[root@master ~]# systemctl enable nfs-lock.service

[root@master ~]# systemctl enable nfs-idmap.service

[root@www ~]# yum -y install nfs-utils

[root@master ~]# vi /etc/idmapd.conf

# line 5: uncomment and change to your domain name

Domain = server.world

[root@www ~]# systemctl start rpcbind.service

[root@www ~]# systemctl start nfs-lock.service

[root@www ~]# systemctl start nfs-idmap.service

[root@www ~]# systemctl start netfs.service

[root@www ~]# systemctl enable rpcbind.service

[root@www ~]# systemctl enable nfs-lock.service

[root@www ~]# systemctl enable nfs-idmap.service

[root@www ~]# systemctl enable netfs.service

[root@www ~]# mount -t nfs master.server.world:/home /home

[root@www ~]# df -h

Filesystem Size Used Avail Use% Mounted on

rootfs 16G 832M 14G 6% /

devtmpfs 995M 0 995M 0% /dev

tmpfs 1003M 0 1003M 0% /dev/shm

tmpfs 1003M 39M 964M 4% /run

/dev/mapper/VolGroup-lv_root 16G 832M 14G 6% /

tmpfs 1003M 39M 964M 4% /run

tmpfs 1003M 0 1003M 0% /sys/fs/cgroup

tmpfs 1003M 0 1003M 0% /media

/dev/vda2 485M 32M 428M 7% /boot

master.server.world:/home/ 16G 848M 14G 6% /home

# home directory on NFS is mounted

[root@www ~]# vi /etc/fstab

/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1

UUID=65ec32e2-f459-4d63-b8b0-e18124b50f3a /boot ext4 defaults 1 2

/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0

# add at the lat line: change home directory this server mounts to the one on NFS

master.server.world:/home /home nfs defaults 0 0

注意:若防火墙开着,要让nfs程序通过防火墙

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-03-12,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 BUG弄潮儿 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档