Solaris
Last edited May 11, 2009
More by {joey} »
How To Check Disk Usage In Solaris | ShareTab Tech Point
sharetab.com/tag/how-to-check-disk-usage-in-solari...

To view disk free status:
# df (disk free): It displays disk free in terms of blocks.
# df -k : It displays disk free status in kilobytes.
# df -h : It displays disk free status in human readable form.
# df -h : It display disk free status of specific slice.


To view disk usage status:

# du (Disk usage): It displays disk usage in blocks
# du /etc : Example of usage for the command.
# du -h : To view the same information in human readable form.

To view the quote of file system: This command displays the file system ownership.

# quot /export/home : to summarize a particular file system.
# quot -a : it summarize all file systems.
Example for quot command is:

root@testmy # quot -a
/dev/rdsk/c1t0d0s0 (/):
6540613 root
5041 adm
854 uucp
396 #192418
162 appls
111 infra
54 noaccess
30 check
14 lp
11 bin
6 daemon
4 nobody
4 smmsp
2 gdm
2 webservd

Configuring JBoss to Use With Service Management Facility (SMF)

William Pool (Puddle), June 2005

The Solaris 10 OS uses the Service Management Facility (SMF) to handle services. Traditional means like /etc/rc?.d scripts still work, but as a legacy means. (For more information on SMF, see the References section.)

To take advantage of the SMF in the Solaris 10 OS using JBoss, do the following.

Note: Read the scripts and "change" the paths of jboss and your version of jboss accordingly! This does work for JBoss 3.x.x branches too!

Create a service manifest file:

/var/svc/manifest/network/jboss4.xml

This contains the following:

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM
'/usr/share/lib/xml/dtd/service_bundle.dtd.1'>

<!--
William Pool (Puddle) 01/05
Service manifest for JBoss
E-mail: puddle@flipmotion.com
-->

<service_bundle type='manifest' name='JBoss4:jboss'>

<service
name='network/jboss'
type='service'
version='1'>
<create_default_instance enabled='false' />
<single_instance />

<dependency name='fs'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri
value='svc:/system/filesystem/local' />
</dependency>

<!-- DATABASE NOTES
UnComment this block if you use MySQL/PostgreSQL. This will make sure
that MySQL/PostgreSQL is started before you start JBoss. This is an
example for MySQL. Please create an SMF service for MySQL / PostgreSQL.

<dependency name='mysql'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri
value='svc:/network/mysql' />
</dependency>

-->

<dependency name='net'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/network/loopback' />
</dependency>

<dependent
name='ssh_multi-user-server'
grouping='optional_all'
restart_on='none'>
<service_fmri
value='svc:/milestone/multi-user-server' />
</dependent>

<exec_method
type='method'
name='start'
exec='/lib/svc/method/svc-jboss4 start'
timeout_seconds='-1'>
<method_context>
<method_credential user='jboss' group='jboss' />
</method_context>
</exec_method>

<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='-1'>
</exec_method>

<exec_method
type='method'
name='restart'
exec='/lib/svc/method/svc-jboss4 restart'
timeout_seconds='-1'>
</exec_method>

<stability value='Unstable' />

<template>
<common_name>
<loctext xml:lang='C'>
JBoss
</loctext>
</common_name>
<documentation>
<manpage title='jboss' section='1M'
manpath='/usr/share/man' />
</documentation>
</template>
</service>
</service_bundle>

Now create your "Service Method File" in /lib/svc/method called svc-jboss4:

#!/usr/bin/sh
# William Pool (Puddle) 01/05
# SMF Method file for JBoss
# E-mail: puddle@flipmotion.com
#
# NOTE: If you start JBoss with su -c 'cmds' instead
# You "will" be able to start and stop it via root using the method file
# itself. However, it "does" confuse SMF. It's best to have the straight
# commands and let the actual SMF service do the user rights and permissions
# of execution. You've been WARNED! Use su -c 'cmds' at your own risk!
#

. /lib/svc/share/smf_include.sh

case $1 in
'start')
echo "starting jboss.."
/opt/software/jboss-4.0.1/bin/run.sh & >/dev/null 2> /dev/null
;;

'stop')
echo "stopping jboss.."
/opt/software/jboss-4.0.1/bin/shutdown.sh -S &
pkill java
;;

'restart')
stop
# give stuff some time to stop before we restart
sleep 35
# protect against any services that can't stop before we restart (warning
this kills all Java instances running as 'jboss' user)
pkill java
start
;;
*)
echo "Usage: $0 { start | stop | restart }"
exit 1
;;
esac

#---EOF

Now fix the permissions for the two files created:

chown root:bin /lib/svc/method/svc-jboss4
chmod 555 /lib/svc/method/svc-jboss4
chown root:sys /var/svc/manifest/network/jboss4.xml
chmod 444 /var/svc/manifest/network/jboss4.xml

Import the service into the service repository:

# svccfg import /var/svc/manifest/network/jboss4.xml

Enable the service:

# svcadm -v enable jboss
 
