(假定使用VirtualBox4.0.2)
1 在虚拟机硬盘所在目录下,运行如下命令将A盘复制到B盘:
...\.VirtualBox\HardDisks>vboxmanage clonehd A.vdi B.vdi
2 创建虚拟机B,并让其使用B盘。
Friday, 18 February 2011
Monday, 7 February 2011
Linux常用命令
测试网络的连通性:
[root@localhost ~]# ping -c 3 a.b.c.d
检查网络接口状态:
[root@localhost ~]# ifconfig -a
关闭网络接口eth0:
[root@localhost ~]# ifconfig eth0 down
打开网络接口eth0:
[root@localhost ~]# ifconfig eth0 up
为网络接口eth0设置网址:
[root@localhost ~]# ifconfig eth0 a.b.c.d netmask 255.255.255.0
查看内核路由表的配置:
[root@localhost ~]# route
添加默认网关:
[root@localhost ~]# route add default gw a.b.c.d
显示数据包所经过的路由:
[root@localhost ~]# traceroute a.b.c.d
显示网络端口状态:
[root@localhost ~]# netstat -penal
[root@localhost ~]# ping -c 3 a.b.c.d
检查网络接口状态:
[root@localhost ~]# ifconfig -a
关闭网络接口eth0:
[root@localhost ~]# ifconfig eth0 down
打开网络接口eth0:
[root@localhost ~]# ifconfig eth0 up
为网络接口eth0设置网址:
[root@localhost ~]# ifconfig eth0 a.b.c.d netmask 255.255.255.0
查看内核路由表的配置:
[root@localhost ~]# route
添加默认网关:
[root@localhost ~]# route add default gw a.b.c.d
显示数据包所经过的路由:
[root@localhost ~]# traceroute a.b.c.d
显示网络端口状态:
[root@localhost ~]# netstat -penal
Monday, 31 January 2011
如何在VirtualBox中设置虚拟网络环境?
1 创建两个局域网(internal network)
局域网A
vboxmanage dhcpserver add --netname icc_net --ip 136.1.206.0 --netmask 255.255.255.0 --lowerip 136.1.206.1 --upperip 136.1.206.255 --enable
局域网B
vboxmanage dhcpserver add --netname ncc_net --ip 121.157.1.0 --netmask 255.255.255.0 --lowerip 121.157.1.1 --upperip 121.157.1.255 --enable
2 配置局域网B上机器(RHEL5)的网卡
在/etc/sysconfig/network-scripts/ifcfg-eth0中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=121.157.1.147
NETWORK=121.157.1.0
USERCTL=no
在/etc/sysconfig/network中,添加如下配置:
GATEWAY=121.157.1.141
重新启动网卡:
service network restart
3 配置路由器(RHEL5)的网卡
在/etc/sysconfig/network-scripts/ifcfg-eth0中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=121.157.1.141
NETWORK=121.157.1.0
USERCTL=no
在/etc/sysconfig/network-scripts/ifcfg-eth1中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=136.1.206.121
NETWORK=136.1.206.0
USERCTL=no
重新启动网卡:
service network restart
在/etc/sysctl.conf中,设置:
net.ipv4.ip_forward =1
sysctl -p
4 配置局域网A上机器(Win7)的网卡
IP=136.1.206.129
NETMASK=255.255.255.0
GATEWAY=136.1.206.121
注意:路由器上的防火墙对A,B网间的通讯的影响。
局域网A
vboxmanage dhcpserver add --netname icc_net --ip 136.1.206.0 --netmask 255.255.255.0 --lowerip 136.1.206.1 --upperip 136.1.206.255 --enable
局域网B
vboxmanage dhcpserver add --netname ncc_net --ip 121.157.1.0 --netmask 255.255.255.0 --lowerip 121.157.1.1 --upperip 121.157.1.255 --enable
2 配置局域网B上机器(RHEL5)的网卡
在/etc/sysconfig/network-scripts/ifcfg-eth0中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=121.157.1.147
NETWORK=121.157.1.0
USERCTL=no
在/etc/sysconfig/network中,添加如下配置:
GATEWAY=121.157.1.141
重新启动网卡:
service network restart
3 配置路由器(RHEL5)的网卡
在/etc/sysconfig/network-scripts/ifcfg-eth0中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=121.157.1.141
NETWORK=121.157.1.0
USERCTL=no
在/etc/sysconfig/network-scripts/ifcfg-eth1中,添加如下配置:
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=136.1.206.121
NETWORK=136.1.206.0
USERCTL=no
重新启动网卡:
service network restart
在/etc/sysctl.conf中,设置:
net.ipv4.ip_forward =1
sysctl -p
4 配置局域网A上机器(Win7)的网卡
IP=136.1.206.129
NETMASK=255.255.255.0
GATEWAY=136.1.206.121
注意:路由器上的防火墙对A,B网间的通讯的影响。
Saturday, 8 January 2011
如何连接Ingres服务器?
Ingres与其他数据库不同,用于连接数据库的用户名必须是操作系统级的用户名。而且,操作系统级的用户名必须先生成。
Tuesday, 21 December 2010
如何扩大VirtualBox磁盘容量?
- 创建一个更大的磁盘;
- 将新创建的磁盘添加到虚拟客户机上;
- 将Ghost光盘插入客户机;
- 启动客户机;
- 使用Ghost 将原磁盘克隆至新创建的磁盘;
- 克隆完成后,关机;
- 从客户机上摘去原磁盘;
- 从新启动客户机;
Sunday, 19 December 2010
如何将RHEL5.5的Java升级至1.5?
下载jdk-1_5_0_22-linux-amd64-rpm.bin
[root@localhost ~]# chmod 775 jdk-1_5_0_22-linux-amd64-rpm.bin
[root@localhost ~]# ./jdk-1_5_0_22-linux-amd64-rpm.bin
vi /etc/profile.d/java.sh 加入下述两行:
export JAVA_HOME=/usr/java/jdk1.5.0_22
export PATH=$JAVA_HOME/bin:$PATH
[root@localhost ~]# source /etc/profile.d/java.sh
[root@localhost ~]# alternatives --install /usr/bin/java java /usr/java/jdk1.5.0_22/bin/java 2
运行下述命令,并选择2:
[root@localhost ~]# alternatives --config java
[root@localhost ~]# chmod 775 jdk-1_5_0_22-linux-amd64-rpm.bin
[root@localhost ~]# ./jdk-1_5_0_22-linux-amd64-rpm.bin
vi /etc/profile.d/java.sh 加入下述两行:
export JAVA_HOME=/usr/java/jdk1.5.0_22
export PATH=$JAVA_HOME/bin:$PATH
[root@localhost ~]# source /etc/profile.d/java.sh
[root@localhost ~]# alternatives --install /usr/bin/java java /usr/java/jdk1.5.0_22/bin/java 2
运行下述命令,并选择2:
[root@localhost ~]# alternatives --config java
Friday, 17 December 2010
如何在RHEL5.5上更改PostgreSQL的数据目录?
检查缺省数据目录的属性
# ls -lZ /var/lib/pgsql
drwx------ postgres postgres system_u:object_r:postgresql_db_t data
生成新的数据目录
# mkdir -p /opt/postgresql/data
检查新生成的数据目录属性
# ls -lZ /opt/postgresql/
drwxr-xr-x root root root:object_r:usr_t data
更改新生成数据目录的所有权
# chown -R postgres:postgres /opt/postgresql
修改启动代码中的相关路径
# vi /etc/rc.d/init.d/postgresql
PGDATA=/opt/postgresql/data
PGLOG=/opt/postgresql/data/pgstartup.log
创建新的数据区
# su - postgres -c "initdb -D /opt/postgresql/data"
为新数据区添加SELINUX标签
# semanage fcontext -a -t postgresql_db_t "/opt/postgresql(/.*)?"
检查新添标签是否到位
# grep -i postgresql /etc/selinux/targeted/contexts/files/file_contexts.local
/opt/postgresql(/.*)? system_u:object_r:postgresql_db_t:s0
为新数据区贴标签
# restorecon -R -v /opt/postgresql
验证更改后数据库服务能否启动
# service postgresql start
Starting postgresql service: [ OK ]
将数据库服务设置为自动启动
# chkconfig postgresql on
# chkconfig --list | grep post
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# ls -lZ /var/lib/pgsql
drwx------ postgres postgres system_u:object_r:postgresql_db_t data
生成新的数据目录
# mkdir -p /opt/postgresql/data
检查新生成的数据目录属性
# ls -lZ /opt/postgresql/
drwxr-xr-x root root root:object_r:usr_t data
更改新生成数据目录的所有权
# chown -R postgres:postgres /opt/postgresql
修改启动代码中的相关路径
# vi /etc/rc.d/init.d/postgresql
PGDATA=/opt/postgresql/data
PGLOG=/opt/postgresql/data/pgstartup.log
创建新的数据区
# su - postgres -c "initdb -D /opt/postgresql/data"
为新数据区添加SELINUX标签
# semanage fcontext -a -t postgresql_db_t "/opt/postgresql(/.*)?"
检查新添标签是否到位
# grep -i postgresql /etc/selinux/targeted/contexts/files/file_contexts.local
/opt/postgresql(/.*)? system_u:object_r:postgresql_db_t:s0
为新数据区贴标签
# restorecon -R -v /opt/postgresql
验证更改后数据库服务能否启动
# service postgresql start
Starting postgresql service: [ OK ]
将数据库服务设置为自动启动
# chkconfig postgresql on
# chkconfig --list | grep post
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Subscribe to:
Posts (Atom)