Archive for March 17th, 2008

Solaris Init RunLevels

init is a legacy unix and linux application generally responsabily of the process running in the system.

 

###Grand Unified Bootloader ####
1. BIOS ( Ensure hardware health) CPU (s), Memory, Hard Disk(s)
2. GRUB (Present menu to user and defaults to a selection within timer)
3. OS Kernel (Solaris / Linux / Windows / etc )
4. Sched – Pid 0
5. INIT
6. SMF
7. Operational Single / Multi-User System

### INIT in detail ####

init is represented in the process table as PID 1

which init
/usr/sbin/init

INIT’s config file is: /etc/inittab

init table ( reads inmediatly the inittab )

Supported Runlevels: 0 – S

0 – shutdown runlevel
1 – Single User Mode – No networking support is provided
2 – multi-user support without nfs
3 – multi-user support with NFS (Default Runleve)
4 – unused
5 – interactive boot
S – Single User Mode – No networking support is provided

###### /etc/inittab ############################################

id:run_state (0–6):how_to_run_process
(boot,bootwait,initdefault,off,once,powerfail,powerwait, sysinit,wait)
:what process to run

ap::sysinit:/sbin/autopush -f /etc/iu.ap
sp::sysinit:/sbin/soconfig -f /etc/sock2path
smf::sysinit:/lib/svc/bin/svc.startd    >/dev/msglog 2<>/dev/msglog </dev/console
p3:s1234:powerfail:/usr/sbin/shutdown -y -i5 -g0 >/dev/msglog 2<>/dev/msglog

 

 

No Comments

mysql

Hi All,

This is my first blog and I am going to start off with some content which could potentially help others who had gone through some of the common obstacles and blockers of installing MySQL 5.0 on Solaris 10. What motivates me to write this is that it was difficult for me find a comprehensive and workable “one paged” tutorial of doing this. After spending much time on the internet looking for clues and finally making the MySQL installation a success, I’ve decided to glue and share these pieces of information with others as well.


Assumption

  1. Readers are assumed to have at least some basic Unix/Linux administrative skills.
  2. Readers are assumed to have FRESH running copy of Solaris 10 6/06.
  3. Readers are assumed to have NO previously installed MySQL version in the system.
  4. Readers are assumed to have backed up any critical data before the installation.
  5. The MySQL version used for this tutorial is 5.0.24 Community Edition.
  6. Readers are to take full responsibility of any potential software, data, hardware, financial and life damages prior to following this tutorial.

Downloads

Please obtain a copy of MySQL 5.0 from http://dev.mysql.com/downloads/mysql/5.0.html. For the Solaris 10 MySQL packages, please scroll the page down the section of “Solaris (pkgadd package) downloads”. Choose the appropriate processor architecture of the package (either x86 or SPARC). Download the packages (both Standard and Max) and save them in an appropriate directory. I will use “/usr/files” as the directory where the mysql-xxx.pkg.gz files were placed through out the tutorial (Please take note that the xxx is the version number and is to be replaced by the actual text in the file name).

Preparation

Please perform the following as the root user. We have to make sure that any other previously running copies of MySQL are to be uninstalled from the system.

  1. login as “root
  2. To list all the packages, type: pkginfo | grep mysqlat the shell.
  3. If you see any listed packages, you may remove them by typing “pkgrm <pkg_name>” The names of the packages are list at the second column of after executing pkginfo.
  4. Change the directory to the place where you’ve downloaded the mysql-xxx.pkg.gz files. (e.g. “cd /usr/files”). If the files were compressed by gzip and you can see the .gz extension at the end of the files, you may decompress them by typing “gzip –d mysql-xxx.pkg.gz”. Decompress the downloaded mysql-xxx.pkg.gz files.


Installation

