Posts

Showing posts with the label solaris

System Kernel Hardening on Solaris

Just add this lines to your /etc/system file. Better to use it for high load server. set noexec_user_stack=1 set noexec_user_stack_log=1 set semsys:seminfo_semmni=100 set semsys:seminfo_semmns=1024 set semsys:seminfo_semmsl=256 set semsys:seminfo_semvmx=32767 set shmsys:shminfo_shmmax=4294967295 set shmsys:shminfo_shmmin=1 set shmsys:shminfo_shmmni=100 set shmsys:shminfo_shmseg=10

Network Hardening on Solaris

Just adding this script on your /etc/rc3.d, dont' forget to chmod it to 744. /etc/rc3.d/S100nettune #!/bin/sh # # Basic Hardening /usr/sbin/ndd -set /dev/ip ip_forward_src_routed 0 /usr/sbin/ndd -set /dev/ip ip_forwarding 0 /usr/sbin/ndd -set /dev/tcp tcp_conn_req_max_q 16384 /usr/sbin/ndd -set /dev/tcp tcp_conn_req_max_q0 16384 /usr/sbin/ndd -set /dev/tcp tcp_xmit_hiwat 400000 /usr/sbin/ndd -set /dev/tcp tcp_recv_hiwat 400000 /usr/sbin/ndd -set /dev/tcp tcp_cwnd_max 2097152 /usr/sbin/ndd -set /dev/tcp tcp_ip_abort_interval 60000 /usr/sbin/ndd -set /dev/tcp tcp_rexmit_interval_initial 4000 /usr/sbin/ndd -set /dev/tcp tcp_rexmit_interval_max 10000 /usr/sbin/ndd -set /dev/tcp tcp_rexmit_interval_min 3000 /usr/sbin/ndd -set /dev/tcp tcp_max_buf 4194304 /usr/sbin/ndd -set /dev/tcp tcp_maxpsz_multiplier 10 #Oracle Required /usr/sbin/ndd -set /dev/udp udp_recv_hiwat 65535 /usr/sbin/ndd -set /dev/udp udp_xmit_hiwat 65535 # Added parameter /usr/sbin/ndd -set /dev/...

Mirror disk on Solaris

show disk layout on 1st harddisk partition # format 0 p p create copy of Volume Table of Contents from 1st harddisk partition # prtvtoc /dev/rdsk/c1t0d0s2 | fmthard –s - /dev/rdsk/c1t1d0s2 create metadb as database that contain all mirror configuration. slice 7 is unused partition # metadb –a –c 3 –f c1t0d0s7 c1t1d0s7 create virtual device for each slice # metainit –f d11 1 1 c1t0d0s0 # metainit –f d12 1 1 c1t1d0s0 # metainit d10 –m d11 # metainit –f d21 1 1 c1t0d0s1 # metainit –f d22 1 1 c1t1d0s1 # metainit d20 –m d21 # metainit –f d31 1 1 c1t0d0s3 # metainit –f d32 1 1 c1t1d0s3 # metainit d30 –m d31 # metainit –f d41 1 1 c1t0d0s4 # metainit –f d42 1 1 c1t1d0s4 # metainit d40 –m d41 # metainit –f d51 1 1 c1t0d0s5 # metainit –f d52 1 1 c1t1d0s5 # metainit d50 –m d51 # metainit –f d61 1 1 c1t0d0s6 # metainit –f d62 1 1 c1t1d0s6 # metainit d60 –m d61 Tell system that root actually virtual device, not slice anymore # metaroot d10 Reboot system # shutdown -g0 -i6 -y Add virtual device from...

ALOM Solaris

From konsole to alom # #. From alom to konsole sc> console Configure alom from scratch sc> setupsc After configure, you should reset alom with sc> resetsc graceful reset server sc> poweroff sc> poweron force reset sc> poweroff -f sc> poweron immediately reset sc> reset go to OpenBoot PROM sc> break show env sc> showenvirontment change alom password login sc> password

logadm on Solaris

If we want to administering log files on solaris, we can use logadm. Another option we also can use logrotate. For example : we have log files at /var/log/tinyproxy.log 1. we want to rotate log after reach 1MB. # logadm -w /var/log/tinyproxy.log -s 1m 2. we want to rotate log every day. # logadm -w /var/log/tinyproxy.log -p 1d 3. we want to keep until previous 10 day only. # logadm -w /var/log/tinyproxy.log -C10 etc... for more details, you should see logadm manual. File configuration of logadm at /etc/logadm.conf For default logadm run every morning 3:10 AM by crontab process. You can see crontab list with this : # crontab -e If you just see number after running command above, # crontab -e 713 you should define your editor profile. # export EDITOR=vi # crontab -e

General Solaris Command

