在opensolaris下设置DNS和DHCP

首先以DHCP获得IP
ifconfig pcn0 dhcp start

启动完成后,检查默认网关是否正确获得:

netstat -nr

如果没有正确获得,/etc/defaultrouter文件中应该有东西,有的话,将之删除
cat /etc/defaultrouter

然后重新运行:ifconfig pcn0 dhcp start

在DHCPserver中是可以设置DNS server的,如果不能设置,自己要手动设置;

再次启动完成后检查DNS是否正确配置,如果没有的话,手动改:
cat /etc/resolv.conf

DNS设置完成后,还有修改nsswitch.conf文件,让hosts,ipnodes的别名通过DNS来取得,

检查对应的是否是dns,如果不是的话,将它改成dns
cat /etc/nsswitch.conf | grep hosts
hosts: dns
cat /etc/nsswitch.conf | grep ipnodes
ipnodes: dns

refs:

http://blogs.sun.com/observatory/entry/beyond_dhcp_with_dns_and

如何写扩张mib

0.环境:
OS:opensolaris 2009.06版
gcc:3.4.3 (csl-sol210-3_4-20050802)
snmp:NET-SNMP version: 5.0.9

1.环境准备
确认snmp和gcc的相关包是否已经安装:
pkginfo SUNWsmaS
pkginfo SUNWsmdoc
pkginfo SUNWsmcmd
pkginfo SUNWsmmgr
pkginfo SUNWsmagt
pkginfo SUNWgcc

如果没有的话,请先安装:
pfexec pkg install SUNWsmaS
pfexec pkg install SUNWsmdoc
pfexec pkg install SUNWsmcmd
pfexec pkg install SUNWsmmgr
pfexec pkg install SUNWsmagt
pfexec pkg install SUNWgcc
(注释:如果是以root登录的话,命令前面不需要pfexec)

安装完成后的确认:
检查sma的配置文件:
cat /var/svc/manifest/application/management/sma.xml
cat /etc/sma/snmp/snmpd.conf
确认gcc安装成功:
gcc -v

启动并确认sma:
svcadm enable svc:/application/management/sma:default
svcs -a sma

查看sma的log:
cat /var/log/snmpd.log

2.编写mib并将它导入的snmpd中
下载net-snmp的source,它会在编译自己写的c文件时用到,下载地址是:
http://sourceforge.net/projects/net-snmp/files/

编写自己的mib,这一步很复杂,如果需要的话,我会单独写一片文章;具体可参见:
http://msdn.microsoft.com/en-us/library/aa909833.aspx
http://www.net-snmp.org/wiki/index.php/Writing_your_own_MIBs

