Ceph安装笔记

操作系统Centos7.9 

192.168.186.201 192.168.187.201      #186为Publick

192.168.186.202 192.168.187.202 

192.168.186.203 192.168.187.203 

一.修改Hosts文件

[root@node-1 ~] vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.187.201 node-1    #添加
192.168.187.202 node-2    #添加
192.168.187.203 node-3    #添加

[root@node-1 ~] scp /etc/hosts node-2:/etc/    #将hosts配置文件发给node-2
[root@node-1 ~] scp /etc/hosts node-3:/etc/    #将hosts配置文件发给node-3

二.配置无密码登录

Node-1:配置

[root@node-1 ~] ssh-ketgen

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RNd/EfeRh3t7C73PD//lsUVTQpf84hKM5Dy3CdWj6iQ root@node-1
The key's randomart image is:
+---[RSA 2048]----+
|        . .. .o+*|
|       . .. o.+*=|
|        .+ + o.o*|
|       .  * = +.=|
|        S  = =.=o|
|        E o +..+o|
|         +   .o.*|
|          .    B=| 
|               .@|
+----[SHA256]-----+

[root@node-1 ~] ssh-copy-id -i /root/.ssh/id_rsa.pub node-2   #会输入node-2密码
[root@node-1 ~] ssh-copy-id -i /root/.ssh/id_rsa.pub node-3   #会输入node-3密码

三.安全设置

1.关闭Selinux 所有节点
[root@node-1 ~] vi /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled     #修改位置

[root@node-1 ~] setenforce 0 #临时关闭
[root@node-1 ~] getenforce   #查看状态
Permissiv

2.关闭防火墙
[root@node-1 ~] systemctl disable firewalld    #禁止开机自启
[root@node-1 ~] systemctl stop firewalld       #关闭防火墙
[root@node-1 ~] firewall-cmd --list-all        #查看防火墙状态
FirewallD is not running

四.NTP设置

所有节点执行
[root@node-3 ~] cd /etc/yum.repos.d/
[root@node-3 yum.repos.d] rm -rf *  
[root@node-1 yum.repos.d]  curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@node-1 yum.repos.d] yum clean all && yum makecache #清除缓存
[root@node-1 yum.repos.d] yum install ntp -y     #安装NTP
[root@node-1 yum.repos.d] systemctl restart ntpd #启动NTP服务
[root@node-1 yum.repos.d] systemctl enable ntpd  #设置开机自启动
[root@node-1 yum.repos.d] ntpq -pn               #查看NTP状态

[root@node-2 ~] crontab -l 
[root@node-2 ~] crontab -e 编辑,每分钟同步一次时间插入下边字段
*/1 * * * * /usr/sbin/ntpdate node-1;/sbin/hwclock -w


下边操作node-2 node-3执行  下边有备注#添加字段
[root@node-3 yum.repos.d] vi /etc/ntp.conf

# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).

driftfile /var/lib/ntp/drift

# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1 
restrict ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server node-1 iburst         #####添加位置
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst

#broadcast 192.168.1.255 autokey    # broadcast server
#broadcastclient            # broadcast client
#broadcast 224.0.1.1 autokey        # multicast server
#multicastclient 224.0.1.1        # multicast client
#manycastserver 239.255.254.254        # manycast server
#manycastclient 239.255.254.254 autokey # manycast client

# Enable public key cryptography.
#crypto

includefile /etc/ntp/crypto/pw

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography. 
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8

# Enable writing of statistics records.
#statistics clockstats cryptostats loopstats peerstats

# Disable the monitoring facility to prevent amplification attacks using ntpdc
# monlist command when default restrict does not include the noquery flag. See
# CVE-2013-5211 for more details.
# Note: Monitoring will not be disabled with the limited restriction flag.
disable monitor

五.配置YUM源

所有节点执行
[root@node-3 ~] cd /etc/yum.repos.d
[root@node-3 ~] rm -rf *
[root@node-3 ~] curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@node-3 ~]curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
[root@node-3 ~] vi /etc/yum.repos.d/ceph.repo    #插入下边全部