Root

1)
Edit the /etc/passwd file and change the entry for the root user thus : 

root:x:0:1:Super-User:/root:/sbin/sh

Be very diligent about creating the root users home directory right away and ensure that it is only readable by the root user :

# mkdir /root # chmod 700 /root # chown root:root /root


2) If using CSW or Coolstack:

Next item is the default PATH for the root user and regular users. You can set this in the files /etc/default/login and /etc/default/su. Please feel free to be pedantic and set PATH and SUPATH in both of those files to something useful thus : 

PATH=/opt/csw/bin:/usr/sbin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ccs/bin

Really you can leave /opt/csw/bin out of there entirely if you want. The software from Blastwave is isolated in /opt/csw and will not interfere with your other software. You can use GNOME from somewhere else if you want. Your users can have there own .profile files that determine that they run JDS if they want.


Labels: configuration

-d home-directory-path
This is the new user's home directory, typically /export/home/username

-m
make home directory and copy the default skeleton files (these files are located in /etc/skel directory).

-u uid
The uid (userid) is a number from 0 to 65535 which identifies the user on the system. uid 0 is reserved for root. If you don't specify one, the next available uid will be used automatically.

-c "User Name"
Comment field which usually contains the name of the user. Make sure you enclose the name in quotes if it contains a space.

-s /path/to/shell
The shell to use. If you don't specify this, it will default to /bin/sh. Make sure you specify the fully qualified path.

So, putting it together, a typical addition of a user named fred would be:

groupadd user

useradd -d /export/home/fred -m -g user -s /bin/bash -c "Fred Smith" fred

cp /etc/nsswitch.dns /etc/nsswitch.conf

/etc/resolv.conf    -> /etc/inet/resolv.conf


domain mtn.co.za
search mtn.co.za
nameserver 209.212.96.1
nameserver 10.204.28.5
nameserver 209.212.97.1
nameserver 10.211.58.8

svcs -a |grep dns

svcadm enable svc:/network/dns/client:default


Other

/usr/sadm/bin/smc
prodreg
Use the following command to enable the service :
# svcadm enable svc:/network/http:tomcat6-csk
JAVA_HOME is set to /usr/java
Environment variables e.g JAVA_HOME, JAVA_OPTS for tomcat6-csk  service can be s
et using following commands :
# svccfg  -s svc:/network/http:tomcat6-csk setenv -m start JAVA_OPTS <java_optio
ns>
# svccfg  -s svc:/network/http:tomcat6-csk setenv -m stop JAVA_OPTS <java_option
s>

svcadm enable tomcat6-csk
svcadm enable apache22-csk



Here are the steps:

1. Install the Solaris 10 OS, Solaris Express/Nevada, or OpenSolaris.

2. Make sure your system is networked so that it can reach the Internet and is using a static IP address. If you need assistance with network configuration, review this documentation: System Administration Guide: IP Services.

3. We wish to install MySQL 5 from Blastwave.org. Open a web browser, go to Blastwave.org's step-by-step guide, and perform steps 1 through 7. It's that simple, and you are now ready to use the pkg-get command to install packages such as MySQL 5 over the network.

4. We are now ready to install MySQL 5 packages. From a console or xterm window, log in as root and issue these commands:

# /opt/csw/bin/pkg-get -i mysql5 mysql5client mysql5devel mysql5rt
# /opt/csw/bin/pkg-get -i mysql5test

Note: It is very important to install the mysql5devel package, or else you will have trouble building PHP 5 later.

5. Now let's set up MySQL 5.

Blastwave.org has a guide: Go to http://www.blastwave.org/packages.php/mysql5 and click the grey button that says "View news and info about the software package". We have repeated the guidelines here, and also expanded upon some of the discussion. (Thanks to Blastwave for their generosity in sharing their work with us.)

A. Create the config file /opt/csw/mysql5/my.cnf, as follows: Copy one of the my-*.cnf files in /opt/csw/mysql5/share/mysql/ to /opt/csw/mysql5/my.cnf and make any changes appropriate for your environment, such as enabling InnoDB. Note that /opt/csw/mysql5/var is a deprecated location for my.cnf. If you are not sure which file to copy, use my-small.cnf.

B. It is important to set up a MySQL user and group before initializing the database in the next step. This is done for you by the Blastwave package install script. However, if you are building MySQL from source, you will need to create a MySQL user and group as follows:

# groupadd mysql
# useradd -c "MySQL Server" -d /dev/null -g mysql -s /bin/false mysql 

C. Initialize the MySQL database and fix the permissions:

cd /opt/csw/mysql5
./bin/mysql_install_db
chown -R mysql:mysql ./var

Caution: If you skip the chown step above, MySQL will refuse to start.

D. Start MySQL 5. To simply attempt to start the server and see if the above steps were done correctly, you can issue this command:

# cd /opt/csw/mysql5 ; /opt/csw/mysql5/bin/mysqld_safe &

You can then check with the ps command to see if it started, and use the kill command and the PID to stop it.

