2019年8月20日火曜日

vimカスタマイズ

【viで文字コードを指定して再読込】
:e ++enc=shift_jis                       [ shift_jis / utf-8 / euc-jp 】


# vi ~/.vimrc
set encoding=utf-8
set fileencoding=utf-8
scriptencoding utf-8
set paste
set number
"-----------------------------------------------------------
" TABキーを押した際にタブ文字の代わりにスペースを入れる
set expandtab
set tabstop=2
set shiftwidth=2
"-----------------------------------------------------------
" Jsonファイルを表示。
" command :Jq
"-----------------------------------------------------------
command! -nargs=? Jq call s:Jq(<f-args>)
function! s:Jq(...)
  if 0 == a:0
    let l:arg = "."
  else
    let l:arg = a:1
  endif
execute "%! jq \"" . l:arg . "\""
endfunction
"xml 整形
command Xml :%s/></>\r</g | filetype indent on | setf xml | normal gg=G

"-----インデンドの可視化------------------------------------
" command : set list / set nolist
"-----------------------------------------------------------
hi SpecialKey ctermfg=darkmagenta
set listchars=tab:¦_,trail:-,eol:↲,extends:»,precedes:«,nbsp:%

"--------neobundle.vim--------------------------------------
if &term =~ "xterm"
  let &t_SI .= "\e[?2004h"
  let &t_EI .= "\e[?2004l"
  let &pastetoggle = "\e[201~"

  function XTermPasteBegin(ret)
    set paste
    return a:ret
  endfunction
  inoremap <special> <expr> <Esc>[200~ XTermPasteBegin("")
endif

if has('vim_starting')
  " 初回起動時のみruntimepathにNeoBundleのパスを指定する
  set runtimepath+=~/.vim/bundle/neobundle.vim/

  " NeoBundleが未インストールであればgit cloneする・・・・・・①
  if !isdirectory(expand("~/.vim/bundle/neobundle.vim/"))
    echo "install NeoBundle..."
    :call system("git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim")
  endif
endif

call neobundle#begin(expand('~/.vim/bundle/'))

"----------------------------------------------------------
" インストールするVimプラグインを以下に記述
" NeoBundle自身を管理
NeoBundleFetch 'Shougo/neobundle.vim'
"----------------------------------------------------------
" ここに追加したいVimプラグインを記述する・・・・・・②

" カラースキームmolokai
NeoBundle 'tomasr/molokai'
" カラースキームrupza
NeoBundle 'felipesousa/rupza'
" ステータスラインの表示内容強化
NeoBundle 'itchyny/lightline.vim'

" 末尾の全角と半角の空白文字を赤くハイライト
" command :FixWhitespce
NeoBundle 'bronson/vim-trailing-whitespace'

" インデントの可視化
NeoBundle 'Yggdroot/indentLine'
"----------------------------------------------------------
call neobundle#end()
"----------------------------------------------------------
" ファイルタイプ別のVimプラグイン/インデントを有効にする
filetype plugin indent on
" 未インストールのVimプラグインがある場合、インストールするかどうかを尋ねてくれるようにする設定・・・・・・③
NeoBundleCheck

"----------------------------------------------------------
" colorschemeの設定
"----------------------------------------------------------
if neobundle#is_installed('molokai') " molokaiがインストールされていれば
" colorscheme molokai " カラースキームにmolokaiを設定する
  colorscheme rupza " カラースキームにrupzaを設定する
endif
set t_Co=256 " iTerm2など既に256色環境なら無くても良い
syntax enable " 構文に色を付ける

"----------------------------------------------------------
" ステータスラインの設定
"----------------------------------------------------------
set laststatus=2 " ステータスラインを常に表示
set showmode " 現在のモードを表示
set showcmd " 打ったコマンドをステータスラインの下に表示
set ruler " ステータスラインの右側にカーソルの現在位置を表示する

" indentLine
let g:indentLine_color_term = 111
let g:indentLine_color_gui = '#708090'
let g:indentLine_char = '¦'

2019年8月15日木曜日

CentOS7 /homeを別ディスクにマウント

root でログイン
# userdel -r xxxxx              /home以下のユーザを削除
# ls -l /home
total 0                         確認
# umount /home

# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xab90547f.

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

コマンド (m でヘルプ): m
コマンドの動作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

コマンド (m でヘルプ): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
パーティション番号 (1-4, default 1):
最初 sector (2048-976773167, 初期値 2048):
初期値 2048 を使います
Last sector, +sectors or +size{K,M,G} (2048-976773167, 初期値 976773167):
初期値 976773167 を使います
Partition 1 of type Linux and of size 465.8 GiB is set

コマンド (m でヘルプ): t
Selected partition 1
Hex code (type L to list all codes): L

 0  空              24  NEC DOS         81  Minix / 古い Li bf  Solaris       
 1  FAT12           27  Hidden NTFS Win 82  Linux スワップ  c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 隠し C: ド c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux 拡張領域  c7  Syrinx        
 5  拡張領域        41  PPC PReP Boot   86  NTFS ボリューム da  非 FS データ  
 6  FAT16           42  SFS             87  NTFS ボリューム db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux プレーン  de  Dell ユーティリ
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt        
 9  AIX ブート可能  4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access    
 a  OS/2 ブートマネ 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O       
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor     
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad ハ eb  BeOS fs       
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT           
 f  W95 拡張領域 (L 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC 
11  隠し FAT12      56  Golden Bow      a8  Darwin UFS      f1  SpeedStor     
12  Compaq 診断     5c  Priam Edisk     a9  NetBSD          f4  SpeedStor     
14  隠し FAT16 <32M 61  SpeedStor       ab  Darwin ブート   f2  DOS セカンダリ
16  隠し FAT16      63  GNU HURD または af  HFS / HFS+      fb  VMware VMFS   
17  隠し HPFS/NTFS  64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI スワップ   fd  Linux raid 自動
1b  隠し W95 FAT32  70  DiskSecure Mult bb  隠し Boot Wizar fe  LANstep       
1c  隠し W95 FAT32  75  PC/IX           be  Solaris ブート  ff  BBT           
1e  隠し W95 FAT16  80  古い Minix    
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

コマンド (m でヘルプ): w
パーティションテーブルは変更されました!
ioctl() を呼び出してパーティションテーブルを再読込みします。
ディスクを同期しています。

# fdisk -l /dev/sdb
Disk /dev/sdb: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O サイズ (最小 / 推奨): 4096 バイト / 4096 バイト
Disk label type: dos
ディスク識別子: 0xab90547f

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1            2048   976773167   488385560   8e  Linux LVM

# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created.
# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <222.57 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              56977
  Free PE               1
  Allocated PE          56976
  PV UUID               IbFRgF-14az-CyYG-Vq0o-JRll-rEPl-TwfdZA
  
  "/dev/sdb1" is a new physical volume of "465.76 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name              
  PV Size               465.76 GiB
  Allocatable           NO
  PE Size               0  
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               wSOMkJ-a57d-M5Ko-F5PG-TktP-Gm6g-KkozMu
  
# vgcreate lvguserdata /dev/sdb1
  /dev/sdc: open failed: メディアが見つかりません
  /dev/sdd: open failed: メディアが見つかりません
  /dev/sde: open failed: メディアが見つかりません
  /dev/sdf: open failed: メディアが見つかりません
  Volume group "lvguserdata" successfully created
# vgdisplay
  --- Volume group ---
  VG Name               lvguserdata
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <465.76 GiB
  PE Size               4.00 MiB
  Total PE              119234
  Alloc PE / Size       0 / 0  
  Free  PE / Size       119234 / <465.76 GiB
  VG UUID               8CFNUB-wlEk-JOA2-LtDn-YzBN-dL0U-mDiQKM
  
  --- Volume group ---
  VG Name               centos
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <222.57 GiB
  PE Size               4.00 MiB
  Total PE              56977
  Alloc PE / Size       56976 / 222.56 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               ZUzbN5-dx4i-qR5d-wNxD-ejeB-9syW-aRtbgC
  
# vgscan
  Reading volume groups from cache.
  Found volume group "lvguserdata" using metadata type lvm2
  Found volume group "centos" using metadata type lvm2
[root@localhost dev]# lvcreate --name home -l 100%FREE lvguserdata
  Logical volume "home" created.
[root@localhost dev]# lvdisplay lvguserdata
  --- Logical volume ---
  LV Path                /dev/lvguserdata/home
  LV Name                home
  VG Name                lvguserdata
  LV UUID                oatwnX-vjXB-hgXp-DNfo-zc1W-wUJO-rBJwGH
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2019-08-15 19:58:48 +0900
  LV Status              available
  # open                 0
  LV Size                <465.76 GiB
  Current LE             119234
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
  
# mkfs.xfs /dev/lvguserdata/home
meta-data=/dev/lvguserdata/home  isize=512    agcount=4, agsize=30523904 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=122095616, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=59617, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
# vi /etc/fstab
/dev/mapper/lvguserdata-home /home              xfs     defaults        0 0
# ls -l /dev/centos
合計 0
lrwxrwxrwx. 1 root root 7  8月 15 19:21 home -> ../dm-2
lrwxrwxrwx. 1 root root 7  8月 15 19:21 root -> ../dm-0
lrwxrwxrwx. 1 root root 7  8月 15 19:21 swap -> ../dm-1

# lvremove /dev/centos/home
# lvdisplay centos
# lvextend -l +100%FREE /dev/centos/root
# df
# xfs_growfs /dev/centos/root
# df


2019年8月1日木曜日

Oracleが ロックした。セッションをKILL →切れない ORA-00031: session marked for kill

$ alias sqlplus='rlwrap -pRed -if /usr/local/opt/rlwrap-extensions/sqlplus sqlplus64'
$ sqlplus user/password@192.168.1.xxx:1521/sid
SQL> SELECT s.sid,s.serial#, s.username, s.program FROM V$SESSION s where s.username='ARCSDBSS' and s.program='python36@buffy3 (TNS V1-V3)';

SQL> select s.sid, s.serial#, s.username, s.osuser, s.machine, s.terminal, s.program, o.object_name from v$session s, v$locked_object l, dba_objects o where s.sid = l.session_id and l.object_id = o.object_id;

SQL> alter system kill session 'sid, serial#'

killedになったが切れない。
ORA-00031: session marked for kill

ALTER SYSTEM DISCONNECT SESSION 'sid,serialNo' {POST_TRANSACTION | IMMEDIATE};
ERROR at line 1:
ORA-00031: session marked for kill

すぐ返って来るけど同じだ!!!!

select spid, s.sid, s.serial#, s.status , osuser, s.program,s.username, s.event from
v$process p, v$session s where p.addr=s.paddr and s.status = 'KILLED';

列幅調整
COLUMN spid FORMAT a5 TRUNCATE

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...