Final releasenotes for Fuel/Arno SR1
[genesis.git] / ceph.md
1 # Ceph Installation
2
3 ---
4 ## Intro
5 Ceph is used to build a storage system accross all machines
6
7 ## Architecture
8 We consider the following architecture
9
10     TODO: add schema (4 machines: ceph-admin, 3 ceph-nodes: opensteak9{2,3,4})
11
12 Networks:
13 ```
14 192.168.0.0/24 is the cluster network (use for storage)
15 192.168.1.0/24 is the management network (use for admin task)
16 ```
17
18
19 ## Ceph-admin machine preparation
20
21 This is done on an Ubuntu 14.04 64b server
22
23 ### Install ceph-deploy
24 ```bash
25 wget -q -O- 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | sudo apt-key add -
26 echo deb http://ceph.com/debian-firefly/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
27 sudo apt-get update && sudo apt-get install ceph-deploy
28 ```
29
30 ### Install ntp
31 ```bash
32 sudo apt-get install ntp
33 sudo service ntp restart
34 ```
35
36 ### Create a ceph user on each node (ceph-admin included)
37 ```bash
38 sudo useradd -d /home/ceph -m ceph
39 sudo passwd ceph
40 ```
41
42 Add sudo rights:
43 ```bash
44 echo "ceph ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/ceph
45 sudo chmod 0440 /etc/sudoers.d/ceph
46 ```
47
48 * *Note: if you think this can be a security treat, remove the ceph user from sudoers after installation is complete*
49
50 * *Note 2: the ceph documentation ask for this user: http://ceph.com/docs/master/rados/deployment/preflight-checklist/?highlight=sudoers*
51
52
53 ### Add each node in hosts file (ceph-admin included)
54 ```bash
55 sudo bash -c ' cat << EOF >> /etc/hosts
56 192.168.1.200 ceph-admin
57 192.168.1.92 opensteak92
58 192.168.1.93 opensteak93
59 192.168.1.94 opensteak94
60 EOF'
61 ```
62
63 ### Create and copy a passwordless ssh key to each node
64 ```bash
65 ssh-keygen
66 ssh-copy-id ceph@ceph-admin
67 ssh-copy-id ceph@opensteak92
68 ssh-copy-id ceph@opensteak93
69 ssh-copy-id ceph@opensteak94
70 ```
71
72 ### Create a .ssh/config file to connect automatically
73 ```bash
74 cat << EOF >> .ssh/config
75 Host ceph-admin
76   Hostname ceph-admin
77   User ceph
78 Host opensteak92
79   Hostname opensteak92
80   User ceph
81 Host opensteak93
82   Hostname opensteak93
83   User ceph
84 Host opensteak94
85   Hostname opensteak94
86   User ceph
87 EOF
88 ```
89
90 ## Ceph storage cluster
91 All these commands must be run inside the ceph-admin machine as a regular user
92
93 ### Prepare folder
94 ```bash
95 mkdir ceph-cluster
96 cd ceph-cluster/
97 ```
98
99 ### Deploy initial monitor on first node
100 ```bash
101 ceph-deploy new opensteak92
102 ```
103
104 ### Configure ceph
105 We set default pool size to 2 and public/cluster networks:
106
107 ```bash
108 cat << EOF >> ceph.conf
109 osd pool default size = 2
110 public network = 192.168.1.0/24
111 cluster network = 192.168.0.0/24
112 EOF
113 ```
114
115 ### Install ceph in all nodes
116 ```bash
117 ceph-deploy --username ceph install ceph-admin opensteak92 opensteak93 opensteak94
118 ```
119
120 ### Create initial monitor and gather the keys
121 ```bash
122 ceph-deploy --username ceph mon create-initial
123 ```
124
125 ### Create and add OSD
126 We will use hard disk (/dev/sdb) for storage: http://docs.ceph.com/docs/master/rados/deployment/ceph-deploy-osd/
127
128 ```bash
129 ceph-deploy --username ceph osd create opensteak93:sdb
130 ceph-deploy --username ceph osd create opensteak94:sdb
131 ```
132
133 ### Prepare all nodes to administer the cluster
134 Prepare all nodes with a ceph.conf and ceph.client.admin.keyring keyring so that it can administer the cluster:
135
136 ```bash
137 ceph-deploy admin ceph-admin opensteak92 opensteak93 opensteak94
138 sudo chmod +r /etc/ceph/ceph.client.admin.keyring
139 ```
140
141 ### Add a metadata server in first node
142 ```bash
143 ceph-deploy--username ceph mds create opensteak92
144 ```
145
146 ## Extend
147 ### Extend the OSD pool
148 We decided to extend OSD pool by adding the first node as well:
149
150 ```bash
151 ceph-deploy --username ceph osd create opensteak92:sdb
152 ```
153
154 ### Extend the monitors
155 In the same spirit, extend the monitor by adding the two last nodes and check the status
156 ```bash
157 ceph-deploy --username ceph mon create opensteak93 opensteak94
158 ceph quorum_status --format json-pretty
159 ```
160
161 ## Check status
162 ```bash
163 ceph health
164 ```
165
166 ## Create a file system
167 Check osd pools:
168 ```bash
169 ceph osd lspools
170 ```
171
172 I you don't have data and metadata pools, create it:
173 ```bash
174 ceph osd pool create cephfs_data 64
175 ceph osd pool create cephfs_metadata 64
176 ```
177
178 Then enable filesystem on the cephfs_data pool:
179 ```bash
180 ceph fs new cephfs cephfs_metadata cephfs_data
181 ```
182
183 And check again:
184 ```bash
185 ceph osd lspools
186 ```
187
188 Should produce:
189 ```bash
190 0 rbd,1 cephfs_data,2 cephfs_metadata,
191 ```
192
193 You can check as well with:
194 ```bash
195 $ ceph fs ls
196 name: cephfs, metadata pool: cephfs_metadata, data pools: [cephfs_data ]
197
198 $ ceph mds stat
199 e5: 1/1/1 up {0=opensteak92=up:active}
200 ```
201
202 ## Mount file system
203 For each node you want to mount ceph in **/mnt/cephfs/**, run:
204 ```bash
205 ssh opensteak9x "cat /etc/ceph/ceph.client.admin.keyring |grep key|awk '{print \$3}'|sudo tee /etc/ceph/ceph.client.admin.key"
206
207 ssh opensteak9x "sudo mkdir /mnt/cephfs"
208
209 ssh opensteak9x "echo '192.168.1.92:6789:/ /mnt/cephfs ceph name=admin,secretfile=/etc/ceph/ceph.client.admin.key,noatime 0 2' | sudo tee --append /etc/fstab && sudo mount /mnt/cephfs"
210 ```
211
212 This will add a line in fstab so the file system will automatically be mounted on boot.
213
214 ## TODO
215
216 * create a python/bash script that will install & check that the cluster is well configured (do all of this automatically)
217 * create a conf file that will be used by the above script to describe the architecture?