伺服器搭建與管理(9-1)
阿新 • • 發佈:2018-11-08
1.伺服器:
192.168.9.106 admin
192.168.9.107 node1
192.168.9.108 node2
2.建立deph賬號並賦予sudo許可權:(3臺)
建立賬號
[[email protected] ~]# mkdir /app/userhome -p
[[email protected] ~]# useradd -d /app/userhome/deph deph
[[email protected] ~]# passwd deph
賦予sudo許可權
[[email protected] ~]# echo "deph ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/deph
[ [email protected] ~]# sudo chmod 0440 /etc/sudoers.d/deph
修改sudo配置檔案
#此處有一個小坑,使用不同賬戶,執行執行指令碼時候sudo經常會碰到 sudo: sorry, you must have a tty to run sudo這個情況,其實修改一下sudo的配置就好了,用vi /etc/sudoers (最好用visudo命令),註釋掉 Default requiretty 一行
[[email protected] ~]# visudo
#Default requiretty
3.建立admin主機和node節點的信任
#建立祕鑰
[[email protected] ~]# su - deph
[[email protected] ~]$ ssh-keygen
#分發公鑰
[[email protected] ~]$ ssh-copy-id [email protected]
[[email protected] ~]$ ssh-copy-id [email protected]
#修改 管理節點的~/.ssh/config檔案,ceph-deploy以便ceph-deploy能夠以您建立的使用者身份登入Ceph節點
[[email protected] ~]$ vim .ssh/config
Host admin
Hostname admin
User deph
Host node1
Hostname node1
User deph
Host node2
Hostname node2
User deph
#修改許可權
[[email protected] ~]$ cd .ssh/
[[email protected] .ssh]$ chmod 600 config
#測試登入ssh
[[email protected] ~]$ ssh node1
[[email protected] ~]$ exit
logout
Connection to node1 closed.
[[email protected] ~]$ ssh node2
[[email protected] ~]$ exit
logout
Connection to node2 closed