Tuesday, 21 December 2010

如何扩大VirtualBox磁盘容量?

  1. 创建一个更大的磁盘;
  2. 将新创建的磁盘添加到虚拟客户机上;
  3. 将Ghost光盘插入客户机;
  4. 启动客户机;
  5. 使用Ghost 将原磁盘克隆至新创建的磁盘;
  6. 克隆完成后,关机;
  7. 从客户机上摘去原磁盘;
  8. 从新启动客户机;

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


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

Thursday, 16 December 2010

如何让yum使用RHEL5.5光盘安装软件?

插入RHEL5光盘
登录为root
[root@localhost ~]# mkdir dvd
[root@localhost ~]# cd /media/RHEL-5.5\ i386\ DVD/Server/
[root@localhost Server]# rpm -i createrepo-0.4.11-3.el5.noarch.rpm
[root@localhost Server]# cd /root/dvd
[root@localhost dvd]# createrepo -vpo . /media/RHEL-5.5\ i386\ DVD/
[root@localhost dvd]# ln -s /media/RHEL-5.5\ i386\ DVD/Server/ Server
[root@localhost dvd]# vi /etc/yum.repos.d/DVD.repo 并加入下述内容:
    [dvd]
    name=RHEL5 DVD
    baseurl=file:///root/dvd
    enabled=1
    gpgcheck=0
      [root@localhost dvd]# yum clean all
      [root@localhost dvd]# yum update

      例如,安装PostgreSQL
      [root@localhost ~]# yum install postgresql84 postgresql84-server postgresql84-contrib postgresql84-devel postgresql84-docs postgresql84-test
      [root@localhost ~]# chkconfig postgresql on
      [root@localhost ~]# service postgresql initdb
      [root@localhost ~]# service postgresql start


      Update 1: I found this URL is more comprehensive.

      Update 2: Here is another way, which is much simpler:

      copy the ISO image, e.g. rhel-server-6.5-x86_64-dvd.iso, to the server under /root;

      mount -o loop -t iso9660 /root/rhel-server-6.5-x86_64-dvd.iso /mnt/

      vi /etc/yum.repos.d/dvd.repo and add following content:

      [dvd]
      name=DVD
      baseurl=file:///mnt/Server
      enabled=1
      gpgcheck=0


      Thursday, 9 December 2010

      如何为Linux虚拟机设置VirtualBox共享文件夹?

      设置共享文件夹Temp后,在Linux虚拟机上运行如下命令:
      mount -t vboxsf temp /mnt
      即可在/mnt下看到共享文件夹的内容。