Shows the ethernet address arp table # arp -a Delete a stale ethernet entry for host xhost # arp -d xhost Reports disk space used in Kilobytes # du -k Reports only total disk space used in Kilobytes # du -sk Tells you how big the / files are in reverse order # du -ad / | sort -nr Mount an ISO 8660 CDROM # /bin/mount -F hsfs -o ro /dev/sr0 /cdrom Disk geometry and partitioning info # prtvtoc /dev/rdsk/c0t0d0s2 Zero's out the file without breaking pipe # cat /dev/null > filename Make a mirror image of your boot disk # dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096 Check a UFS filesystem # fsck -F ufs /dev/rdsk/cxtxdxsx Check a UFS filesystem with auto-answer "yes" # fsck -F ufs -y /dev/rdsk/cxtxdxsx Check using an alternate super block # fsck -F ufs -o b=97472 /dev/rdsk/cxtxdxsx Verify reconfigurable hardware resources # cfgadm Display kernel module information # /usr/sbin/modinfo Load a kernel module # /usr/sbin/modload Unload a kernel module # /usr/sbin/modunload -i Tune...

Show I/O error solaris

Show I/O error solaris # iostat -eE ---- errors --- sd0 0 0 0 0 ssd0 0 0 0 0 ssd1 0 0 0 0 nfs2 0 0 0 0 sd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 Vendor: TOSHIBA Product: ODD-DVD SD-C2732 Revision: 1051 Serial No: Size: 0.00GB Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 Illegal Request: 0 Predictive Failure Analysis: 0 ssd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 Vendor: FUJITSU Product: MAT3073F SUN72G Revision: 0602 Serial No: 0527B08LLN Size: 73.40GB Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 Illegal Request: 0 Predictive Failure Analysis: 0 ssd1 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 Vendor: FUJITSU Product: MAT3073F SUN72G Revision: 0602 Serial No: 0526B08BHH Size: 73.40GB Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0 Illegal Request: 0 Predictive Failure Analysis: 0

Setting File Descriptor kernel parameter solaris

For file descriptor, add this lines to /etc/system # vi /etc/system ---------------- set rlim_fd_max=8192 #(def: 1024, Process open file descriptors limit; should account for the expected load, for the associated sockets, files, pipes if any) set rlim_fd_cur=8192 #(def: 256, Process open file descriptors limit; should account for the expected load, for the associated sockets, files, pipes if any) set sq_max_size=0 #(Controls streams driver queue size; setting to 0 makes it infinity so the performance runs wont be hit by lack of buffer space) set tcp:tcp_conn_hash_size=8192 #(The connection hash table keeps all the information for active TCP connections) set autoup=60 set pcisch:pci_stream_buf_enable=0 ----------------- You should reboot your server to make changes.

Setting TCP kernel parameter solaris

Setting TCP kernel parameter solaris How to know your TCP current kernel parameter # /usr/sbin/ndd -get /dev/tcp tcp_ip_abort_cinterval; 180000 # /usr/sbin/ndd -get /dev/tcp tcp_time_wait_interval; 60000 # /usr/sbin/ndd -get /dev/tcp tcp_conn_req_max_q; 128 # /usr/sbin/ndd -get /dev/tcp tcp_conn_req_max_q0; 1024 # /usr/sbin/ndd -get /dev/tcp tcp_ip_abort_interval; 480000 # /usr/sbin/ndd -get /dev/tcp tcp_keepalive_interval; 7200000 # /usr/sbin/ndd -get /dev/tcp tcp_rexmit_interval_initial; 3000 # /usr/sbin/ndd -get /dev/tcp tcp_rexmit_interval_max; 60000 # /usr/sbin/ndd -get /dev/tcp tcp_rexmit_interval_min; 400 # /usr/sbin/ndd -get /dev/tcp tcp_smallest_anon_port; 32768 # /usr/sbin/ndd -get /dev/tcp tcp_slow_start_initial; 4 # /usr/sbin/ndd -get /dev/tcp tcp_xmit_hiwat; 49152 # /usr/sbin/ndd -get /dev/tcp tcp_recv_hiwat; 49152 # /usr/sbin/ndd -get /dev/tcp tcp_fin_wait_2_flush_interval; 30000 Change your TCP kernel parameter as you want :p /usr/sbin/ndd -set /dev/tcp tcp_ip_abort_cint...

Setting IPMP on Solaris 10 - link based detection

