2015/10/21

Published 10月 21, 2015 by

Samba Domain Integration-Samba加入Windows 2008網域

Samba Domain Integration-Samba加入Windows 2008網域
所需檔案:
yum install samba
yum install krb5-server
yum install krb5-workstation
yum install samba-winbind

DC
IP: 192.168.3.48
Hostname:dc123
domainabc.example.com.tw

RHEL 6.5 X64
HOSTNAME:test1

設定步驟:
一、設定Hostname,
[root@test1 samba]# vi /etc/sysconfig/network
HOSTNAME=test1

二、Samba設定:
[root@test1 samba]# vi /etc/samba/smb.conf
[global]
   workgroup = DOM
   password server = dc123.abc.example.com.tw #密碼server指定ad server
   realm = abc.EXAMPLE.COM.TW #完整網域名稱
   security = ads #認證方式交給ad認證
   encrypt passwords = yes #編碼方式傳遞密碼
   idmap config * : range = 16777216-33554431 #修改UIDGID的範圍及目錄
   template shell = /bin/bash #指定AD帳號的SHELL
   winbind enum users = yes
   winbind enum groups = yes
   winbind use default domain = yes
   template homedir =  /home/%D/%U

        server string = EXAMPLE TEST Server #描述
        netbios name = test1 #Linux主機名稱

        # logs split per machine
        log file = /var/log/samba/%m.log #Log message
        # max 50KB per log file, then rotate
        max log size = 102400 #最大的檔案

[TMP]
        comment         = For tmp
        path            = /tmp
        browseable      = yes
        writable        = yes
        valid users     = @"DOM\FS99_test_rw"
        create mask     = 0644
        directory mask  = 0750

三、DNS/認證順序設定:
[root@test1 samba]# cat /etc/resolv.conf
search abc.example.com.tw example.com.tw
nameserver 192.168.3.48
nameserver 192.168.3.47
options timeout:1
options attempts:1 rotate

[root@test1 samba]# vi /etc/nsswitch.conf
passwd:     files winbind
shadow:     files winbind
group:      files winbind
hosts:      dns files

四、Kerberos認證設定:
[root@test1 samba]# vi /etc/krb5.conf
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log

[libdefaults]
default_realm = abc.example.com.tw
dns_lookup_realm = true
dns_lookup_kdc = true
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
abc.example.com.tw = {
  kdc = dc123.abc.example.com.tw
  kdc = dc35.abc.example.com.tw
  admin_server = dc123.abc.example.com.tw
  default_domain=abc.example.com.tw
}

[domain_realm]
abc.example.com.tw = abc.example.com.tw
.abc.example.com.tw = abc.example.com.tw
DOM = abc.example.com.tw
.DOM = abc.example.com.tw

五、samba/winbind 服務啟動,並設定開機自動啟動該服務
# service smb start
# chkconfig smb on
# service winbind start
# chkconfig winbind on


六、測試連線
[root@test1 ~]# kinit sidney@abc.EXAMPLE.COM.TW

PS.網域一定要大寫,小寫會出錯
七、Linux主機加入/退出網域
加入網域:
[root@test1 ~]# net ads join -U sidney@abc.example.com.tw
Using short domain name -- DOM
Joined 'TEST1' to dns domain 'abc.example.com.tw'

或用以下的方式加入網域:
net ads join -S abc.example.com.tw
net rpc join -S abc.example.com.tw
net ads join -U sidney@abc.example.com.tw
net rpc join -U sidney@abc.example.com.tw
net rpc join -U sidney

退出網域方式:
net ads leave -U sidney@abc.example.com.tw

八、設定NTP(同步時間和domain不能超過5分鐘)

[root@test1 ~]# cat /etc/ntp.conf 
server 192.168.6.86
server 192.168.6.87

九、Check:
確認連線
[root@test1 ~]# wbinfo -t
checking the trust secret for domain DOM via RPC calls succeeded

確認網域資訊
[root@test1 ~]# net ads info
LDAP server: 192.168.3.48
LDAP server name: dc123.abc.example.com.tw
Realm: abc.EXAMPLE.COM.TW
Bind Path: dc=HS,dc=EXAMPLE,dc=COM,dc=TW
LDAP port: 389
Server time: Thu, 15 Oct 2015 15:19:39 CST
KDC server: 192.168.3.48
Server time offset: 0