[norch]     #起一个名字
name=norch
baseurl=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/noarch/
enabled=1
gpgcheck=0

[x86_64]
name=x86 64
baseurl=https://mirrors.aliyun.com/ceph/rpm-nautilus/el7/x86_64/
enabled=1
gpgcheck=0


[root@node-1 ] yum clean all && yum makecache #清除缓存
[root@node-1 ] yum update
[root@node-1 ] scp ceph.repo node-2:/etc/yum.repos.d/
[root@node-1 ] scp ceph.repo node-3:/etc/yum.repos.d/

六.安装Ceph-deploy

Node1执行
[root@node-1 yum.repos.d]# yum install python-setuptools ceph-deploy #安装核心软件
[root@node-1 yum.repos.d]# ceph-deploy --version #查看版本
2.0.1

七.安装Mon节点

重置集群  :此步掠过不用执行
如果安装失败或者重新安装时执行:
ceph-deploy purge {ceph-node} [{ceph-node}]
ceph-deploy purgedata  {ceph-node} [{ceph-node}]
ceph-deploy forgetkeys
rm ceph.*
安装相关软件

Node1执行:
[root@node-1 yum.repos.d]#  cd /opt/
[root@node-1 opt]#  mkdir my-cluster
[root@node-1 opt]#  cd my-cluster/
[root@node-1 my-cluster]#  ceph-deploy new --public-network 192.168.187.0/24 --cluster-network 192.168.199.0/24 node-1
 #公共网络是外部访问集群时使用的,集群网络时内部同步使用的
所有节点执行:
ll会生成三个文件conf配置文件 log 日志  keyring 身份验证
[root@node-1 my-cluster]# yum install ceph ceph-mon ceph-mgr ceph-mds ceph-radosgw -y #安装核心软件包
Mon初始化及安装Mgr
节点1执行

[root@node-1] ceph-deploy mon create-initial    #初始化mon 

[root@node-1] ceph-deploy admin node-1 node-2 node-3 #推送最新配置到所有节点

[root@node-1] ceph -s  #查看ceph最新状态

 cluster:
    id:     e9a90625-4707-4b6b-b52f-661512ea831d
    health: HEALTH_WARN
            mon is allowing insecure global_id reclaim  #mon允许不安全的global_id回收
 
  services:
    mon: 1 daemons, quorum node-1 (age 2m)
    mgr: no daemons active
    osd: 0 osds: 0 up, 0 in
 
  data:
    pools:   0 pools, 0 pgs
    objects: 0 objects, 0 B
    usage:   0 B used, 0 B / 0 B avail
    pgs:  

[root@node-1] ceph config set mon auth_allow_insecure_global_id_reclaim fales

[root@node-1] ceph -s
 cluster:
    id:     e9a90625-4707-4b6b-b52f-661512ea831d
    health: HEALTH_OK
 
  services:
    mon: 1 daemons, quorum node-1 (age 3m)
    mgr: no daemons active
    osd: 0 osds: 0 up, 0 in
 
  data:
    pools:   0 pools, 0 pgs
    objects: 0 objects, 0 B
    usage:   0 B used, 0 B / 0 B avail
    pgs:     

[root@node-1] ceph-deploy mgr create node-1 #安装mgr监控

[root@node-1] ceph -s 
 cluster:
    id:     e9a90625-4707-4b6b-b52f-661512ea831d
    health: HEALTH_WARN
            OSD count 0 < osd_pool_default_size 3
 
  services:
    mon: 1 daemons, quorum node-1 (age 6m)
    mgr: node-1(active, since 55s) #查看已经成功安装
    osd: 0 osds: 0 up, 0 in
 
  data:
    pools:   0 pools, 0 pgs
    objects: 0 objects, 0 B
    usage:   0 B used, 0 B / 0 B avail
    pgs:        

八.部署OSD节点

你可能感兴趣的:(ceph,ssh,linux)