2016年6月14日 星期二

linux remove disk



http://www.redhatgeek.com/linux/remove-a-disk-from-redhatcentos-linux-without-rebooting-the-system

先 umount 停止IO
echo "offline" > /sys/block/sdc/device/state

echo "1" > /sys/block/sdc/device/delete







=======END=========

CentOS7 postfix 2.10 openwebmail 3 安裝記錄

參考
http://www.wkb.idv.tw/moodle/mod/page/view.php?id=7831&lang=zh_tw



mkdir /home01


先把 yum 跟 wget 設 ftp proxy

wget ftp://openwebmail.org/pub/openwebmail/el7/openwebmail-el7.repo -e use_proxy=yes -e ftp_proxy=172.22.x.x:3128

vim /etc/yum.conf
加
proxy=http://172.22.x.x:3128

然後
yum update

yum --downloadonly --downloaddir=/usr/local/src install openwebmail perl-CGI-SpeedyCGI perl-Authen-PAM perl-HTML-Template

這時候有的東西是
openwebmail-2.54-1.el7.noarch.rpm               perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm
openwebmail-data-2.54-1.el7.noarch.rpm          perl-IO-Compress-2.061-2.el7.noarch.rpm
perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm

缺了
perl-CGI-SpeedyCGI
perl-Authen-PAM
perl-HTML-Template


SpeedyCGI  要從 EPEL 裝

參考
https://support.rackspace.com/how-to/install-epel-and-additional-repositories-on-centos-and-red-hat/

yum install epel-release
yum update


繼續安裝
rm -f openwebmail*.rpm  (把 2.54 的 openwebmail 砍掉 等等要抓新的)
rpm -Uvh *.rpm  (把其他的裝進去)
yum install perl-Authen-PAM perl-CGI-SpeedyCGI perl-HTML-Template


來裝本體
cd /var/www
wget http://openwebmail.acatysmoof.com/download/current/openwebmail-current.tar.gz -e use_proxy=yes -e ftp_proxy=172.22.x.x:3128

tar zxvf ./openwebmail-current.tar.gz

ln -s /var/www/data/openwebmail /var/www/html/openwebmail
cd /var/www/html/openwebmail/
ln -s redirect.html index.html
cp /usr/bin/speedy /usr/bin/speedy_suidperl
chmod 4555 /usr/bin/speedy_suidperl

cd /var/www/cgi-bin/openwebmail/
sed -i -e 's/perl -T/speedy_suidperl -T -- -T\/tmp\/speedy/' openwebmail*.pl

vim etc/openwebmail.conf


#ow_cgidir          /usr/local/www/cgi-bin/openwebmail
ow_cgidir               /var/www/cgi-bin/openwebmail

#ow_htmldir              /usr/local/www/data/openwebmail
ow_htmldir              /var/www/data/openwebmail

新增
mailspooldir            /var/spool/mail
use_homedirspools       yes


cd /var/www/cgi-bin/openwebmail/
cp defaults/dbm.conf .

改 /var/www/cgi-bin/openwebmail/etc/dbm.conf
dbm_ext .pag
dbmopen_ext none
dbmopen_haslock no


cd /var/www/cgi-bin/openwebmail/
chmod 777 ./misc/tools/wrapsuid/wrapsuid.pl ./misc/tools/wrapsuid/wrapsuid.pl /var/www/cgi-bin/openwebmail/openwebmail*.pl
chmod 660 ./misc/tools/wrapsuid/wrapsuid.pl
chmod 4755 openwebmail*.pl


touch /var/log/openwebmail.log
chown root.mail /var/log/openwebmail.log
chmod -R 777 /var/www/cgi-bin/openwebmail/etc/sessions/

然後改 /etc/postfix/main.cf

#inet_protocols = all
inet_protocols = ipv4

#inet_interfaces = localhost
inet_interfaces = all

#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, webmail.$mydomain, *****.$mydomain

home_mailbox = Mailbox

mynetworks = 127.0.0.0/8, 192.168.0.0/24, 172.22.0.0/16, blahblah
relay_domains = $mydestination
myhostname = ms3.xxxxx
mydomain = xxxxx
myorigin = $mydomain


service postfix restart



出現
YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!
cd /var/www/cgi-bin/openwebmail/
chmod 4755 openwebmail*.pl

./openwebmail-tool.pl --init

出現

登入失敗︰系統確認錯誤。
請返回然後 再試一次.

cd /var/www/cgi-bin/openwebmail/
cp defaults/auth_unix.conf .
vim auth_unix.conf

