Problem
When uploading a WAR file larger than 50 MB, the Tomcat 7 Manager application reports:
The server encountered an internal error () that prevented it from fulfilling this request.
Exception java.lang.IllegalStateException:
org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException:
the request was rejected because its size (XXX) exceeds the configured maximum (52428800)
Solution
Go to the web.xml of the manager application (for instance it could be under /tomcat7/webapps/manager/WEB-INF/web.xml.
Increase the max-file-size and max-request-size:
<multipart-config>
<!– 50MB max –>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0</file-size-threshold>
</multipart-config>
Nguon Internet.
Search This Blog
Showing posts with label Linux tricks. Show all posts
Showing posts with label Linux tricks. Show all posts
Thursday, September 29, 2011
Tang dung luong file upload cho Tomcat Apache
Friday, June 24, 2011
ssh, scp without password to remote host
GIỚI THIỆU
Hôm nay định viết một script để tự động copy backup dữ liệu từ local host sang 1 host khác.
Việc copy thì dễ dàng có thể dùng các lệnh scp hay rsync. Tuy nhiên vấn đề khó khăn ở đây là các lệnh trên yêu cầu phải nhập password.
Phải làm sao để thực hiện các lệnh nói trên đến remote host mà không phải nhập password thì việc backup tự động mới khả thi được.
THỰC HIỆN
Nào hãy bắt đầu. Giả sử
localhost (192.168.241.63) - Máy source cần copy data
remotehost (192.168.241.246)- Máy đích cần copy data đến để backup
1) Từ localhost tạo một ssh rsa key pair cho host validation:
3) Connect đến máy remotehost dùng ssh:
6) Kiểm Tra:
Hôm nay định viết một script để tự động copy backup dữ liệu từ local host sang 1 host khác.
Việc copy thì dễ dàng có thể dùng các lệnh scp hay rsync. Tuy nhiên vấn đề khó khăn ở đây là các lệnh trên yêu cầu phải nhập password.
Phải làm sao để thực hiện các lệnh nói trên đến remote host mà không phải nhập password thì việc backup tự động mới khả thi được.
THỰC HIỆN
Nào hãy bắt đầu. Giả sử
localhost (192.168.241.63) - Máy source cần copy data
remotehost (192.168.241.246)- Máy đích cần copy data đến để backup
1) Từ localhost tạo một ssh rsa key pair cho host validation:
[localhost]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 82:c6:21:5b:9e:07:6e:6d:3b:66:47:eb:9e:ff:6a:bd root@localhost
[localhost]# scp ~/.ssh/id_rsa.pub 192.168.241.246:~ The authenticity of host '192.168.241.246 (192.168.241.246)' can't be established. RSA key fingerprint is 2e:43:dd:e8:72:8a:47:91:89:7f:b9:3a:94:ca:2a:27. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.241.246' (RSA) to the list of known hosts. root@192.168.241.246's password: id_rsa.pub 100% 395 0.4KB/s 00:00
3) Connect đến máy remotehost dùng ssh:
[localhost]# ssh root@192.168.241.246 root@192.168.241.246's password: Last login: Tue Feb 22 14:13:28 2011 from 192.168.241.249 [remotehost ~]#
[remotehost]# ls -la ~/.ssh ls: cannot access /root/.ssh: No such file or directory
[remotehost]# mkdir .ssh [remotehost]# chmod 700 .ssh
[remotehost]# cat ~/id_rsa.pub >> .ssh/authorized_keys [remotehost]# chmod 600 .ssh/authorized_keys [remotehost]# rm id_rsa.pub
6) Kiểm Tra:
[localhost]# scp test.txt root@192.168.241.246:/hdd/ test.txt 100% 4 0.0KB/s 00:00
Friday, June 10, 2011
Migrate user account & samba user to new linux system
http://serverfault.com/questions/74370/how-to-migrate-samba-user-accounts-to-a-new-linux-server
You'll need to copy /etc/passwd, /etc/shadow, /etc/group, /etc/samba/smbusers, and /etc/samba/smbpasswd. This site shows you how to do the first 3, but I've done the last two and it worked fine.
Setup UID filter limit:
Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
Copy /etc/group file:
Copy /etc/shadow file:
Copy /etc/gshadow (rarely used):
Make a backup of /home and /var/spool/mail dirs:
Where,
Now restore passwd and other files in /etc/
Please note that you must use >> (append) and not > (create) shell redirection.
Now copy and extract home.tar.gz to new server /home
Now copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
Now reboot system; when the Linux comes back, your user accounts will work as they did before on old system:
You'll need to copy /etc/passwd, /etc/shadow, /etc/group, /etc/samba/smbusers, and /etc/samba/smbpasswd. This site shows you how to do the first 3, but I've done the last two and it worked fine.
Commands to type on old Linux system
First create a tar ball of old uses (old Linux system). Create a directory:# mkdir /root/move/Setup UID filter limit:
# export UGIDLIMIT=500Now copy /etc/passwd accounts to /root/move/passwd.mig using awk to filter out system account (i.e. only copy user accounts)
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.migCopy /etc/group file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/group > /root/move/group.migCopy /etc/shadow file:
# awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534) {print $1}' /etc/passwd | tee - |egrep -f - /etc/shadow > /root/move/shadow.migCopy /etc/gshadow (rarely used):
# cp /etc/gshadow /root/move/gshadow.migMake a backup of /home and /var/spool/mail dirs:
# tar -zcvpf /root/move/home.tar.gz /home
# tar -zcvpf /root/move/mail.tar.gz /var/spool/mail Where,
- Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. Limits according to different Linux distro:
- RHEL/CentOS/Fedora Core : Default is 500 and upper limit is 65534 (/etc/libuser.conf).
- Debian and Ubuntu Linux : Default is 1000 and upper limit is 29999 (/etc/adduser.conf).
- You should never ever create any new system user accounts on the newly installed Cent OS Linux. So above awk command filter out UID according to Linux distro.
- export UGIDLIMIT=500 - setup UID start limit for normal user account. Set this value as per your Linux distro.
- awk -v LIMIT=$UGIDLIMIT -F: '($3>=LIMIT) && ($3!=65534)' /etc/passwd > /root/move/passwd.mig - You need to pass UGIDLIMIT variable to awk using -v option (it assigns value of shell variable UGIDLIMIT to awk program variable LIMIT). Option -F: sets the field separator to : . Finally awk read each line from /etc/passwd, filter out system accounts and generates new file /root/move/passwd.mig. Same logic is applies to rest of awk command.
- tar -zcvpf /root/move/home.tar.gz /home - Make a backup of users /home dir
- tar -zcvpf /root/move/mail.tar.gz /var/spool/mail - Make a backup of users mail dir
# scp -r /root/move/* user@new.linuxserver.com:/path/to/locationCommands to type on new Linux system
First, make a backup of current users and passwords:# mkdir /root/newsusers.bak
# cp /etc/passwd /etc/shadow /etc/group /etc/gshadow /root/newsusers.bak
Now restore passwd and other files in /etc/
# cd /path/to/location
# cat passwd.mig >> /etc/passwd
# cat group.mig >> /etc/group
# cat shadow.mig >> /etc/shadow
# /bin/cp gshadow.mig /etc/gshadowPlease note that you must use >> (append) and not > (create) shell redirection.
Now copy and extract home.tar.gz to new server /home
# cd /
# tar -zxvf /path/to/location/home.tar.gzNow copy and extract mail.tar.gz (Mails) to new server /var/spool/mail
# cd /
# tar -zxvf /path/to/location/mail.tar.gzNow reboot system; when the Linux comes back, your user accounts will work as they did before on old system:
# reboot
Monday, June 6, 2011
Lenh mount file iso tren linux
mount -o loop -t iso9660 clonezilla-live-1.2.8-42-i686.iso /mnt
Subscribe to:
Posts (Atom)