FreeBSD install

FreeBSD的可玩性还是很高的.
本文将介绍一下FreeBSD在vmware中的安装, 物理机的安装和这个差不多.

我们这里将要用到zfs的root disk mirror. 所以虚拟机环境中需要2块物理设备.

如果是物理机器的话, 建议使用RAID的JBOD模式. (原因参见http://blog.163.com/digoal@126/blog/static/163877040201441694022110/)

首先我们要下载freebsd 的iso, 本文用到的是10.0 x64的版本.

ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.0/FreeBSD-10.0-RELEASE-amd64-dvd1.iso

然后需要安装vmware workstation. 我这里用到的是10的版本.

创建虚拟机


 


 


 


 

内存建议配大一点, 至少1G, 最好有2GB, 如果使用ZFS的话, 最好大于4GB.
 


 

创建磁盘
 


 


 


 


 


 

这里只创建了1块磁盘, 所以使用ZFS的话, 无法选择mirror模式.

最好创建2块一样的磁盘, 实际生产机中, 如果底层设备是RAID模式的, 那么没有必要使用MIRROR模式.

如果底层设备不是RAID模式, 那么建议使用JBOD+mirror模式.

准备安装, 选择1.
 


 

配置键盘
 

配置主机名
 

配置要安装的包
 

选择磁盘分区, 建议使用ZFS.
 

选择Install, 配置ZPOOL

因为例子中只有1块硬盘, 选择mirror后会导致无法进行安装.
 


 


 


 

关闭虚拟机, 新建一个硬盘.
 

现在可以选择mirror了, 选中两块硬盘作为mirror vdev.
 


 

开始安装包
 

安装完成后, 提示你设置root用户的密码

然后是配置网卡


 


 


 


 

配置时钟, 时区.
 


 


 


 


 

配置BSD启动后, 开启哪些常用的服务, 例如sshd, ntpd

询问是否新增一个普通用户, 可以在后面使用adduser命令添加.
 

是否安装handbook, 可选.
 


 


 


 


 


 

询问是否进入SHELL进行配置, 可以配置, 也可以直接exit退出
 


 

重启服务器.

接下来要配置一下sshd_config, 让root用户可以使用密码认证, 使用远程登录.
 


 


 


 

重启sshd服务
 

创建普通用户举例




root@my-domain:~ # adduser 

Username: digoal    输入用户名

Full name: digoal.zhou   输入全名

Uid (Leave empty for default): 

Login group [digoal]: 

Login group is digoal. Invite digoal into other groups? []:   类似linux 的useradd -G , 是否加入其他组

Login class [default]: 

Shell (sh csh tcsh nologin) [sh]: csh  使用csh

Home directory [/home/digoal]: 

Home directory permissions (Leave empty for default): 

Use password-based authentication? [yes]:   是否使用基于密码的认证

Use an empty password? (yes/no) [no]: 

Use a random password? (yes/no) [no]: 

Enter password: 

Enter password again: 

Lock out the account after creation? [no]:   创建完后是否锁住用户

Username   : digoal

Password   : *****

Full Name  : digoal.zhou

Uid        : 1002

Class      : 

Groups     : digoal 

Home       : /home/digoal

Home Mode  : 

Shell      : /bin/csh

Locked     : no

OK? (yes/no): yes

adduser: INFO: Successfully added (digoal) to the user database.

Add another user? (yes/no): no  是否继续创建其他用户

Goodbye!

root@my-domain:~ # id digoal

uid=1002(digoal) gid=1002(digoal) groups=1002(digoal)

查找包举例






pkg search $packagename

第一次使用pkg, 如果没有安装的话, 会提示安装.

root@digoal:~ # pkg search postgresql
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait...

Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.2.7_2... done
If you are upgrading from the old package format, first run:

# pkg2ng

root@my-domain:~ # pkg search postgresql

exim-postgresql-4.82

ja-postgresql82-man-8.2.4

libgda4-postgresql-4.2.12

libgda5-postgresql-5.0.3

p5-Test-postgresql-0.09

pgtcl-postgresql90-2.0.0

pgtcl-postgresql91-2.0.0

pgtcl-postgresql92-2.0.0

pgtcl-postgresql93-2.0.0

pgtcl-postgresql94-2.0.0

postgresql-jdbc-9.1.902_1

postgresql-libpgeasy-3.0.4_1

postgresql-libpqxx-4.0.1_1

postgresql-libpqxx3-3.1.1_1

postgresql-odbc-09.01.0200_1

postgresql-pllua-1.0

postgresql-plproxy-2.5

postgresql-plruby-0.5.4_2

postgresql-plv8js-1.4.1

postgresql-relay-1.3.2_1

postgresql-repmgr-2.0_1

postgresql84-client-8.4.21

postgresql84-contrib-8.4.21_1

postgresql84-docs-8.4.21

postgresql84-plperl-8.4.21_1

postgresql84-plpython-8.4.21_1

postgresql84-pltcl-8.4.21

postgresql84-server-8.4.21_1

postgresql9-client-9.4.b1_1

postgresql9-contrib-9.4.b1_1

postgresql9-docs-9.4.b1

postgresql9-plperl-9.4.b1

postgresql9-plpython-9.4.b1

postgresql9-pltcl-9.4.b1

postgresql9-server-9.4.b1_1

postgresql90-client-9.0.17

postgresql90-contrib-9.0.17

postgresql90-docs-9.0.17

postgresql90-plperl-9.0.17

postgresql90-plpython-9.0.17

postgresql90-pltcl-9.0.17

postgresql90-server-9.0.17

postgresql91-client-9.1.13_1

postgresql91-contrib-9.1.13_1

postgresql91-docs-9.1.13

postgresql91-plperl-9.1.13_1

postgresql91-plpython-9.1.13_1

postgresql91-pltcl-9.1.13

postgresql91-server-9.1.13_1

postgresql92-client-9.2.8_1

postgresql92-contrib-9.2.8_1

postgresql92-docs-9.2.8

postgresql92-plperl-9.2.8_1

postgresql92-plpython-9.2.8_1

postgresql92-pltcl-9.2.8

postgresql92-server-9.2.8_1

postgresql93-client-9.3.4

postgresql93-contrib-9.3.4_1

postgresql93-docs-9.3.4

postgresql93-plperl-9.3.4

postgresql93-plpython-9.3.4

postgresql93-pltcl-9.3.4

postgresql93-server-9.3.4

postgresql_autodoc-1.41

py33-postgresql-1.1.0_1

安装包举例

pkg install $packagename

例如安装我们上面查到的postgresql 9.3.4






root@my-domain:~ # pkg install postgresql93-server-9.3.4

Updating repository catalogue

The following 2 packages will be installed:

        Installing postgresql93-client: 9.3.4

        Installing postgresql93-server: 9.3.4

The installation will require 25 MB more space

5 MB to be downloaded

Proceed with installing packages [y/N]: y

postgresql93-client-9.3.4.txz                                                           100% 1968KB  43.7KB/s 108.1KB/s   00:45    

postgresql93-server-9.3.4.txz                                                           100% 3196KB  47.0KB/s  55.5KB/s   01:08    

Checking integrity... done

[1/2] Installing postgresql93-client-9.3.4... done

[2/2] Installing postgresql93-server-9.3.4...===> Creating users and/or groups.

Creating group 'pgsql' with gid '70'.

Creating user 'pgsql' with uid '70'.

  =========== BACKUP YOUR DATA! =============

  As always, backup your data before

  upgrading. If the upgrade leads to a higher

  minor revision (e.g. 8.3.x -> 8.4), a dump

  and restore of all databases is

  required. This is *NOT* done by the port!

  Press ctrl-C *now* if you need to pg_dump.

  ===========================================

 done

The PostgreSQL port has a collection of "side orders":

postgresql-docs

  For all of the html documentation

p5-Pg

  A perl5 API for client access to PostgreSQL databases.

postgresql-tcltk 

  If you want tcl/tk client support.

postgresql-jdbc

  For Java JDBC support.

postgresql-odbc

  For client access from unix applications using ODBC as access

  method. Not needed to access unix PostgreSQL servers from Win32

  using ODBC. See below.

ruby-postgres, py-PyGreSQL

  For client access to PostgreSQL databases using the ruby & python

  languages.

postgresql-plperl, postgresql-pltcl & postgresql-plruby

  For using perl5, tcl & ruby as procedural languages.

postgresql-contrib

  Lots of contributed utilities, postgresql functions and

  datatypes. There you find pg_standby, pgcrypto and many other cool

  things.

etc...

For procedural languages and postgresql functions, please note that

you might have to update them when updating the server.

If you have many tables and many clients running, consider raising

kern.maxfiles using sysctl(8), or reconfigure your kernel

appropriately.

The port is set up to use autovacuum for new databases, but you might

also want to vacuum and perhaps backup your database regularly. There

is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that

you may find useful. You can use it to backup and perfom vacuum on all

databases nightly. Per default, it perfoms `vacuum analyze'. See the

script for instructions. For autovacuum settings, please review

~pgsql/data/postgresql.conf.

If you plan to access your PostgreSQL server using ODBC, please

consider running the SQL script /usr/local/share/postgresql/odbc.sql

to get the functions required for ODBC compliance.

Please note that if you use the rc script,

/usr/local/etc/rc.d/postgresql, to initialize the database, unicode

(UTF-8) will be used to store character data by default.  Set

postgresql_initdb_flags or use login.conf settings described below to

alter this behaviour. See the start rc script for more info.

To set limits, environment stuff like locale and collation and other

things, you can set up a class in /etc/login.conf before initializing

the database. Add something similar to this to /etc/login.conf:

---

postgres:\

        :lang=en_US.UTF-8:\

        :setenv=LC_COLLATE=C:\

        :tc=default:

---

and run `cap_mkdb /etc/login.conf'.

Then add 'postgresql_class="postgres"' to /etc/rc.conf.

======================================================================

To initialize the database, run

  /usr/local/etc/rc.d/postgresql initdb

You can then start PostgreSQL by running:

  /usr/local/etc/rc.d/postgresql start

For postmaster settings, see ~pgsql/data/postgresql.conf

NB. FreeBSD's PostgreSQL port logs to syslog by default

    See ~pgsql/data/postgresql.conf for more info

======================================================================

To run PostgreSQL at startup, add

'postgresql_enable="YES"' to /etc/rc.conf

root@my-domain:~ # su - pgsql

$ which psql

/usr/local/bin/psql

$ psql -V

psql (PostgreSQL) 9.3.4

这个pg的编译参数

$ pg_config --configure

'--with-libraries=/usr/local/lib' '--with-includes=/usr/local/include' '--enable-thread-safety' '--with-openssl' '--with-libxml' '--enable-nls' '--without-gssapi' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=amd64-portbld-freebsd10.0' 'build_alias=amd64-portbld-freebsd10.0' 'CC=cc' 'CFLAGS=-O2 -pipe -fno-strict-aliasing' 'LDFLAGS= -L/usr/local/lib -Wl,-rpath,/usr/lib:/usr/local/lib' 'CPPFLAGS=' 'CPP=cpp' 'LDFLAGS_SL='

删除包举例






root@my-domain:~ # pkg remove postgresql93-server-9.3.4

Deinstallation has been requested for the following 1 packages:

        postgresql93-server-9.3.4

The deinstallation will free 17 MB

Proceed with deinstalling packages [y/N]: y

[1/1] Deleting postgresql93-server-9.3.4...==> You should manually remove the "pgsql" user. 

 done

提示用户需要手工删除

root@my-domain:~ # id pgsql

uid=70(pgsql) gid=70(pgsql) groups=70(pgsql)

手工删除用户






root@my-domain:~ # rmuser pgsql

Matching password entry:

pgsql:*:70:70::0:0:PostgreSQL pseudo-user:/usr/local/pgsql:/bin/sh

Is this the entry you wish to remove? yes

Remove user's home directory (/usr/local/pgsql)?    

Remove user's home directory (/usr/local/pgsql)? ys

Remove user's home directory (/usr/local/pgsql)? yes

Removing user (pgsql): mailspool home passwd.

root@my-domain:~ # rm

rm        rmail     rmd160    rmdir     rmextattr rmt       rmuser    

root@my-domain:~ # id pgsql

id: pgsql: no such user

下载软件举例

freebsd默认没有安装wget, 可以使用fetch命令下载软件.









fetch http://ftp.postgresql.org/pub/source/v9.3.4/postgresql-9.3.4.tar.bz2

如果要用wget的话, 可以使用pkg安装wget.









pkg install wget

[参考]

1. http://blog.163.com/digoal@126/blog/static/163877040201441694022110/

2. http://en.wikipedia.org/wiki/Non-RAID_drive_architectures

3. http://www.freebsd.org/

4. ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/10.0/FreeBSD-10.0-RELEASE-amd64-dvd1.iso

5. http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/

6. ftp://ftp.freebsd.org/pub/FreeBSD/doc/en_US.ISO8859-1/books/

时间: 2024-08-29 08:02:46

FreeBSD install的相关文章

第 1 章 FreeBSD Install

1.1. Welcome 回车即可 选择 Install 按钮后回车 选择 No 输入 Hostname 原文出处:Netkiller 系列 手札 本文作者:陈景峯 转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明.

Freebsd+Resin成功建立支持jsp平台

js 环境:FreeBsd 4.9 Apache1.3.29+php4.3.4+mysql4+ports 安装 首先要cvsup同步ports , /usr/local/bin/cvsup -g -L 2 /usr/local/etc/ports-supfile /usr/local/bin/cvsup -g -L 2 /usr/local/etc/stable-supfile 然后进入http://www.freebsd.org/ports/java.html 进入bsd 关于java 的官方

阿里云freebsd安装node

安装node pkg install node 安装npm pkg install bin/www 然后,看一下版本: freebsd 安装node 非常简单是吧.

PC-BSD install

PC-BSD是基于FreeBSD的一个专注于桌面应用的操作系统. 下面是在VMWare 10中的安装简介. 下载ISO http://iso.cdn.pcbsd.org/10.0-RELEASE/amd64/PCBSD10.0-RELEASE-x64-DVD-USB-latest.iso 创建虚拟机. 安装                 以下为zfs的各dataset的属性, 这些属性可以通过zfs get all查看. 通过zfs set x=x进行设置.                  

FreeBSD平台下Web服务器架设攻略

在FreeBSD系统中,一个标准的FreeBSD系统,至少要有一个网络界面以便与其他计算机通信.它支持Token Ring和FDDI,以及普通电话拨号连接.ISDN.ATM等广域网连接方式.本文要讨论的是基于此系统平台下的WEB服务的组建情况,FreeBSD的使用版本为4.7. 一.接入Internet 配置的第一步就是让FreeBSD接入Internet并设置好代理服务.本机使用ADSL接入Internet有两种情况,即通过拨号获取的动态ip或ISP提供的静态ip.以下主要介绍动态IP的配置过

FreeBSD下构建安全的Web服务器(3)

web|web服务|web服务器|安全 对于使用php脚本来进行交互,最好建立一个用户只针对某个库有 update.select.delete.insert.drop table.create table等权限,这样就很好避免了数据库用户名和密码被黑客查看后最小损失. 比如下面我们创建一个数据库为db1,同时建立一个用户test1能够访问该数据库. mysql> create database db1; mysql> grant select,insert,update,delete,crea

FreeBSD下安装PostgreSQL新手教程

教程  FreeBSD下安装PostgreSQL新手教程  作者: heiyeluren QQ群: 5415735 (FreeBSD安装维护群) 日期: 2004/9/17 -- 特别感谢QQ群好友阿南,本文在他的耐心指导下才产生 -- PostgreSQL是一个开源的数据库管理系统,PostgreSQL 是一种非常复杂的对象-关系型数据库管理系统(ORDBMS), 也是目前功能最强大,特性最丰富和最复杂的自由软件数据库系统.它的很多特性正是当今许多商业数据库的前身,有些特性甚至连商业数据库都不

在freebsd下安装oracle

oracle Установка Oracle8i 8.1.7.4 на FreeBSD шаг за шагомВячеслав Иванченко<ivi@dhs.net.ru> $FreeBSD: doc/ru_RU.KOI8-R/articles/oracle/article.sgml,v 1.36 2003/07/14 03:12:47 ivi Exp $ Чтобы сделать этот документ максимально информативным и правильн

在FreeBSD上建立一个功能完整的邮件服务器

#1 在FreeBSD上建立一个功能完整的邮件服务器 第一部分:安装邮件服务器:postfix+vm-pop3d+openwebmail 欢迎大家转贴这个文章,但要保留下面的版权信息: 作者:llzqq 联系:llzqq@126.com 以下的安装在FreeBSD 5.2.1系统上完成 1.更新 ports # cvsup -gL 2 -h cvsup.freebsdchina.org /usr/share/examples/cvsup/ports-supfile 2.安装 openssl+ap