Tuesday, July 28, 2015

How to assign multiple IP addresses to one network interface on CentOS



How to assign multiple IP addresses to one network interface on CentOS


The practice of configuring multiple IP addresses on a particular network interface is called IP aliasing. IP aliasing is useful when you set up multiple sites on virtual web hosting on a single interface, or maintain multiple connections to a network each of which serves a different purpose. You can assign multiple IP addresses to one network interface from a single subnet or completely different ones.
All existing Linux distributions including CentOS supports IP aliasing. Here is how to bind multiple IP addresses to a single network interface on CentOS.
If you would like to set up IP aliasing on the fly, there are two ways to do it. One way is to useifconfig, and the other method is to use ip command. Using these two methods, let me show you how to add two extra IP addresses to eth0.
To use the first method:
$ sudo ifconfig eth0:1 192.168.10.10 netmask 255.255.255.0 up
$ sudo ifconfig eth0:2 192.168.10.15 netmask 255.255.255.0 up
To use the second method:
$ sudo ip addr add 192.168.10.10/24 dev eth0
$ sudo ip addr add 192.168.10.15/24 dev eth0
To view a list of all IP addresses assigned to eth0 by using either method, run the following command.
$ sudo ip addr list dev eth0
2: eth0:  mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000
    link/ether 00:0c:29:5c:86:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.91.128/24 brd 192.168.91.255 scope global eth0
    inet 192.168.91.10/24 scope global secondary eth0
    inet 192.168.91.20/24 scope global secondary eth0
    inet6 fe80::20c:29ff:fe5c:86f4/64 scope link
       valid_lft forever preferred_lft forever
If you used ifconfig to create IP aliases, you can also use the same command to view them.
$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0C:29:5C:86:F4
          inet addr:192.168.91.128  Bcast:192.168.91.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe5c:86f4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:22 errors:0 dropped:0 overruns:0 frame:0
          TX packets:102 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3869 (3.7 KiB)  TX bytes:18172 (17.7 KiB)
          Interrupt:19 Base address:0x2000

eth0:1    Link encap:Ethernet  HWaddr 00:0C:29:5C:86:F4
          inet addr:192.168.91.10  Bcast:192.168.91.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:19 Base address:0x2000

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:5C:86:F4
          inet addr:192.168.91.20  Bcast:192.168.91.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:19 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)
If you would like to permanently assign multiple IP addresses to an interface, create corresponding configuration files in /etc/sysconfig/network-scripts.
$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.0.5
NETMASK=255.255.255.0
ONBOOT=yes
Once you have created as many configuration files as IP addresses to assign, restart network to activate IP aliasing.
$ sudo /etc/init.d/network restart

Monday, July 27, 2015

Grid Control Target Maintenance: How To Recreate the Targets.xml File in Grid Control 10.2.x Using 'agentca' Commands

Grid Control Target Maintenance: How To Recreate the Targets.xml File in Grid Control 10.2.x Using 'agentca' Commands

The targets.xml file is used by the agent to store important details about each monitored target on the node.  Sometimes under certain conditions, the file may need to be regenerated either because of corruption or accidental deletion.  To recreate a 10.2.x targets.xml file, the agentca (Agent Configuration Assistant) can be called from commandline.
NOTE: The targets.xml file should be included in a system backup each time a configuration change is made to a target through the Grid Control Console (UI) or from the commandline using 'emctl' commands.

