ceph安装记录

分类:Linux, 发布于 2020-03-18 14:58:11  浏览(670)

sudo vi /etc/network/interfaces
sudo vi /etc/apt/sources.list
sudo apt update
sudo vi /etc/hosts
sudo apt install ntp
sudo apt install python
sudo useradd -d /home/cephuser -m cephuser 
sudo passwd cephuser 
echo "cephuser ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/cephuser 
sudo chmod 0440 /etc/sudoers.d/cephuser
wget -q -O- 'http://mirrors.163.com/ceph/keys/release.asc' | sudo apt-key add -
echo deb http://mirrors.163.com/ceph/debian-luminous/ $(lsb_release -sc) main | sudo tee /etc/apt/sources.list.d/ceph.list
sudo apt-get update && sudo apt-get install -y ceph-deploy
ssh-keygen
vi .ssh/config
mkdir cluster
sudo apt install
sudo apt upgrade
ssh-copy-id cephuser@mon
ssh-copy-id cephuser@node1
 ssh-copy-id cephuser@node2
cd cluster/
ceph-deploy new mon
export CEPH_DEPLOY_REPO_URL=http://mirrors.163.com/ceph/debian-luminous/
export CEPH_DEPLOY_GPG_URL=http://mirrors.163.com/ceph/keys/release.asc
ceph-deploy install mon node1 node2
sudo apt update
ceph-deploy install mon node1 node2
ceph-deploy mon create-initial
ceph-deploy disk zap node1:sdb
ceph-deploy disk zap node1 /dev/sdb
ceph-deploy disk zap node2 /dev/sdb
ceph-deploy disk zap mon /dev/sdb
ceph-deploy osd create node1:sdb
ceph-deploy osd create --data /dev/sdb node1
ceph-deploy osd create --data /dev/sdb node2
ceph-deploy osd create --data /dev/sdb mon
ceph-deploy admin mon node1 node2
sudo chmod +r /etc/ceph/ceph.client.admin.keyring 
ceph health
ceph-deploy mgr create mon:mon_mgr
ceph health
ceph -s


flask 开发 ceph控制系统模块安装

分类:Python, 发布于 2020-03-18 14:54:40  浏览(579)

pip3 install ansible ceph redis flask flask-moment flask-sqlalchemy flask-mail pycryptodome gunicorn gevent eventlet monkey pprint
sudo apt install python3-rados python3-rbd sshpass


PyCharm在SSH开发flask时启动后url显示127.0.0.1的问题

分类:Python, 发布于 2020-03-10 23:30:24  浏览(545)

run-Edit-Configuration 中,找到Additinal options栏 :手动写入 --host=x.x.x.x --port=xxxx

python之Base64添加\n处理

分类:Python, 发布于 2020-03-08 00:46:16  浏览(549)

base64.decodebytes会默认添加\n

而base64.b64encode方法不添加\n

PHP json_last_error() 报错int(3)的解决办法

分类:PHP, 发布于 2020-03-07 23:56:41  浏览(539)

在decode前执行:

$result =  preg_replace('/[\x00-\x1F\x80-\x9F]/u', '', trim($result));


Ansible API 2.9.5 给host配置密码访问

分类:Python, 发布于 2020-03-05 15:05:43  浏览(574)

直接上例子,顺便Mark备注。

import json
import shutil
from ansible.module_utils.common.collections import ImmutableDict
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from ansible.playbook.play import Play
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.plugins.callback import CallbackBase
from ansible import context
import ansible.constants as C
class ResultCallback(CallbackBase):
    def v2_runner_on_ok(self, result, **kwargs):
        host = result._host
        print(json.dumps({host.name: result._result}, indent=4))
    def v2_runner_on_failed(self, result, ignore_errors=False):
        print('FAILED! => task: %s; message: %s', result._task, self._dump_results(result._result))
    def v2_runner_on_unreachable(self, result):
        print('UNREACHABLE! =>  message: %s', result._task, self._dump_results(result._result))
context.CLIARGS = ImmutableDict(connection='ssh',module_path=None, verbosity=5, forks=10, become=None, become_method=None, become_user=None, check=False, diff=False)
loader = DataLoader() # Takes care of finding and reading yaml, json and ini files
#passwords = dict(vault_pass='123456')
passwords = {}
inventory = InventoryManager(loader=loader, sources=None)
results_callback = ResultCallback()
host_list = ['192.168.3.6','192.168.3.7']
inventory.add_group('node')
for h in host_list:
    inventory.add_host(host=h, group='node')
#inventory = InventoryManager(loader=loader, sources='inventory_file')
host = inventory.get_host(hostname='192.168.3.6')
variable_manager = VariableManager(loader=loader, inventory=inventory)
#print(host_vars)
host.set_variable('ansible_ssh_user', 'user')
host.set_variable('ansible_ssh_pass', 'pass')
play_source =  dict(
        name = "node1",
        hosts = '192.168.3.6',
        gather_facts = 'no',
        tasks = [
            dict(action=dict(module='shell', args='whoami'), register='shell_out')
            #dict(action=dict(module='debug', args=dict(msg='{{shell_out.stdout}}')))
         ]
    )
play = Play().load(play_source, variable_manager=variable_manager, loader=loader)
tqm = None
try:
    tqm = TaskQueueManager(
              inventory=inventory,
              variable_manager=variable_manager,
              loader=loader,
              passwords=passwords,
              stdout_callback=results_callback,  # Use our custom callback instead of the ``default`` callback plugin, which prints to stdout
          )
    result = tqm.run(play)
finally:
    if tqm is not None:
        tqm.cleanup()
    shutil.rmtree(C.DEFAULT_LOCAL_TMP, True)

这种方式需要服务安装sshpass,当然更推荐使用免密登录