久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

ceph

共計(jì) 7136 個(gè)字符,預(yù)計(jì)需要花費(fèi) 18 分鐘才能閱讀完成。

這篇文章主要為大家展示了“ceph-deploy 中 new 模塊有什么用”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“ceph-deploy 中 new 模塊有什么用”這篇文章吧。

ceph-deploy 源碼分析——new 模塊

ceph-deploy 的 new.py 模塊是用來(lái)開(kāi)始部署新集群,創(chuàng)建 ceph.conf、ceph.mon.keyring 文件。

new 子命令格式如下

ceph-deploy new [-h] [--no-ssh-copykey] [--fsid FSID]
 [--cluster-network CLUSTER_NETWORK]
 [--public-network PUBLIC_NETWORK]
 MON [MON ...]

部署集群

make 函數(shù) priority 為 10,子命令設(shè)置的默認(rèn)函數(shù)為 new 函數(shù)。

@priority(10)
def make(parser):
  
 Start deploying a new cluster, and write a CLUSTER.conf and keyring for it.
  
 parser.add_argument(
  mon ,
 metavar= MON ,
 nargs= + ,
 help= initial monitor hostname, fqdn, or hostname:fqdn pair ,
 type=arg_validators.Hostname(),
 )
 parser.add_argument(
  --no-ssh-copykey ,
 dest= ssh_copykey ,
 action= store_false ,
 default=True,
 help= do not attempt to copy SSH keys ,
 )
 parser.add_argument(
  --fsid ,
 dest= fsid ,
 help= provide an alternate FSID for ceph.conf generation ,
 )
 parser.add_argument(
  --cluster-network ,
 help= specify the (internal) cluster network ,
 type=arg_validators.Subnet(),
 )
 parser.add_argument(
  --public-network ,
 help= specify the public network for a cluster ,
 type=arg_validators.Subnet(),
 )
 parser.set_defaults(
 func=new,
 )

部署新集群

new 函數(shù)開(kāi)始部署新集群

創(chuàng)建 ceph.conf 文件, 寫(xiě)入 [global]fsid、mon_initial_members、mon_host、auth_cluster_required、auth_service_required、auth_client_required,如果參數(shù)中有 public_network、cluster_network 寫(xiě)入配置文件

調(diào)用 new_mon_keyring 函數(shù)創(chuàng)建 ceph.mon.keyring 文件

def new(args):
 if args.ceph_conf:
 raise RuntimeError(will not create a Ceph conf file if attemtping to re-use with `--ceph-conf` flag)
 LOG.debug(Creating new cluster named %s , args.cluster)
 #  生成配置
 cfg = conf.ceph.CephConf()
 cfg.add_section(global)
 #  獲取參數(shù)中的額 fsid 或者自動(dòng)生成
 fsid = args.fsid or uuid.uuid4()
 cfg.set(global ,  fsid , str(fsid))
 # if networks were passed in, lets set them in the
 # global section
 if args.public_network:
 cfg.set(global ,  public network , str(args.public_network))
 if args.cluster_network:
 cfg.set(global ,  cluster network , str(args.cluster_network))
 # mon 節(jié)點(diǎn)
 mon_initial_members = []
 # mon 主機(jī)
 mon_host = []
 #  循環(huán) host
 for (name, host) in mon_hosts(args.mon):
 # Try to ensure we can ssh in properly before anything else
 # ssh key copy
 if args.ssh_copykey:
 ssh_copy_keys(host, args.username)
 # Now get the non-local IPs from the remote node
 #  連接遠(yuǎn)程主機(jī)
 distro = hosts.get(host, username=args.username)
 #  獲取主機(jī)的 IP 地址
 remote_ips = net.ip_addresses(distro.conn)
 # custom cluster names on sysvinit hosts won t work
 if distro.init ==  sysvinit  and args.cluster !=  ceph :
 LOG.error(custom cluster names are not supported on sysvinit hosts)
 raise exc.ClusterNameError(
  host %s does not support custom cluster names  % host
 )
 distro.conn.exit()
 # Validate subnets if we received any
 if args.public_network or args.cluster_network:
 #  校驗(yàn) IP 地址
 validate_host_ip(remote_ips, [args.public_network, args.cluster_network])
 # Pick the IP that matches the public cluster (if we were told to do
 # so) otherwise pick the first, non-local IP
 LOG.debug(Resolving host %s , host)
 if args.public_network:
 ip = get_public_network_ip(remote_ips, args.public_network)
 else:
 ip = net.get_nonlocal_ip(host)
 LOG.debug(Monitor %s at %s , name, ip)
 mon_initial_members.append(name)
 try:
 socket.inet_pton(socket.AF_INET6, ip)
 mon_host.append([  + ip + ] )
 LOG.info(Monitors are IPv6, binding Messenger traffic on IPv6)
 cfg.set(global ,  ms bind ipv6 ,  true)
 except socket.error:
 mon_host.append(ip)
 LOG.debug(Monitor initial members are %s , mon_initial_members)
 LOG.debug(Monitor addrs are %s , mon_host)
 # mon_initial_members  有多個(gè)的話,中間用空格隔開(kāi)
 cfg.set(global ,  mon initial members ,  ,  .join(mon_initial_members))
 # no spaces here, see http://tracker.newdream.net/issues/3145
 # mon_host  有多個(gè)的話,中間沒(méi)有空格
 cfg.set(global ,  mon host ,  , .join(mon_host))
 # override undesirable defaults, needed until bobtail
 # http://tracker.ceph.com/issues/6788
 cfg.set(global ,  auth cluster required ,  cephx)
 cfg.set(global ,  auth service required ,  cephx)
 cfg.set(global ,  auth client required ,  cephx)
 path =  {name}.conf .format(
 name=args.cluster,
 )
 #  創(chuàng)建 mon keyring
 new_mon_keyring(args)
 LOG.debug(Writing initial config to %s... , path)
 tmp =  %s.tmp  % path
 with open(tmp,  w) as f:
 #  保存 ceph 配置文件
 cfg.write(f)
 try:
 os.rename(tmp, path)
 except OSError as e:
 if e.errno == errno.EEXIST:
 raise exc.ClusterExistsError(path)
 else:
 raise

 

