Thursday, August 21, 2008

Adding swap file to linux

there are three steps to add a new swap file to a linux box.
1- you have to create the swap file
dd if=/dev/zero of=swapfile bs=1024 count=1536000
2- run this command to identify the file as a swap file
mkswap /swapfile/swapfile
3- and activate it:
swapon /swapfile/swapfile

Tuesday, August 12, 2008

Property 'name' of instance .. missing errors

if you have system errors on Solaris like "Property 'name' of instance svc:/network/ftp:default is missing, inconsistent or invalid" or "Invalid configuration for instance svc:/network/finger:default, placing in maintenance" after creating a zone, you should control the /etc/services file.

You can copy this file from a working system and reboot your server. After this operation, your system will be fine.

Tuesday, June 3, 2008

Creating secure ftp account on Solaris

i told about ftpaccess file and setting a secure ftp account on solaris before. but i noticed that with that configuration i couldn't use "ls -l" (detailed list) because of security.

i found the solution, there is a command named "ftpconfig" on solaris. here is the usage:
# ftpconfig ftp_user_path

For example:

root@Uranus # ftpconfig /export/ftp2/
Updating user ftp
Updating directory /export/ftp2/

that's all..

Wednesday, May 28, 2008

Sun xVM Virtual Box

(from sun's site:)
This week Sun formally launches xVM VirtualBox, new open source virtualization software for personal computers that lets developers easily work on cross-platform applications and virtualized server environments, from any platform they choose. Power users who require multiple platforms to do their work will also benefit from xVM VirtualBox.

How is xVM VirtualBox Different?

The biggest difference between xVM and its competitors is that it is a free and open source product that requires no registration or license keys and downloads and installs quickly. In addition, xVM VirtualBox can be run on a larger number of host operating systems, including Microsoft Windows, Linux, Sun Solaris, and Apple Macintosh, than any other virtual desktop product.

http://www.sun.com/featured-articles/2008-0527/feature/index.jsp?intcmp=hp2008may27_xvm_read

Friday, May 23, 2008

how to move a zone on solaris

If you want to move a zone to another disk or partition, you can use the "move" option of zoneadm command.

first, you have to halt the zone.

# zoneadm -z zonename halt

now you can move it;

# zoneadm -z zonename move /new/partition/directory


http://docs.sun.com/app/docs/doc/819-2450/gcgnc?a=view

Friday, April 18, 2008

Creating a zone on Solaris 10

here are the basic steps to create a zone on solaris 10.

root@Uranus # zonecfg -z test1
test1: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:test1> create
zonecfg:test1> set zonepath=/space/zone/test1
zonecfg:test1> add net
zonecfg:test1:net> set physical=bge1
zonecfg:test1:net> set address=192.168.0.237
zonecfg:test1:net> end
zonecfg:test1> verify
zonecfg:test1> commit
zonecfg:test1> exit

root@Uranus # zoneadm -z test1 install

root@Uranus # zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- test1 installed /space/zone/test1 native shared

root@Uranus # zoneadm -z test1 boot

root@Uranus # zlogin -C test1

Monday, March 31, 2008

Making Solaris ftp more secure

if you create an ftp user on a solaris system, the user can change directory to anywhere and read the list of objects in it with default configurations.

if you want to make ftp more secure you can use ftpaccess file in /etc/ftpd/ directory.

here are the steps:

- create a group for ftp
shell > groupadd ftpuser

- create a user for ftp
shell > useradd -g ftpuser -d /path/to/ftphome -s /bin/true ftpusername
note: there should be an entry in /etc/shells like "/bin/true", if not you cannot login to ftp server.

- edit /etc/ftpd/fptaccess file and add a line
guestgroup ftpuser

- then restart the ftp server
shell> svcadm restart svc:/network/ftp:default

Thursday, March 27, 2008

Are your tablespaces shrinkable? (oracle)

here is a sql script by Tom Kyte.
if you have problems with sizes of tablespaces you can shrink datafiles. but if there is data at the end of the datafile you cannot shrink them.
with this sql script you can see if you can shrink them.
after running script you should copy the shrink commands and run them..

set verify offcolumn file_name format a50 word_wrappedcolumn smallest format 999,990 heading "SmallestSizePoss."column currsize format 999,990 heading "CurrentSize"column savings format 999,990 heading "Poss.Savings"break on reportcompute sum of savings on report
column value new_val blksizeselect value from v$parameter where name = 'db_block_size'/
select file_name, ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) smallest, ceil( blocks*&&blksize/1024/1024) currsize, ceil( blocks*&&blksize/1024/1024) - ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) savingsfrom dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) bwhere a.file_id = b.file_id(+)/
column cmd format a75 word_wrapped
select 'alter database datafile '''file_name''' resize ' ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) 'm;' cmdfrom dba_data_files a, ( select file_id, max(block_id+blocks-1) hwm from dba_extents group by file_id ) bwhere a.file_id = b.file_id(+) and ceil( blocks*&&blksize/1024/1024) - ceil( (nvl(hwm,1)*&&blksize)/1024/1024 ) > 0/


http://www.oracle.com/technology/oramag/oracle/04-sep/o54asktom.html

how to take tab delimited export with mysql

you can use mysqldump to take a dump of a table or a database.
when you use the command without a parameter dump is taken with insert statements.

if you want to have a tab delimeted export file you should use --tab paramter with mysqldump.

shell > mysqldump --tab=/path_to_dump_files database table

after this command table.sql and table.txt files will be created. sql for table structure and txt file for data.

Tuesday, March 18, 2008

Using ufsdump for directory backup

you can take incremental backups with ufsdump. here is the usage:

ufsdump 0ucf /pathto/backup/backup_1 /device

what about taking backup of a directory? Of course you can use tar, cpio or cp commands to take backup of a directory. But it might be useful to use ufsrestore command for restoring any corrupted data.

But there is a point, you cannot take incremental backup of directories with ufs dump. this feature is only for devices. so you have to take always zero level backup when you backup a directory.

ufsdump, updates the /etc/dumpdates file to control the backup levels. but it doesn't matter to update this file manual for a directory.

Wednesday, March 5, 2008

Maximum number of files under a directory (Solaris)

- Is there a limit to the number of files under a directory on Solaris OS?
- In fact, there is no such limit. But it is not a good situation if there are thousands of files under a directory. Because, operations like finding, opening, creating and deleting a file are affected as the number of files goes into tens of thousands.
(http://www.sun.com/bigadmin/xperts/sessions/20_jes/#8)

Thursday, February 21, 2008

Learning the Cluster (installation) Type of an Solaris

Solaris OS has various cluster types for installation.
here is the list:

SUNWCrnet Reduced Networking Core System Support
SUNWCreq Core System Support
SUNWCuser End User System Support
SUNWCprog Developer System Support
SUNWCall Entire Distribution
SUNWCXall Entire Distribution plus OEM support

if you want to learn the cluster type of an installed system, you can run this command:

# cat /var/sadm/system/admin/CLUSTER
CLUSTER=SUNWCXall

Wednesday, February 20, 2008

Oracle Client for Linux (rpm)

if you want to connect to a remote oracle database from a linux machine (with net naming services, tnsnames.ora file) you should have oracle client software. you can download this software from oracle official site.
size of the softwares for client and server are so huge. Maybe it is normal for server software but not for client.
But you have an another choice, you can install only 2 rpm files and use sqlplus and oracle client libraries.
total size of these files is 34mb, download url is: http://www.oracle.com/technology/software/products/database/xe/htdocs/102xelinsoft.html

installation:
it is too basic.
rpm -iv oracle-instantclient-basic-10.2.0.3-1.i386.rpm
rpm -iv oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm

after installation you have to set LD_LIBRARY_PATH and add /usr/lib/oracle/10.2.0.3/client/lib. (to see the path of client files:
[root@oracle]# rpm -qlv oracle-instantclient-basic
-rwxr-xr-x 1 root root 39612 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/bin/genezi
-rw-r--r-- 1 root root 18825267 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libclntsh.so.10.1
-rw-r--r-- 1 root root 5486009 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libnnz10.so
-rw-r--r-- 1 root root 1398088 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libocci.so.10.1
-rw-r--r-- 1 root root 72480394 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libociei.so
-rw-r--r-- 1 root root 120135 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/libocijdbc10.so
-rw-r--r-- 1 root root 1545954 Nov 15 2006 /usr/lib/oracle/10.2.0.3/client/lib/ojdbc14.jar
)

so, where is tnsnames.ora file?
you can put this file anywhere. it is enough to set TNS_ADMIN shell variable to the directory of tnsnames.ora file.

now you can use sqlplus to connect remote oracle database.

Router Configuration for Solaris

if you want to make router configuration permanent for a solaris machine, you should put the ip or hostname of your router to /etc/defaultrouter file. (ipv4)

Tuesday, February 19, 2008

how to see the storage engine of a mysql table

you can use the
mysql> show create table TABLE_NAME
command to see the engine of a table.
the response should be like that:

Create Table: CREATE TABLE t (
id INT(11) default NULL auto_increment,
s char(60) default NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM

Friday, February 15, 2008

Setting kernel and project parameters for Oracle on Solaris 10

Before installing Oracle on Solaris, you have to do some preparatory works for a correct installation. For example creating groups and user. (groups: oinstall, (dba-optional); user: oracle)
there is an another important requirement. Kernel parameters..
Before Solaris 10, you have to edit the /etc/system file to change kernel parameters. But with Solaris 10, we use projects to define required parameters.
first of all, control the project information for the user you loged in (for installation it should be oracle)

# id -p
uid=101(oracle) gid=101(oinstall) projid=3(default)

it is clear that proejct id for oracle is 3. now we can control the kernel parameters.

for the parameter max-shm-memory :
# prctl -n project.max-shm-memory -i project 3

for the parameter max-sem-ids
# prctl -n project.max-sem-ids -i project 3

if the values are not enough for oracle (compare them with the requirements given in Oracle Documentation) you have to change them. If you don't change these values, you can get "Out Of Memory" error while installing Oracle.

you can change them with these commands:


# prctl -n project.max-shm-memory -v 6gb -r -i project 3
# prctl -n project.max-sem-ids -v 256 -r -i project 3


there is a last point, to make these values permanent, you have to run these commands:
# projmod -K "project.max-sem-ids=(priv,256,deny)" default
# projmod -s -K "project.max-shm-memory=(priv,6000MB,deny)" default

now your /etc/project file is changed.

Thursday, February 14, 2008

Solaris Patch Installation Status Codes

if you are installing a Solaris patch, these status code may be useful for you

Solaris Patch Installation Status Codes
0. No error
1. Usage error
2. Attempt to apply a patch that's already been applied
3. Effective UID is not root
4. Attempt to save original files failed
5. pkgadd failed
6. Patch is obsoleted
7. Invalid package directory
8. Attempting to patch a package that is not installed
9. Cannot access /usr/sbin/pkgadd (client problem)
10. Package validation errors
11. Error adding patch to root template
12. Patch script terminated due to signal
13. Symbolic link included in patch
14. NOT USED
15. The prepatch script had a return code other than 0.
16. The postpatch script had a return code other than 0.
17. Mismatch of the -d option between a previous patch install and the current one.
18. Not enough space in the file systems that are targets of the patch.
19. $SOFTINFO/INST_RELEASE file not found
20. A direct instance patch was required but not found
21. The required patches have not been installed on the manager
22. A progressive instance patch was required but not found
23. A restricted patch is already applied to the package
24. An incompatible patch is applied
25. A required patch is not applied
26. The user specified backout data can't be found
27. The relative directory supplied can't be found
28. A pkginfo file is corrupt or missing
29. Bad patch ID format
30. Dryrun failure(s)
31. Path given for -C option is invalid
32. Must be running Solaris 2.6 or greater
33. Bad formatted patch file or patch file not found
34. Incorrect patch spool directory
35. Later revision already installed

uninitialized state for any service on solaris 10

if there is a problem about a service on solaris 10 (i.e telnet), you can control the status of this service with command
# svcs grep telnet

you should see "online" as output if there is no problem. if the status in the output is offline, you can take it online with this command:
# svcadm enable svc:/network/telnet:default

if the status is "uninitialized", you should control the output of
# svcs -vx
command. with this information you can find the problem (maybe a dependancy)

i met with this problem and saw that some of the services look for /etc/resolv.conf (telnet, ftp). i created the file, then the statuses became online.