確認user資訊:
[root@test1 ~]# wbinfo -i sidney

確認domain user資訊:
[root@test1 ~]# wbinfo -i


十、文字介面設定:

#setup
設定授權:
選擇授權方式:Winbind & Kerberos




輸入網域資料
認證選擇ads認證
輸入帳密

做認證過程中的錯誤訊息:


十一、        錯誤記錄

[root@test1 samba]# cat /var/log/krb5kdc.log
krb5kdc: No such file or directory - while initializing database for realm abc.example.com.tw
krb5kdc: No such file or directory - while initializing database for realm abc.example.com.tw

[root@test1 samba]# kdb5_util create -s -r abc.example.com.tw
Loading random data
Initializing database '/var/kerberos/krb5kdc/principal' for realm 'abc.example.com.tw',
master key name 'K/M@abc.example.com.tw'
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter KDC database master key:
Re-enter KDC database master key to verify:
[root@test1 samba]# service krb5kdc restart
Stopping Kerberos 5 KDC:                                   [FAILED]
Starting Kerberos 5 KDC:                                   [  OK  ]

十二、        相關Reference:

Read More

2015/07/18

Published 7月 18, 2015 by

修改Linux 網卡ethx的對應

OS: RHEL6.5_X64
透過虛擬機常會出現虛擬網卡,因為變更或新增網卡之後,eth0、eth1、eth2…常會變更,導致系統通常不是抓到eth0,或者他的對應變來變去,變更方法如下:

一、修改此檔案, /etc/udev/rules.d/70-persistent-net.rules ,把不要的網卡刪除掉
二、到網卡的設定檔去做修改mac的對應


#vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.

# Firewire device 000ac606203a402e (ohci1394)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:0d:a4:e5:02:44:e0:62", NAME="eth0"

# PCI device 0x8086:0x119b (e1000)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:26:d3:32:a3:c8", NAME="eth1"


Note: 如果有多張網卡,還是會跑來跑去,可以在這邊來做定義試試
/etc/modprobe.d/aliases 中加上
alias eth0 e1000
alias eth1 tulip


Reference:
http://wiki.debian.org.hk/w/Fix_network_interface_name

http://blog.xuite.net/happyman/tips/16199196-%5Bubuntu%5D+udev+%E5%9B%BA%E5%AE%9A+netowrk+device+name

Read More

2014/12/14

Published 12月 14, 2014 by

找尋檔案中的字串-find / grep 指令

在linux底下,找尋目錄及子目錄的檔案的字串:

要利用 find 的功能來協助,就嘗試寫寫看囉!我的寫法如下:

# find ./ -type f -name \*.php |xargs grep 'localhost'

# grep -r --include='*.php' localhost .

Read More

2014/07/24

Published 7月 24, 2014 by

Create partition Table/Index

Create partition Table/Index
1.      確認是否需要新增Table/Index Tablespace
2.      確認空間是否足夠
3.      Create Partition table
4.      Split Partition
5.      Create Partition Index
6.      確認建立的Partition(找出最大的Partition)

一、產生新的 Table/index Tablespace語法(自行確認是否要新增)
CREATE TABLESPACE STGC5_TRG_2015Q1 DATAFILE
  '/rptdata1/c5prpt/STGC5_TRG_2015Q1_01.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE 32000M,
  '/rptdata2/c5prpt/STGC5_TRG_2015Q1_02.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE 32000M,
  '/rptdata3/c5prpt/STGC5_TRG_2015Q1_03.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE 32000M,
  '/rptdata4/c5prpt/STGC5_TRG_2015Q1_04.dbf' SIZE 500M AUTOEXTEND ON NEXT 100M MAXSIZE 32000M
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

二、確認Tablespace空間大小:
select t.tablespace_name ,avg(d.bytes/d.maxbytes)*100 as Used_Rate,sum(d.maxbytes)/1024/1024/1024 as max_g,sum(d.bytes)/1024/1024/1024 as Used_g,
       (sum(d.maxbytes)-sum(d.bytes))/1024/1024/1024 as free_space_g