To recreate the targets.xml file  follow these steps:

    • Create a blank targets.xml file:
      • On Windows, create the new file in the Agent's %ORACLE_HOME%\sysman\emd\ directory.
        From Windows Explorer, click on File->New->Text File.  Save as 'targets.xml'
      • On Unix, issue the commands

        $ cd $ORACLE_HOME/sysman/emd   (where $ORACLE_HOME is the Agent's home)
        $ touch targets.xml.

    • Once you have created the targets.xml file, view the Agent's $ORACLE_HOME/sysman/config/emd.properties file.  Copy the values for:

...
agentSeed=12345678
...
EMD_URL=http://agentmachine.domain:9876/emd/main
...

    • Manually update the new targets.xml and add the following entries to the file following the syntax exactly:
<Targets AGENT_SEED="agentseed from emd.properties">
               <Target TYPE="oracle_emd" NAME="hostname and port from emd.properties EMD_URL"/>
               <Target TYPE="host" NAME="hostname as it appears in the emd_url"/>
</Targets>

      For example:

<Targets AGENT_SEED="12345678">
            <Target TYPE="oracle_emd" NAME="agentmachine.domain:9876"/>
            <Target TYPE="host" NAME="agentmachine.domain"/>
</Targets>

NOTE: The first time you start this agent after adding the above parameters, the AGENT_SEED parameter will convert itself to AGENT_TOKEN and the seed will become encrypted.


    • Force the target re-discovery using one of the below methods:

      • Run agentca -d to force a new discovery of the targets on the host

        cd <AGENT_HOME>/bin
        agentca -d
        For options that can be used with agentca (including those to be used on a RAC setup), refer to Note 868817.1: Grid Agent Configuration: How To Manually Execute the Agent Configuration Assistant utility (agentca)

      • Manually discover the target via the Grid Console. Refer to the steps in
        Note 417690.1: Grid Control Target Maintenance: How To Manually Discover a Target in the Grid Console?

Tuesday, July 14, 2015

CUPS Command Line Interfaces

CUPS Command Line Interfaces


You can also simply use the command line to administer the printers. You can add a network printer enable the printer with:


  # lpadmin -p hplj -v socket://192.168.0.6:9100/ -E

Another example for a LPD print server:


  # lpadmin -p lp1nd -v lpd://printhost/lp1nd -E

To add information about the Location and a Description of the printer:


  # lpadmin -p lp0 -L "Level 2 South" -D "HP LaserJet 4"

To specify a PPD for the printer:


  # lpadmin -p lp7 -P /usr/share/postscript/ppd/HP_LaserJet_4050_Series.ppd
  # lpadmin -p lp11 -P LEXC750.PPD

The PPD file is copied into /etc/cups/ppd/lp11.ppd, for example.
You can look at the printer options (assuming it has a PPD) with:


  # lpoptions -p lp7 -l

And you can set options with:


  # lpoptions -p lp7 -o PageSize=A4
  # lpoptions -p lp1 -o PageSize=A4

And so on. These options are placed in /etc/cups/lpoptions. The same options can be set using the web interface. The web interface is indeed somewhat easier to use, and it modifies the PPD file directly (e.g., /etc/cups/ppd/lp1.ppd) rather than using the /etc/cups/lpoptions file!
You can access printer options directly from the command line when printing, if the printer's PPD supports the option. For example, the HP LaserJet 4050 driver I'm using (from hp-ppd) supports n-up printing and watermarks:




  $ lp -o HPNup=TwoUpL sample.pdf
  $ lp -o HPwmText=Draft odbcmine.pdf

Monday, July 13, 2015

HP-UX 网络故障

1. 如需修改网络地址、主机名等,一定要用 set_parms 命令

        # set_parms    hostname 
        # set_parms    ip_address

2. 查看网卡状态:    lanscan

Hardware   Station                 Crd    Hardware    Net-
Interface 
Path          Address                 In#         state       
nameunit state 
8/20/5/1    0x0800097843FB    0      up              lan0    up

3. 确认网络地址:

# ifconfig    lan0 

4. 启动网卡:

# ifconfig lan0 up 

5. 网络不通的诊断过程:

lanscan  查看网卡是否启动(up) 
ping    自己网卡地址 (ip 地址) 
ping    其它机器地址,如不通,在其机器上用 lanscan 命令得知 station address,然后
linkloop station_address 来确认网线及集成器是否有问题。
在同一网中,subnetmask 应一致。

6. 配置网关

手动加网关
/usr/sbin/route   add  default   20.08.28.98 1 
把网关自动加入系统中
vi  /etc/rc.config.d / netconf: 
ROUTE_DESTINATION [0]=default 
ROUTE_GATEWAY [0]=20.08.28.98 
ROUTE_COUNT [0]=1 
/sbin/init.d/net  将执行:
/usr/sbin/route   add  default  20.08.28.98 1 命令
 netstat  -rn  查看路由表

另外也可用 set_parms addl_netwrk 来设缺省路由。


HP-UX 软件故障诊断

常用命令来查看系统状态。

1. # ioscan -fn 
列出各
I/O
卡及设备的所有相关信息:如逻辑单元号,硬件地址及
设备文件名等。

2. # ps -ef 
列出正在运行的所有进程的各种信息:如进程号及进程名等。

3. # netstat -rn 
列出网卡状态及路由信息等。

4. # lanscan 
列出网卡状态及网络配置信息。

5. # bdf 
列出已加载的逻辑卷及其大小信息。

6. # mount 
列出已加载的逻辑卷及其加载位置。

7. # uname -a 
列出系统 ID 号,OS版本及用户权限等信息。

8. # hostname 
列出系统网络名称。

9. # pvdisplay -v /dev/dsk/c*t*d* 
显示磁盘各种信息,如磁盘大小,包含的逻辑卷,设备名称等。

10.# vgdisplay -v /dev/vg00 
显示逻辑卷组信息,如包含哪些物理盘及逻辑卷等。

11.# lvdisplay -v /dev/vg00/lvol1 
显示逻辑卷各种信息,如包含哪些盘,是否有镜像等

Thursday, July 9, 2015

ulimit

ulimit

User limits - limit the use of system-wide resources.
Syntax
      ulimit [-acdfHlmnpsStuv] [limit]

Options

   -S   Change and report the soft limit associated with a resource. 
   -H   Change and report the hard limit associated with a resource. 

   -a   All current limits are reported. 
   -c   The maximum size of core files created. 
   -d   The maximum size of a process's data segment. 
   -f   The maximum size of files created by the shell(default option) 
   -l   The maximum size that can be locked into memory. 
   -m   The maximum resident set size. 
   -n   The maximum number of open file descriptors. 
   -p   The pipe buffer size. 
   -s   The maximum stack size. 
   -t   The maximum amount of cpu time in seconds. 
   -u   The maximum number of processes available to a single user. 
   -v   The maximum amount of virtual memory available to the process. 
ulimit provides control over the resources available to the shell and to processes started by it, on systems that allow such control.
The soft limit is the value that the kernel enforces for the corresponding resource. The hard limit acts as a ceiling for the soft limit.
An unprivileged process may only set its soft limit to a value in the range from 0 up to the hard limit, and (irreversibly) lower its hard limit. A privileged process can make arbitrary changes to either limit value.
If limit is given, it is the new value of the specified resource. Otherwise, the current value of the soft limit for the specified resource is printed, unless the `-H' option is supplied.
When setting new limits, if neither `-H' nor `-S' is supplied, both the hard and soft limits are set.
Restricting per user processes ( -u) can be useful for limiting the potential effects of a fork bomb.

Values are in 1024-byte increments, except for `-t', which is in seconds, `-p', which is in units of 512-byte blocks, and `-n' and `-u', which are unscaled values.
The return status is zero unless an invalid option is supplied, a non-numeric argument other than unlimited is supplied as alimit, or an error occurs while setting a new limit.
ulimit is a bash built in command.

How to change the ulimit values in HPUX

How to change the ulimit values in HPUX




If you want to change it for all users, do it in /etc/profile.

If you want to do particular user, use the respective options with ulimit.

e.g ulimit -c to set core file size.

Read man pages of ulimit to get more details.
# man ulimit.

1. ulimit -a
Display all configured values.

2. ulimit -c 
Sets core file size

3. ulimit -d 
Sets data seg size

4. ulimit -n 
Sets Open Files

5. ulimit -s 
Sets stack size

6. ulimit -u 
Sets max user processes

7. ulimit -t 
Sets cpu time

8. ulimit -v 
Sets virtual memory

9. ulimit -p 
Sets pipe size

  How to Change Instance Type & Security Group of EC2 in AWS By David Taylor Updated April 29, 2023 EC2 stands for Elastic Compute Cloud...