Follow these steps to perform the installation (perform as “root”):

  1. Create the mysql group by typing “groupadd mysql”.
  2. Create the mysql user by typing “useradd -g mysql mysql”.
  3. Change the directory where the MySQL packages were placed. “cd /usr/files”.
  4. First install the “Standard” package by typing: “pkgadd -d mysql-standard-xxx.pkg”. Just accept the default install directory (/opt/mysql) when prompted and go through the installation process.
  5. Next, install the “Max” package by typing: “pkgadd –d mysql-max-xxx.pkg”. Just accept the default directory when prompted and go through the installation process.
  6. The MySQL should have been installed in “/opt/mysql/mysql”.
  7. Change the directory to /etc/init.d and edit the “mysql” file with any text editor. Locate the line which states: “datadir=<something>“. Change the line to “datadir=/opt/mysql/mysql/data“. Save the changes.
  8. After the installation, change the path to “/opt” and type this: “chown -R mysql:mysql mysql”. This is to change the ownership of the whole mysql directory.


Initiallizing the Database

  1. Change the operating user from “root” to “mysql” by tying: “su mysql”.
  2. Change the working directory to “/opt/mysql/mysql/scripts” by typing: “cd /opt/mysql/mysql/scripts”.
  3. Execute the mysql_db_install script by typing: “./mysql_install_db –user=mysql –ldata=/opt/mysql/mysql/data”.
  4. Change the working directory to “/opt/mysql/mysql/bin”.

  5. Start the database by typing: “./mysqld_safe –datadir=/opt/mysql/mysql/data –user=mysql &”.
Connecting to MySQL

Try to connect to the MySQL database by typing “mysql” as the root user. You should be able to see the “mysql>” prompt for the successful connection. The only user which could connect to the database now is the root user and it doesn’t require a password. For more information on user account management, please visit http://dev.mysql.com/doc/refman/5.0/en/user-account-management.html.


I hope this will help those who are trying to install the MySQL 5.0 database on the Solaris 10 OS for the first time. These pieces of software are some of the greatest works which were created by some of the most beautiful minds ever existed. Enjoy…

No Comments

PHP

This script will configure a web server instance to run PHP scripts.
usage :
     setupPHP -instancename=<instance name> [-sapi=nsapi|fastcgi]
Examples:
     setupPHP -instancename=https-php
     setupPHP -instancename=https-php -sapi=nsapi
bash-3.00# setupPHP -instancename=https-miservidor.com
bash: setupPHP: command not found
bash-3.00# ./setupPHP -instancename=https-miservidor.com

UPDATED: /sun/webserver7/https-miservidor.com/config/magnus.conf
UPDATED: /sun/webserver7/https-miservidor.com/config/solarisapp-obj.conf
UPDATED: /sun/webserver7/https-miservidor.com/config/miservidor.com-obj.conf
UPDATED: /sun/webserver7/https-miservidor.com/config/mime.types
   
Setup was sucessful.
——————–

The following steps are necessary to make the changes to all the nodes.

(1) Start the admin server

    /sun/webserver7/admin-server/bin/startserv

(2) Connect to the admin server using wadm command

    /sun/webserver7/bin/wadm [--user=admin-user] [--password-file=admin-pswd-file] [--host=admin-host] [--port=admin-port]

(3) Pull the modified config from the node to config store
    using the following command in wadm console:

    pull-config –config=miservidor.com nodehost
   
    For Example: If the host name for the node is xyz.com then enter the command like,
   
    pull-config –config=miservidor.com xyz.com

(4) Deploy the new changes to all nodes using
    the following command in wadm console:

    deploy-config miservidor.com

 

 

No Comments

Directorio de Instalación

 

/sun/webserver7

admin

https://miservidor:8989

No Comments

Solaris SSHD

svcadm enable ssh

No Comments

Configuring networking

 

Keith Parkansky
http://www.execpc.com/~keithp

Last revised: May 1, 2002