mib写好后,可以通过snmptranslate来测试自己的mib是否写的正确:
首先将自己的mib文件copy到/etc/sma/snmp/mibs;
设置环境变量:export MIBS=+YOUR-MIB-FILE-NAME
重启sma服务:svcadm restart svc:/application/management/sma:default
使用snmptranslate来测试自己的mib是否正常加载:snmptranslate -IR yourMIBObject
(具体的可参见:
http://www.net-snmp.org/FAQ.html#How_do_I_add_a_MIB_
http://www.net-snmp.org/wiki/index.php/TUT:snmptranslate )

编写mib对应的c文件:
使用mib2c可以生产对应的c文件和头文件:pfexec mib2c -c /etc/sma/snmp/mib2c.scalar.conf
yourFileName
(注释:mib2c只是生产一个框架,具体的实现自己要完成;/etc/sma/snmp/mib2c.scalar.conf是用来生成c文件的配置文件,
在/etc/sma/snmp目录下还有很多不同的配置文件,具体的区别可参见:
http://docs.sun.com/app/docs/doc/817-3155/writingmodule-19?a=view)

编译source:
首先配置刚才下载的net-snmp的source,转到你解压的目录并执行:
./configure –with-mib-modules=”ucd_snmp $OTHER_MIBS” $OTHER_OPTIONS
编译mib2c生产并且自己实现的c文件:
cc -m64 -I yoursnmproot/net-snmp-svn-main/include net-snmp-config --cflags
-fPIC -shared -g -O0 -o yourSoName.so yourFileName.c net-snmp-config --libs
(注释:-m64 表示生产的目标文件是64位的)

加载so文件:
修改snmpd.conf文件(给文件追加一行),使自己的动态链接库在snmpd重启时可以加载:
dlmod yourMIBObject yourdemopath/yourSoName.so
重启sma并查看log:
svcadm restart svc:/application/management/sma:default
cat /var/log/snmpd.log
(如果log中只有snmp的版本号,表示一切顺利)

使用snmpget,snmpset等命令测试自己的so文件是否正常工作
(参见:http://www.net-
snmp.org/wiki/index.php/TUT:Writing_a_Dynamically_Loadable_Object)

注意,参见我写的另一篇文章:
http://blog.csdn.net/lantianjialiang/archive/2010/04/27/5532789.aspx

bash中特殊的变量赋值

看例子就好:

unset X Y Z

#${variable?value} - Complain if undefined
cat ${jack?”Please define jack, and try again”}

#${variable-default} - Use default if undefined
echo X is: $X
echo X is: ${X-default}
X=new
echo X is: ${X-default}
echo X is: $X

#${variable+value} - Change if defined
echo Y is: $Y
echo Y is: ${Y+”Current value of Y is $Y”}
Y=”test”
echo Y is: $Y
echo Y is: ${Y+”Current value of Y is $Y”}
echo Y is: $Y

#${variable=value} - define if undefined
echo Z is: $Z
echo Z is: ${Z=default}
Z=”test”
echo Z is: ${Z=default}
echo Z is: $Z

bash中的quote(/,',")

Quoted characters do not have a special meaning

以下的命令都一个执行:
touch ‘file1 file2’
ls ‘file1 file2’
rm ‘file1 file2’
touch file1’ ‘file2
ls file1’ ‘file2
rm file1’ ‘file2
touch f’ile1 file’2
ls f’ile1 file’2
rm f’ile1 file’2
touch “file1 file2”
ls “file1 file2”
rm “file1 file2”
touch file1” “file2
ls file1” “file2
rm file1” “file2
touch file”1 f”ile2
ls file”1 f”ile2
rm file”1 f”ile2

Single quotes(‘) is strong quote; double quote(“) is weak quote;
but backslash(/) is the strongest of all.

If you want to quote single quotes, use double quotes around it.
to quote double quotes, use single quotes

In fact, you don’t want to put quotes within quotes,
you want to combine or concatenate several units into one argument.
For example:
awk ‘{print $’$1’}’
the shell breaks up the argument to awk into three pieces:
{print $ Quoted
$1 Evaluated
} Quoted

However - there is a problem with this script. If you have a space as an
argument, the script would cause a syntax error A better version would protect
from this happening:
awk ‘{print $’”$1“’}’

再比如:
sed -n ‘s/‘“$1”‘/&/p’

输出单引号

echo /‘

输出双引号

echo /“

输出反斜线

echo //

输出’”/
echo /‘/“//

输出双引号

echo ‘“‘
echo “/“”

输出$HOME

echo ‘$HOME’

输出当前环境变量HOME的内容
echo “$HOME”

输出pwd

echo ‘pwd

输出当前的工作目录
echo “pwd

输出单引号

echo ‘’”‘“‘’
echo “‘“
echo ‘’/‘’’

有关opensolaris的一些调查和链接

所有帮助文档的集合地点:
http://docs.sun.com/source/820-7679/index.html

用户管理:
http://docs.sun.com/app/docs/doc/819-2379/userconcept-30?a=view
http://www.kobhi.com/solaris/user_management/solaris_user_management.htm

网络相关:
1.dladm: administrator data links

2.alias 的创建可以通过命令:

ifconfig e1000g1 addif 10.1.3.17/22
3.IPMP and Link Aggregation
Like IPMP, link aggregation groups interfaces together to improve network
performance and
reliability. Unlike IPMP, link aggregation is done at the link layer, rather
than at the IP layer;
this means that an aggregation uses only a single IP address, and it can be
used with dynamic IP
addresses provided by DHCP. Aggregations do not use the active probe-based
failure detection
that IPMP groups can provide, but they can be configured to use the Link
Aggregation Control
Protocol (LACP) to provide link failure detection.
4.Link Aggregation
Link Aggregation Control Protocol (LACP)
http://en.wikipedia.org/wiki/Link_aggregation
5.open solaris中的vlan设置和一般link的设定是一样的
http://blogs.sun.com/seb/entry/using_new_networking_features_in

在线测试正则表达式:
http://regex.powertoy.org/

opensolaris下一些长度和格式的guard:

username format
2个到8个字符;
第一个字符应当是字母;
其中是少有一个小写字母;
可以包含(period (.), underscore (_), or hyphen (-)),但是不推荐使用;
不能是一些默认的用户名;

password format
密码的长度在/etc/default/passwd中的PASSLENGTH定义,默认长度是6;
至少有两个字母,至少有一个数字或特殊字符;
[a-zA-Z]{2}
[0-9]{1}|/W|[_]

ip v4 address
/b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/b
可以匹配以下格式:
0{1,3}.0{1,3}.0{1,3}.0{1,3}
172.28.92.169
172.01.12.12
172.001.12.12
172.000.12.12
172.000.000.12
172.000.00.12
172.000.0.12
http://www.regular-expressions.info/examples.html

ip v6 address
full notation
E3D7:0000:0000:0000:51F4:9BC8:C0A8:6420
Shorthand notation(只能压缩一次)
E3D7::51F4:9BC8:C0A8:6420
mixed notation
E3D7::51F4:9BC8:192.168.100.32
http://compnetworking.about.com/od/tcpiptutorials/a/ipaddrnotation.htm

email address:256
http://en.wikipedia.org/wiki/E-mail_addressechoRFC_invalid_e-mail_addresses
http://www.regular-expressions.info/email.html
[/w/.%+-]+@([/w|-]+)(/.[/w|-]+)*

port number
16bit 65535

links
http://docs.sun.com/app/docs/doc/819-6990/geyqw?a=view
http://src.opensolaris.org/source/xref/onnv/onnv-
gate/usr/src/lib/libdladm/common/libdladm.cechodladm_valid_linkname

route:
entry number 132/55

duplex:
http://en.wikipedia.org/wiki/Duplex_%28telecommunications%29

Domain Name包含hostname和FQDN,完整的hostname就是FQDN;

a hostname is also called a domain name.
If the domain name is completely specified including a top-level domain of the
Internet,
the hostname is said to be a fully qualified domain name (FQDN).
hostname: max length is 63
http://technet.microsoft.com/en-us/library/cc959867.aspx
http://en.wikipedia.org/wiki/HostnameechoRestrictions_on_valid_host_names

domain name: max length is 255
http://www.ops.ietf.org/lists/namedroppers/namedroppers.2003/msg00964.html
http://technet.microsoft.com/en-us/library/bb727007.aspx

apache license 2.0
http://blog.csdn.net/arui319/archive/2008/05/12/2436097.aspx

sun nfs root
http://docs.sun.com/app/docs/doc/801-6634/6i10efskb?a=view

snapshot:
http://www.ibm.com/developerworks/tivoli/library/t-snaptsm1/index.html
http://blogs.sun.com/ahrens/entry/is_it_magic

ipf
http://docs.sun.com/app/docs/doc/816-5174/ipf-4?l=en &a=view&q=ipf
http://docs.sun.com/app/docs/doc/816-5166/ipf-1m?l=en&a=view

ICMP
http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol

Visualvm Working with Remote Applications

Visualvm可以用来监视java程序的运行状况,它可以监视本地或远端的java程序,但是在监视远端的程序时,必须进行设置。

1.在远端机器上安装jdk,必须是jdk;

2.在远端及其上启动jstatd;

参照http://java.sun.com/javase/6/docs/technotes/tools/share/jstatd.html,在jstatd的目录下创建一个策略文件,名字叫做jstatd.all.policy,jstatd.all.policy的内容是

grant codebase "file:${java.home}/../lib/tools.jar" {  

   permission java.security.AllPermission;  

};  

这时启动jstatd:  

cd /usr/java/bin  

./jstatd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=172.28.xx.xx &  

3.用jxm参数启动要监视的java程序,比如:  

java -Dcom.sun.management.jmxremote.port=3333 /  

     -Dcom.sun.management.jmxremote.ssl=false /  

     -Dcom.sun.management.jmxremote.authenticate=false /  

     -Djava.rmi.server.hostname=172.28.xx.xx /  

     YourJavaApp &  

4.在本地使用Visualvm连接172.28.xx.xx就可以了。  

具体的步骤参见:  

http://java.sun.com/javase/6/docs/technotes/guides/visualvm/applications_remote.html  

如果出现什么问题,可参见以下的链接:
http://blogs.sun.com/jmxetc/entry/connecting_through_firewall_using_jmxechocomment-1204031889000
http://blogs.sun.com/reichart/entry/jmx_unter_debian

解压.tar.gz文件

先使用:  

tar xzf filename.tar.gz  

如果不行的话,使用:  

gzip -dc filename.tar.gz | tar xf -  

解释:  

[http://freeengineer.org/learnUNIXin10minutes.html#Listing]  

gzip -d decompress  

gzip -c write on standard output, keep original files unchanged