Caution: Make sure you kill the previously-mentioned process before proceeding, or else MySQL will not start properly when you enable the SMF server in the next steps.

This command should work:

# pkill mysql

Now, to ensure it will start after a reboot, read on.

Note: Recent builds of Solaris Express, Nevada, and Solaris 10 updates are using SMF to start daemons such as mysql. The process below may vary. If your version of Solaris uses SMF, you will use the svcadm commands shown below to start/stop MySQL 5.

Old RC File Method:

 # /etc/init.d/cswmysql5 start

New SMF Method:

If you installed the MySQL 5 package on a version of Solaris that is using SMF instead of RC files, you will find that the package installed an SMF manifest for MySQL 5, and you can see the state of the service by using this command:

 # svcs -a | grep mysql
 disabled 13:36:01 svc:/network/cswmysql5:default
To make sure the MySQL 5 server starts (and also at reboot), issue this command:

# svcadm enable svc:/network/cswmysql5:default

You can verify using this command again:

# svcs -a | grep mysql
online 15:12:43 svc:/network/cswmysql5:default

You can stop the server with command # svcadm disable svc:/network/cswmysql5:default and it will remain stopped, even across a reboot, until you issue the svcadm enable command.

E. Please remember to set a password for the MySQL root user!

This should not be the same as your Solaris root user password! To do so, start the server, then issue the following commands:

To set the local password:

# /opt/csw/mysql5/bin/mysqladmin -u root password 'new-password'
	
# /opt/csw/mysql5/bin/mysqladmin -u root -h <YOUR-HostName-Here> \
password 'new-password'

(The previous command line will fail, and is not needed, if you have disabled network access via the security discussion in Step 5, part I below.)

See the MySQL 5 documentation for more instructions.

F. Optional: This takes some time. You can run test suites for the MySQL daemon with the following commands:

# cd /opt/csw/mysql5/mysql-test
# ./mysql-test-run

G. Check the install:

# ./bin/mysql -p

You will be prompted to enter MySQL root's password. You should see a mysql prompt. Try a command such as STATUS to see if the server responds. Next, try to run a test query from the mysql prompt:

show databases;

The mysql and test database is returned.

quit

Note: Startup options may be overridden by creating and editing either /opt/csw/mysql5/etc/mysql5rc or /etc/opt/csw/mysql5rc.

The template for mysql5rc is in /opt/csw/mysql5/share/mysql. You must use this template if making an rc file for your system. For example:

  1. # mkdir -p /etc/opt/csw
    I use these permissions: chown root:bin /etc/opt/csw and chmod 0755 /etc/opt/csw.
  2. # cp /opt/csw/mysql5/share/mysql/mysql5rc /etc/opt/csw/
    If no mysql5rc file is available, the daemon starts with defaults. If this is your first experimental system, don't bother with this step; it is optional.

H. Reference docs:

I. MySQL security is beyond the scope of this article. However, here are some basic steps to consider:

  • Make sure the MySQL root user has a password set, and that it is different than the host system root password.
  • Ensure that only the MySQL user has read and write access to the database directory.
  • If using MySQL on a web server for PHP (so only localhost connections are needed between PHP/Apache and MySQL), add the line skip-networking to the [mysqld] section of your /opt/csw/mysql5/my.cnf configuration file. This will disable all TCP/IP remote connections to the MySQL server daemon.
  • Disable the use of the LOAD DATA LOCAL INFILE command, which could permit unauthorized reading from local files, especially when new SQL injection attacks occur. In the [mysqld] section of your my.cnf file, add set-variable=local-infile=0.
  • Get rid of anonymous user accounts in the users table.

The preceding steps only scratch the surface, but make for good improvement after installation. Please do review articles about MySQL security on the web by entering "Securing MySQL" into your favorite Internet search engine.

6. We are now done with installing and testing MySQL 5. Next, let's build PHP 5. We'll borrow portions from Mel Lester's web site, with his kind permission. We will modify some of the PHP configuration since we are using different options and paths.

Specifically, we will change the configuration of PHP 5 before compiling to use the path to our Blastwave MySQL 5 in /opt/csw/mysql5, and also add some other options. The procedure will also verify that you have the needed GNU tools installed to build PHP 5.

A. Log into the global zone as root and ensure that /opt/csw/bin and /usr/sfw/bin are in $PATH, as follows:

global# echo $PATH
  /opt/csw/bin:/usr/sfw/bin:/usr/sbin:/usr/bin:/usr/openwin/bin: \
  /usr/dt/bin:/usr/ccs/bin 
OK, let's talk. First, you may not want to modify the .profile for root and clutter up the / directory with junk. I'd suggest, for the Solaris 10 OS, Solaris Express, or OpenSolaris, that you create the directory /root, and make another root account in /etc/password that uses the bash orksh shell, and points to /root as a home directory. However, that is a choice and topic for you and Google. Whatever you decide, please ensure that your path has the components above. Then proceed. 
 
The content on this page is provided by a Google Notebook user, and Google assumes no responsibility for this content.