注意:
mon_initial_members 有多個(gè)的話,中間用空格隔開(kāi)
mon_host 有多個(gè)的話,中間沒(méi)有空格

創(chuàng)建 ceph.mon.keyring 文件

new_mon_keyring 函數(shù)創(chuàng)建 ceph.mon.keyring 文件

def new_mon_keyring(args):
 LOG.debug(Creating a random mon key...)
 mon_keyring =  [mon.]\nkey = %s\ncaps mon = allow *\n  % generate_auth_key()
 keypath =  {name}.mon.keyring .format(
 name=args.cluster,
 )
 oldmask = os.umask(0o77)
 LOG.debug(Writing monitor keyring to %s... , keypath)
 try:
 tmp =  %s.tmp  % keypath
 with open(tmp,  w , 0o600) as f:
 f.write(mon_keyring)
 try:
 os.rename(tmp, keypath)
 except OSError as e:
 if e.errno == errno.EEXIST:
 raise exc.ClusterExistsError(keypath)
 else:
 raise
 finally:
 os.umask(oldmask)

手工部署集群

以 ceph-deploy 部署集群:ceph-deploy new ceph-231 為例,對(duì)應(yīng)的手工操作。

獲取 ip 地址

執(zhí)行以下命令,通過(guò)正則表達(dá)式獲取 IP 地址 192.168.217.231

[root@ceph-231 ceph-cluster]# /usr/sbin/ip link show
1: lo:  LOOPBACK,UP,LOWER_UP  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:  BROADCAST,MULTICAST,UP,LOWER_UP  mtu 1500 qdisc pfifo_fast master ovs-system state UP mode DEFAULT qlen 1000
 link/ether 02:03:e7:fc:dc:36 brd ff:ff:ff:ff:ff:ff
3: ovs-system:  BROADCAST,MULTICAST  mtu 1500 qdisc noop state DOWN mode DEFAULT
 link/ether 86:f4:14:e3:1b:b2 brd ff:ff:ff:ff:ff:ff
4: xenbr0:  BROADCAST,MULTICAST,UP,LOWER_UP  mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT
 link/ether 02:03:e7:fc:dc:36 brd ff:ff:ff:ff:ff:ff
[root@ceph-231 ceph-cluster]# /usr/sbin/ip addr show
1: lo:  LOOPBACK,UP,LOWER_UP  mtu 65536 qdisc noqueue state UNKNOWN
 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
 inet 127.0.0.1/8 scope host lo
 valid_lft forever preferred_lft forever
2: eth0:  BROADCAST,MULTICAST,UP,LOWER_UP  mtu 1500 qdisc pfifo_fast master ovs-system state UP qlen 1000
 link/ether 02:03:e7:fc:dc:36 brd ff:ff:ff:ff:ff:ff
3: ovs-system:  BROADCAST,MULTICAST  mtu 1500 qdisc noop state DOWN
 link/ether 86:f4:14:e3:1b:b2 brd ff:ff:ff:ff:ff:ff
4: xenbr0:  BROADCAST,MULTICAST,UP,LOWER_UP  mtu 1500 qdisc noqueue state UNKNOWN
 link/ether 02:03:e7:fc:dc:36 brd ff:ff:ff:ff:ff:ff
 inet 192.168.217.231/24 brd 192.168.217.255 scope global xenbr0
 valid_lft forever preferred_lft forever

創(chuàng)建 ceph.conf

[root@ceph-231 ceph-cluster]# vi ceph.conf
[global]
fsid = a3b9b0aa-01ab-4e1b-bba3-6f5317b0795b
mon_initial_members = ceph-231
mon_host = 192.168.217.231
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
public_network = 192.168.217.231

創(chuàng)建 ceph.mon.keyring

可以通過(guò) ceph-authtool 命令生成

[root@ceph-231 ceph-cluster]# ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon  allow * 
creating /tmp/ceph.mon.keyring
[root@ceph-231 ~]# cat /tmp/ceph.mon.keyring
[mon.]
 key = AQCzxEhZC7tICxAAuHK5GipD96enMuhv82CCLg==
 caps mon =  allow *

將 /tmp/ceph.mon.keyring 內(nèi)容復(fù)制到 ceph.mon.keyring

[root@ceph-231 ceph-cluster]# vi ceph.mon.keyring
[mon.]
key = AQCzxEhZC7tICxAAuHK5GipD96enMuhv82CCLg==
caps mon = allow

以上是“ceph-deploy 中 new 模塊有什么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-16發(fā)表,共計(jì)7136字。
轉(zhuǎn)載說(shuō)明:除特殊說(shuō)明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請(qǐng)注明出處。
評(píng)論(沒(méi)有評(píng)論)
主站蜘蛛池模板: 陆丰市| 屏边| 辽源市| 讷河市| 孙吴县| 定安县| 扶沟县| 静宁县| 道孚县| 临沧市| 华容县| 宜丰县| 晋中市| 青川县| 洛扎县| 古田县| 定西市| 遂溪县| 三河市| 安阳市| 临潭县| 玛多县| 武安市| 沈丘县| 安阳县| 淄博市| 武夷山市| 随州市| 北流市| 甘德县| 修文县| 宁强县| 洛浦县| 易门县| 勐海县| 湖州市| 大港区| 基隆市| 双流县| 绍兴市| 赤水市|