activate ethernet interface # ifconfig ce0 plumb # ifconfig ce1 plumb Giving IP Address and IP Multipathing # ifconfig ce0 10.172.75.2 netmask 255.255.255.0 broadcast group ipmp1 up # ifconfig ce1 group ipmp1 up Now we only have 1 IP address ( 10.172.75.2 ). If this setting keep on when system reboot, check all following conf file. # more /etc/hosts 127.0.0.1 localhost 10.172.75.2 server01 # more /etc/netmasks 10.172.75.0 255.255.255.0 #more /etc/defaultrouter 10.172.75.1 # more /etc/hostname.ce0 server01 netmask + broadcast + group ipmp1 up For active-active configuration : # more /etc/hostname.ce1 group ipmp1 up For active-active configuration : # more /etc/hostname.ce1 group ipmp1 standby up Check network interface status for active-active : # ifconfig -a ce0: flags=1000843 mtu 1500 index 4 inet 10.172.75.2 netmask ffffff00 broadcast 10.172.75.255 groupname ipmp1 ether xx:xx:xx:xx:xx:xx ce1: flags=1000843 mtu 1500 index 5 inet 0.0.0.0 netmask ff000000 broadcast 0.255.2...

Setting IPMP on Solaris 10 - probe based detection

Based on http://docs.sun.com/app/docs/doc/816-4554/emqra?a=view Here the actions : activate ethernet interface # ifconfig ce0 plumb up # ifconfig ce1 plumb up Giving IP Address and IP Multipathing # ifconfig ce0 10.172.75.3 netmask 255.255.255.0 broadcast + group ipmp1 deprecated -failover up \ addif 10.172.75.2 netmask 255.255.255.0 broadcast + failover up # ifconfig ce1 10.172.75.4 netmask 255.255.255.0 broadcast + group ipmp1 deprecated -failover up Now we have 3 IP address, 2 physical ( 10.172.75.3 & 10.172.75.4 ) and 1 virtual ( 10.172.75.2 ). If this setting keep on when system reboot, check all following conf file. # more /etc/hosts 127.0.0.1 localhost 10.172.75.2 server01-vip 10.172.75.3 server01-ce0 10.172.75.4 server01-ce1 # more /etc/netmasks 10.172.75.0 255.255.255.0 #more /etc/defaultrouter 10.172.75.1 # more /etc/hostname.ce0 10.172.75.3 netmask 255.255.255.0 broadcast + group ipmp1 deprecated -failover up \ addif 10.172.75.2 netmask 255.255.255.0 ...

Free memory from SAR and free -m command

Sometimes we confuse about is a system have an inadequate memory after look after "sar" and "free" command or not. Sar description about memory allocation : Total: how much physical memory the machine has Used: amount of used (kernel + user + buffers + cache) memory Free: how much unallocated memory Shared: how much is shared via shm, mmap, shlibs, etc. Buffers: how much is preallocated to unused kernel buffers Cached: how much is preallocated to unsued filesystem buffer cache free –m description about memory allocation : Used: amount of system memory that is actually in use. This is the first line 'used' - (buffers + cache) Free: amount of memory that isn't actually busy. This is the first line 'free' + buffers + cache. For example : # free -m total used free shared buffers cached Mem: 8007 7989 17 0 120 7053 -/+ buffers/cache: 815 7191 Swap: ...

Default SAR command Solaris