Networking information in Solaris is stored in text files. Configuration is done by filling in the appriopriate data to these files and invoking specific commands in a terminal window.

  1. Pop up the menu above the “Text Note” icon and click on Text Editor. Use the editor to open the file:
      /boot/solaris/devicedb/master
    

    and use the Find feature (under Edit on the menu bar) to locate the model number of your NIC – example: 3C905 (3Com) or 9432 (SMC). Note that the Find feature is case sensitive in the CDE text editor.

  2. If your NIC is in the HCL it will be in the master file. The line for the SMC 9432 I’m using in my system looks like this:
      pci10b8,a011 pci10b8,a011 net pci spwr.bef
    

    I have the “spwr.bef” bolded because this is the driver name and you’ll need to know the driver name for other files. Remember it.

    I’ll save you some work if you have a 3Com 3C905 NIC. The line will be:

      pci10b7,9200 pci10b7,9200 net pci elxl.bef
    
  3. Use the editor to open the file:
      /etc/driver_aliases
    

    (Opening this file will automatically close the master file.) If your NIC is supported it will be listed here also. The line for my SMC NIC was:

      spwr "pci10b8,a011"
    

    which you can see is the same information found in the master file just rearranged a bit.

  4. If you know what is the actual device driver name for your NIC you can verify if the device was properly detected and the driver loaded by looking in /dev directory and searching for files which names begin with the driver name, eg. /dev/spwr0 or /dev/elxl0 for devices used in our example. The number after the driver name in the file name is the consecutive number of the NIC in your system (numbered 0, 1, 2, etc.) using the same driver.
  5. Use the editor to open the file:
      /etc/hosts
    

    and enter a new line in it with the IP address you want to give the system on your network and its’ hostname. I called my machine “solarisi” so I entered:

      192.168.10.20     solarisi solarisi.bigsunfan.com     loghost
    

    Make sure you press Enter after typing this in to create a new (blank) line beneath it!

    With your changes, the resulting the file should look like this:

      127.0.0.1          localhost
      192.168.10.20      solarisi solarisi.bigsunfan.com     loghost
    

    Note that the bigsunfan.com domain need not to be a registered domain. I simply use it as an example.

    Don’t forget to save the file. Click on File on menu and select Save.

    A note about Sendmail and the hosts file.

    Sendmail is a mail server, or more professionally, a Mail Transport Agent, MTA in short. It is installed by deafult and started automatically when you boot your system. Sendmail is picky when it comes to FQDNs (Full Qualified Domain Names). When you booted your system you may have seen the infamous Sendmail error:

      sendmail[nnn]: My unqualified host name (solarisi) unknown;
      sleeping for retry
    

    If you are not going to run a mail server, simply turn Sendmail off by renaming its startup file:

    mv /etc/rc2.d/S88sendmail /etc/rc2.d/noS88sendmail

    Otherwise, you need to specify FQDN of your host in /etc/hosts file. For more details see Configuring Sendmail tutorial.

  6. Check if the file
      /etc/hostname.driver_nameNIC_number
    

    exists. Use the ACTUAL WORD “hostname” in the name of the file, NOT the hostname you gave your system. The driver_name is the name I said you should remember above, and the NIC_number is the number of the NIC in your system. Since I only have one NIC in my system, my file was named:

      /etc/hostname.spwr0
    

    The file should contain your host name, the same as in /etc/hosts file. If there is no such file, or it contains improper value you need to correct it.

    You could also enter the IP address instead of the host name which is needed if you want to assign multiple IP addresses to a single interface, such as with hosting multiple Web sites on a single server (Apache’s virtual hosting), create multiple files using the above naming convention but append a :1 and :2 etc. to the file name for each additional file. Each file should have a single, different IP address. For example:

    /etc/hostname.spwr0       contains 192.168.10.20
    /etc/hostname.spwr0:1 contains 192.168.10.21
    /etc/hostname.spwr0:2 contains 192.168.10.22
  7. Now you set up an appropriate subnet mask. Open the file
      /etc/netmasks
    

    and the top of the file has comments that explain the contents. You basically just enter your “network number” (NOT your system’s IP address) followed by the subnet mask for your network. Given that the address I gave my system above (192.168.10.20) is a Class C IP address, my netmasks file looked like this:

      192.168.10.0        255.255.255.0
    

    The following table may help you determine what your network number and subnet mask should be based on the first number of your system’s IP address:

    IP Number Class Network Address Range Subnet Mask Private Address Range
    A 1.0.0.0 to 126.0.0.0 255.0.0.0 10.x.x.x
    B 128.0.0.0 to 191.255.0.0 255.255.0.0 172.16.x.x to 172.31.x.x
    C 192.0.0.0 to 223.255.255.0 255.255.255.0 192.168.0.x to 192.168.255.x

    If you’re setting up a small network in your home or office and you’re not sure what IP address to use, use any address given in the “Private Address Range” above for a Class C network. This will allow you to have up to 254 nodes (aka “hosts” in TCP/IP lingo) on your network.

    Once you’ve got the appropriate network and mask addresses entered, save the file.

  8. The /etc/hosts file mentioned above is used to resolve machine names to IP addresses on your local network. If you are connecting your system to a network that is connected to the Internet and you plan to use it to surf the Web, or have another need to resolve Internet domain names, you’ll need to specify your ISP’s DNS servers. This is done using another file called
      /etc/resolv.conf
    

    Note:  When you save the following newly created files the /etc directory should already be selected as the target for the saved file. That’s why no path is specified for file saves. However, verify that //etc/ is in the “path or folder name” field when saving these files.

    Create the new file using the text editor by clicking on File and then on New and enter the following lines:

      domain enter-your-ISP's-domain
      nameserver enter-IP-address-of-primary-DNS-server
      nameserver enter-IP-address-of-secondary-DNS-server
    

    Be sure to hit Enter at the end of the last line and then save the file with the name resolv.conf

    The above file is used if your system is not part of a domain. If it is, ex: you are going to use your system as an Internet server, you have to list your domain name on the domain line and list your ISP’s domain (for DNS) using the search keyword. For example:

      domain your-domain.com
      nameserver 172.31.214.78
      nameserver 10.138.14.2
      search your-ISPs-domain.com
    
  9. If your system is on a network that has a default gateway, you’ll need to create
      /etc/defaultrouter
    

    file for tha. If your system is going to be an Internet server the default gateway is likely the address of the router interface that connects you to your ISP.

    Create a new file using the text editor (click on File and then on New) and simply enter one IP address. This IP address however will be for your default gateway. Be sure to hit Enter at the end of the address and then save the file as /etc/defaultrouter

  10. Unfortunately, simply creating the resolv.conf file earlier doesn’t mean your system will automatically start to use it. Again, this file is only necessary if you will use your system to access the Internet or other large network where DNS servers are used to resolve system names. This includes simply using your system as a workstation to surf the Web. It doesn’t have to be a server.

    Yet another file called nsswitch.conf is used to “tell” your system which name resolution methods to use (host files, DNS, etc) and in which order to use them. Fortunately, the Solaris installation includes several different pre-written versions of the nsswitch file. The default file only uses the host file to resolve machine names.

    In order for your system to use DNS servers, you’ll have to issue the following command at the # prompt in a “This Host” window:

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

    Note:  At this stage all files related to network configuration are filled in, but the notworking on your system is not yet working properly. You can either reboot your system by typing in init 6 to make Solaris to reread configuration files and setup networking accordingly, or alternatively perform the following steps.

  11. Plumb the network interface with the following command

    ifconfig spwr0 plumb

  12. Make the interafce up by typing in

    ifconfig spwr0 192.168.10.20 netmask 255.255.255.0 up

    The IP part 192.168.10.20 of the above command is the IP assigned to the interface, in other words the IP of your host, and the netmask part 255.255.255.0 is the netmask specified in /etc/netmasks file.

    You should now be able to communicate with systems on your local network. You can verify this with ping command.

  13. Add the default route to routing table as follows

    route add default 192.168.10.1

    where 192.168.10.1 is the IP of the gateway on your network. This should be the IP specified in /etc/defaultrouter file discussed above.

You should now be able to communicate with all systems on the Internet. Verify this with ping command, or simply fire up a web browser.

Related man pages:

  • hosts,
  • resolv.conf,
  • nsswitch.conf,
  • netmasks,
  • defaultrouter,
  • ifconfig
  • route
  • ping.

No Comments