CentOS 6.3上部署Ceph(2)

除客户端外,其它的节点都需一个配置文件ceph.conf,并需要是完全一样的这个文件要位于/etc/ceph下面,如果在./configure时没有修改prefix的话,则应该是在/usr/local/etc/ceph下。

#cp ./src/sample.* /usr/local/etc/ceph/

#mv /usr/local/etc/ceph/sample.ceph.conf /usr/local/etc/ceph/ceph.conf

#mv /usr/local/etc/ceph/sample.fetch_config /usr/local/etc/ceph/fetch_config

#cp ./src/init-ceph /etc/init.d/ceph

#mkdir /var/log/ceph //存放log,现在ceph自己还不自动建这个目录

注:

①部署每台服务器,主要修改的就是/usr/local/etc/ceph/下的两个文件ceph.conf(ceph集群配置文件)和fetch_config(同步脚本,用于同步各节点的ceph.conf文件,具体方法是scp远程拷贝,但我发现没啥用,所以后来自行写了个脚本)。

②针对osd,除了要加载btrfs模块,还要安装btrfs-progs(#yum install btrfs-progs),这样才有mkfs.btrfs命令。另外就是要在数据节点osd上创建分区或逻辑卷供ceph使用:可以是磁盘分区(如/dev/sda2),也可以是逻辑卷(如/dev/mapper/VolGroup-lv_ceph),只要与配置文件ceph.conf中写的一致即可。具体创建分区或逻辑卷的方法请自行google。

[root@ceph_mds ceph]# cat /usr/local/etc/ceph/ceph.conf
;
; Sample ceph ceph.conf file.
;
; This file defines cluster membership, the various locations
; that Ceph stores data, and any other runtime options.

; If a 'host' is defined for a daemon, the init.d start/stop script will
; verify that it matches the hostname (or else ignore it). If it is
; not defined, it is assumed that the daemon is intended to start on
; the current host (e.g., in a setup with a startup.conf on each
; node).

; The variables $type, $id and $name are available to usein paths
; $type = The type of daemon, possible values: mon, mdsand osd
; $id = The ID of the daemon, for mon.alpha, $id will be alpha
; $name = $type.$id

; For example:
; osd.0
; $type = osd
; $id = 0
; $name = osd.0

; mon.beta
; $type = mon
; $id = beta
; $name = mon.beta

; global
[global]
; enable secure authentication
; auth supported = cephx

; allow ourselves to open a lot of files
max open files = 131072

; set log file
log file = /var/log/ceph/$name.log
; log_to_syslog = true ; uncomment this line to log to syslog

; set up pid files
pid file = /var/run/ceph/$name.pid

; If you want to run a IPv6 cluster, set this to true. Dual-stack isn't possible
;ms bind ipv6 = true

; monitors
; You need at least one. You need at least three if you want to
; tolerate any node failures. Always create an odd number.
[mon]
mon data = /data/mon$id

; If you are using for example the RADOS Gateway and want to have your newly created
; pools a higher replication level, you can set a default
;osd pool default size = 3

; You can also specify a CRUSH rule for new pools
; Wiki:
;osd pool default crush rule = 0

; Timing is critical for monitors, but if you want to allow the clocks to drift a
; bit more, you can specify the max drift.
;mon clock drift allowed = 1

; Tell the monitor to backoff from this warning for 30 seconds
;mon clock drift warn backoff = 30

; logging, for debugging monitor crashes, in order of
; their likelihood of being helpful :)
debug ms = 1
;debug mon = 20
;debug paxos = 20
;debug auth = 20

[mon.0]
host = ceph_mds
mon addr = 222.31.76.178:6789

; mds
; You need at least one. Define two to get a standby.
[mds]
; where the mds keeps it'
s secret encryption keys
keyring = /data/keyring.$name

; mds logging to debug issues.
;debug ms = 1
;debug mds = 20

[mds.alpha]
host = ceph_mds

; osd
; You need at least one. Two if you want data to be replicated.
; Define as many as you like.
[osd]
sudo = true
; This is where the osd expects its data
osd data = /data/osd$id

; Ideally, make the journal a separate disk or partition.
; 1-10GB should be enough; moreif you have fastor many
; disks. You can use a file under the osd data dir if need be
; (e.g. /data/$name/journal), but it will be slower than a
; separate disk or partition.
; This is an example of a file-based journal.
osd journal = /data/$name/journal
osd journal size = 1000 ; journal size, in megabytes

; If you want to run the journal on a tmpfs (don't), disable DirectIO
;journal dio = false

; You can change the number of recovery operations to speed up recovery
; or slow it down if your machines can'
t handle it
; osd recovery max active = 3

; osd logging to debug osd issues, in order of likelihood of being
; helpful
;debug ms = 1
;debug osd = 20
;debug filestore = 20
;debug journal = 20


; ### The below options only apply if you're using mkcephfs
; ### and the devs options
; The filesystem used on the volumes
osd mkfs type = btrfs
; If you want to specify some other mount options, you can do so.
; for other filesystems use 'osd mount options $fstype'
osd mount options btrfs = rw,noatime
; The options used to format the filesystem via mkfs.$fstype
; for other filesystems use 'osd mkfs options $fstype'
; osd mkfs options btrfs =


[osd.0]
host = ceph_osd0

; if 'devs' is not specified, you're responsible for
; setting up the '
osd data' dir.
btrfs devs = /dev/mapper/VolGroup-lv_ceph

[osd.1]
host = ceph_osd1

btrfs devs = /dev/mapper/VolGroup-lv_ceph

[osd.2]
host = ceph_osd2

btrfs devs = /dev/mapper/VolGroup-lv_ceph

 

 

4. 配置网络

① 修改各节点的hostname,并能够通过hostname来互相访问

参考:

修改/etc/sysconfig/network文件以重定义自己的hostname;

修改/etc/hosts文件以标识其他节点的hostname与IP的映射关系;

重启主机后用hostname命令查看验证。

② 各节点能够ssh互相访问而不输入密码

原理就是公私钥机制,我要访问别人,那么就要把自己的公钥先发给别人,对方就能通过我的公钥验证我的身份。

例:在甲节点执行如下命令

#ssh-keygen –d

该命令会在"~/.ssh"下面生成几个文件,这里有用的是id_dsa.pub,为该节点(甲)的公钥,然后把里面的内容添加到对方节点(乙) "~/.ssh/"目录下的authorized_keys文件中,如果没有则创建一个,这样就从甲节点不需要密码ssh登陆到乙上了.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/b6c61076a9948c770888eca0433efb74.html