SAR (default) command for showing general system reports. sar -u ( it's default, same as if we only run sar without any option) %usr: running UNIX processes ("user time") %sys: processing kernel system calls on behalf of processes ("system time") %wio: sitting around waiting to read/write data (to disks or network devices), as demanded by processes ("waiting for I/O") %idle: just plain doing nothing as there were no processes that demanded the CPU's time ("idle"). if heavy %usr and %sys it may means a poorly written application can consume infinite amounts of CPU resources. If %wio is high, your system is waiting for your I/O subsystems to catch up. You may have a slow disk or array. Check more with iostat.

Solaris Performance Monitoring with netstat

Show routing table, check if any un-needed route. # netstat -nr Show state of all TCP socket, check if any CLOSE_WAIT state, it may indicate unresponsive port. Check also if any FIN_WAIT state tcp/ip parameters have to be tuned because the connections are not being closed and they gets accumulating. # netstat –aP tcp Show state of all interfaces. Check if any collision and error receiving or sending packets. If collisions percentage greater than 5%, it indicate bottleneck network. # netstat -i I hope Oki, Julio, and Dimas helped with this article.

Solaris Performance Monitoring with vmstat

Create vmstat monitor script. # vi /tmp/vmstat_script.sh #!/bin/ksh echo "$(date '+%nDATE : %m-%d-%y%nTIME : %H-%M-%S')" >> /tmp/vmstat_result .log vmstat 5 60 >> /tmp/iostat_result.log Change mode permission of script file so it can be executed. # chmod 755 /tmp/vmstat_script.sh Running script for monitoring memory statistics regarding kernel thread, virtual memory, disk, trap, and CPU activity. # /tmp/vmstat_scrip.sh View memory statistics regarding kernel thread, virtual memory, disk, trap, and CPU activity report. # more /tmp/vmstat_result.log DATE : 06-19-08 TIME : 18-01-48 kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr sd sd -- -- in sy cs us sy id 0 0 0 14279864 15165272 0 2 0 0 0 0 0 0 0 0 0 366 308 858 0 0 100 Show number of CPU WITH # uname -X | grep NumCPU Analyze the report : • A significant CPU bottlen...

Solaris Performance Monitoring with iostat

Create iostat monitor script. # vi /tmp/iostat_script.sh #!/bin/ksh echo "$(date '+%nDATE : %m-%d-%y%nTIME : %H-%M-%S')" >> /tmp/iostat_result .log iostat -xtc 5 60 >> /tmp/iostat_result.log Change mode permission of script file so it can be executed. # chmod 755 /tmp/iostat_script.sh Running script for monitoring terminal and disk I/O activity and CPU utilization. # /tmp/iostat_scrip.sh View terminal and disk I/O activity and CPU utilization report. # more /tmp/iostat_result.log DATE : 06-19-08 TIME : 18-01-48 extended device statistics tty cpu device r/s w/s kr/s kw/s wait actv svc_t %w %b tin tout us sy wt id ssd0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 0 1073 0 0 0 100 ssd1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 nfs1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0 0 Analyze the report : • The significant Disk bottleneck threshold if : 1. time disk ...

Solaris 10 Performance Monitoring with SAR

SAR ( System Activity Reporter ) Modify the perf startup script to initialize the performance counters then run the init script. # vi /etc/init.d/perf if [ -z "$_INIT_RUN_LEVEL" ]; then set -- `/usr/bin/who -r` _INIT_RUN_LEVEL="$7" _INIT_RUN_NPREV="$8" _INIT_PREV_LEVEL="$9" fi if [ $_INIT_RUN_LEVEL -ge 2 -a $_INIT_RUN_LEVEL -le 4 -a \ $_INIT_RUN_NPREV -eq 0 -a \( $_INIT_PREV_LEVEL = 1 -o \ $_INIT_PREV_LEVEL = S \) ]; then /usr/bin/su sys -c "/usr/lib/sa/sadc /var/adm/sa/sa`date +%d`" fi Utilize the crontab command to modify the crontab configuration file for the sys user. # vi /var/spool/cron/crontabs/sys 0,10,20,30,40,50 * * * * /usr/lib/sa/sa1 0 * * * * /usr/lib/sa/sa2 –A Note : - every 10 minutes will collect the performance data in a binary log file - every hour will generate text report from binary report created by first line command View output graph with ksar (http://sourceforge.net/projects/ksar/). Output files that can be view...

Install Oracle Client 10g.2 Solaris Sparc 64

# mkdir -p /app/oraclient # chown -R oracle:oinstall /app/oraclient # chmod -R 775 /app/oraclient Login to Xwindow with user "oracle". $ gunzip 10gr2_client_sol.cpio.gz $ cpio -idm

Re-installing Oracle Database 10g.2 Solaris Sparc 64

# rm -rf /app/* # rm -rf /oradata/* edit appropriate value on this files you can delete both files # vi /var/opt/oracle/oraInst.loc inventory_loc=/app/oracle/oraInventory inst_group=oinstall # vi /var/opt/oracle/oratab *:/app/oracle/product/10.2.0/Db_1:N: # reboot after this just follow step my previous post Thanks to Anam for helping me.

Install Oracle Database 10g.2 Solaris Sparc 64

# /usr/sbin/groupadd oinstall # /usr/sbin/groupadd dba # /usr/sbin/useradd -g oinstall -G dba oracle # passwd -r files oracle # vi /etc/system -------------- set noexec_user_stack=1 set semsys:seminfo_semmni=100 set semsys:seminfo_semmns=1024 set semsys:seminfo_semmsl=256 set semsys:seminfo_semvmx=32767 set shmsys:shminfo_shmmax=4294967295 set shmsys:shminfo_shmmin=1 set shmsys:shminfo_shmmni=100 set shmsys:shminfo_shmseg=10 # reboot # vi /etc/passwd ------------- oracle:x:100:100::/home/oracle:/bin/sh ------------- # mkdir /home/oracle # cp /etc/skel/* /home/oracle # cd /home/oracle # cp local.profile .profile # cp local.login .login # chown -R oracle:bin /home/oracle # mkdir -p /app/oracle # mkdir -p /oradata # chown -R oracle:oinstall /app/oracle # chown -R oracle:oinstall /oradata # chmod -R 775 /app/oracle # chmod -R 755 /oradata # prctl -n project.max-shm-memory -v 6gb -r -i project user.root # prctl -n project.max-sem-ids -v 256 -r -i project user.root # su - oracle $ vi .login ...