FROM DBA_TABLESPACES T,DBA_DATA_FILES D
WHERE T. TABLESPACE_NAME =D. TABLESPACE_NAME and d.maxbytes!=0 group by t.tablespace_name
ORDER BY Free_space_g

三、增加Partition Table:

1.日期格式:
select 'ALTER TABLE '||TABLE_OWNER||'.'||TABLE_NAME||' ADD PARTITION P2015Q1 VALUES LESS THAN (''20150401 000000'') TABLESPACE DWC5_TBL;'
from dba_tab_partitions t where table_owner='DWC5' AND PARTITION_NAME='P2014Q1';

結果:
ALTER TABLE DWC5.CUT_TIME_WIP ADD PARTITION P2015Q1 VALUES LESS THAN ('20150401 000000') TABLESPACE DWC5_TBL;


2.時間格式:
select 'ALTER TABLE '||TABLE_OWNER||'.'||TABLE_NAME||' ADD PARTITION P2015Q1 VALUES LESS THAN TO_DATE('' 2015-04-01 00:00:00'', ''SYYYY-MM-DD HH24:MI:SS'', ''NLS_CALENDAR=GREGORIAN'') TABLESPACE DWC5_TBL;'
from dba_tab_partitions t where table_owner='DWC5' AND PARTITION_NAME='P2014Q1';

結果:
ALTER TABLE DWC5.CUT_TIME_WIP ADD PARTITION P2015Q1 VALUES LESS THAN TO_DATE(' 2015-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TABLESPACE DWC5_TBL;

四、Split Partition
SELECT 'ALTER TABLE '||TABLE_OWNER||'.'||TABLE_NAME||' SPLIT PARTITION CTHI_MAXVALUE (TO DATE(''20170101 000000'') INTO (PARTITION '
||PARTITION_NAME|| ', PARTITION CTHI_MAXVALUE TABLESPACE) ' ||TABLESPACE_NAME|| ';' from dba_tab_partitions t
where table_owner='C5PROD' AND PARTITION_NAME LIKE '%2015Q4';

結果:
ALTER TABLE C5PROD.FWAMTCOMPTRACKHISTORY SPLIT PARTITION CTHI_MAXVALUE (TO DATE('20170101 000000') INTO (PARTITION CTHI_2015Q4, PARTITION CTHI_MAXVALUE) TABLESPACE C5_PTT_CTHI10;

五、增加Partition Index
每季增加:
SELECT * FROM (SELECT 'ALTER INDEX ' || OWNER || '.' || SEGMENT_NAME || ' REBUILD PARTITION P2015Q4 TABLESPACE= ' || TABLESPACE_NAME || ';'  from dba_segments 
where tablespace_name='DWC5_IDX' AND PARTITION_NAME='P2014Q4');

結果:
ALTER INDEX DWC5.XPKCUT_TIME_WIP_P REBUILD PARTITION P2015Q4 TABLESPACE= DWC5_IDX;

一次找出一整年(Partition table要先建立好)
SELECT 'ALTER INDEX ' || INDEX_NAME || ' REBUILD PARTITION '||PARTITION_NAME|| ' TABLESPACE '||TABLESPACE_NAME|| ';'
FROM ALL_IND_PARTITIONS WHERE INDEX_OWNER='STGC5' AND PARTITION_NAME LIKE '%2014Q%';

結果:
ALTER INDEX IDX_COMPDLTYPETIME_600A REBUILD PARTITION P2014Q1 TABLESPACE STGC5_TRG_IDX_2014Q1;

六、找出最大的Partition
SELECT INDEX_NAME,max(PARTITION_NAME) FROM ALL_IND_PARTITIONS WHERE INDEX_OWNER='STGC5'  group by INDEX_NAME order by max(PARTITION_NAME);


參考資料:

http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm
Read More

2014/07/21

Published 7月 21, 2014 by

Linux下安裝xrdp

Linux下安裝xrdp
使用rdp協定訪問遠端Linux桌面
Read More

2014/07/20

Published 7月 20, 2014 by

被動收入-分類

一般來說被動收入有兩種方式:
1.
透過資本賺被動收入(較適合有一桶金以上的人)
2.
透過技能專長興趣賺被動收入(較適合時間較多的人)

Read More