passwdfile_plaintext    /etc/passwd
#passwdfile_encrypted   /etc/master.passwd
passwdfile_encrypted    /etc/shadow
#passwdmkdb             /usr/sbin/pwd_mkdb
passwdmkdb              none
check_expire            no
check_nologin           no
#check_shell            no
check_shell            yes

service httpd restart


錯誤訊息觀察

Perl 直譯器產生的問題
/var/log/httpd/error.log

openwebmail 自己的問題
/var/log/openwebmail.log

Postfix 寄信的問題
/var/log/maillog








設定  dovecot

/etc/dovecot/dovecot.conf

#protocols = imap pop3 lmtp
protocols = pop3

#listen = *, ::
listen = *

/etc/dovecot/conf.d/

10-auth.conf

#disable_plaintext_auth = yes
disable_plaintext_auth = no

10-logging.conf

#mail_debug = no
mail_debug = yes

(  log 位置預設在 /var/log/maillog . 可以用 doveadm log find 確認)

10-mail.conf

#mail_location = 
mail_location = mbox:~/imap:INBOX=~/Mailbox

10-ssl.conf

#ssl = required
ssl = no




改 hostname

/etc/hosts

用 NetworkManager 的話 可以用


hostnamectl set-hostname server1.cyberciti.biz --static
 systemctl restart systemd-hostnamed
hostnamectl status




SMTP 指令測試

http://www.yuki-onna.co.uk/email/smtp.html

telnet mail.domain.ext 25

HELO local.domain.name
MAIL FROM: mail@domain.ext
RCPT TO: mail@otherdomain.ext

DATA
Subject:-type subject here-
- MAIL_BODY -
.
QUIT

在 openwebmail.conf 裡面可以把 webdisk / sshterm 等等的關掉 . 可參考 defaults/openwebmail.conf



============END===========

2016年6月9日 星期四

jsp file upload

jsp file upload

http://www.tutorialspoint.com/jsp/jsp_file_uploading.htm
http://commons.apache.org/proper/commons-fileupload/using.html
http://stackoverflow.com/questions/16993934/retrieve-file-and-parameters-in-jsp-from-post-request

ORACLE 過 purge

CLOB 搬移
http://www.dba-oracle.com/t_alter_table_move_index_constraint.htm


找 CLOB Column
 select table_name from dba_tab_columns where OWNEr='SCOTT' and data_type='CLOB';
  select table_name from dba_tab_columns where OWNEr='SCOTT' and data_type like '%LOB%';
  
Assuming that I have table "TEST" in USERS TableSpace

CREATE TABLE TEST
(
TEST_ID NUMBER NOT NULL,
TEST_NAME CLOB,
CONSTRAINT PK_TEST PRIMARY KEY(TEST_ID)
)
/


SQL> ALTER TABLE TEST MOVE TABLESPACE EXAMPLE;

Above command will move the table to new tablespace but will not move the CLOB segment and it will still be in original tablespace. This is because LOB data is stored outside of the table.
Check the tablespace of the CLOB column by issuing following sql.

SQL> SELECT index_name, tablespace_name
FROM user_indexes WHERE table_name = ‘TEST’;

INDEX_NAME TABLESPACE_NAME
—————————— —————-
SYS_IL0000073575C00002$$ USERS

In order to move CLOB column to different tablespace, we have to issue following command.

SQL> ALTER TABLE TEST MOVE LOB(TEST_NAME) STORE AS (TABLESPACE EXAMPLE);

In above example, TEST_NAME is the CLOB column which we want to move to new tablespace and EXAMPLE is target tablespace. Above command will successfully move LOB segments to the new tablespace. We can verify it by issuing same sql again.

SQL> SELECT index_name, tablespace_name
FROM user_indexes WHERE table_name = ‘TEST’;

INDEX_NAME TABLESPACE_NAME
—————————— —————
SYS_IL0000073575C00002$$ EXAMPLE

ORACLE parameter file (PFILE , SPFILE)

CREATE PFILE='/tmp/initoradbtst.ora.2016053102' from spfile='/oracle/10g/product/10.2.0/db/dbs/spfileoradbtst.ora';

CREATE spfile='/oracle/10g/product/10.2.0/db/dbs/spfileoradbtst.ora' from PFILE='/oracle/10g/product/10.2.0/db/dbs/initoradbtst.ora'  ;


10g 這邊只能 create pfile from spfile 或是 creare spfile form pfile

會在 ORACLE_HOME/dbs 底下先找 spfile 跟 pfile . (順序要再確認)

在啟動的時候可以指定 startup PFILE='絕對路徑';


--controll file 比較麻煩 要 recreate  . 而且 scn 不對還要 resetlog