这次实验没有成功,两个Nodes,只有一个显示ok, 按照配置添加global环境到smb.conf文件,却导致smbd服务无法启动,具体原因未明。

CTDB+Samba实现高可用 ----一次失败的尝试_ctdb

 

具体命令记录如下:

安装samba

sudo apt-get update
sudo apt-get install samba
sudo service smbd status
cd /
sudo mkdir shareDoc
cd shareDoc/
sudo mkdir TestLog
sudo mkdir abc
sudo useradd log
sudo passwd log
sudo passwd ubuntu
sudo vim /etc/ssh/sshd_config
AllowUsers ubuntu aaa
ClientAliveInterval 60
ClientAliveCountMax 86400

Subsystem sftp internal-sftp
Match group sftp
ForceCommand internal-sftp
ChrootDirectory /shareDoc/TestLog

sudo groupadd sftp
sudo gpasswd -a aaa sftp

sudo chown aaa.aaa abc/
sudo chmod 700 abc/
sudo vim /etc/samba/smb.conf

[shareDoc]
comment = Folder for File Sharing
path = /shareDoc
public = no
writable = yes
valid users = ubuntu,aaa

sudo smbpasswd -a aaa
sudo service smbd restart
sudo service sshd restart
sudo service ssh restart

-----------------------------------------------------------------------

安装ctdb

sudo apt-get install ctdb
sudo vim /etc/services
add below to end:
ctdb  9999/tcp

sudo vim /etc/samba/smb.conf
[global]
clustering = yes
idmap backend = tdb2
private dir=/shareDoc/ctdb
fileid:mapping = fsname
#use mmap = no (smbd有这个导致无法启动)
nt acl support = yes
ea support = yes

---------------------

ctdb官网拿到的信息,测试不起作用
[global]
clustering = yes
ctdb:registry.tdb = yes
include = registry

---------------------------


sudo vim /shareDoc/ctdb/lock (也许需要自己创建这个lock文件)


sudo vim /etc/default/ctdb
CTDB_RECOVERY_LOCK="/shareDoc/ctdb/lock"
CTDB_PUBLIC_INTERFACE=eth0
CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
CTDB_MANAGES_SAMBA=yes
ulimit -n 10000
CTDB_NODES=/etc/ctdb/nodes
CTDB_LOGFILE=/var/log/ctdb/log.ctdb
CTDB_DEBUGLEVEL=2
CTDB_PUBLIC_NETWORK="172.30.2.10/24"
CTDB_PUBLIC_GATEWAY="172.30.2.1"

sudo vim /etc/ctdb/public_addresses
172.30.2.10/24
172.30.2.11/24

sudo vim /etc/ctdb/nodes
172.30.2.196
172.30.2.162

sudo mkdir /etc/ctdb/events.d
sudo vim /etc/ctdb/events.d/11.route
#!/bin/sh
. /etc/ctdb/functions
loadconfig ctdb
cmd="$1"
shift
case $cmd in
takeip)
# we ignore errors from this, as the route might be up already when we're grabbing
# a 2nd IP on this interface
/sbin/ip route add $CTDB_PUBLIC_NETWORK via $CTDB_PUBLIC_GATEWAY dev $1 2> /dev/null
;;
esac
exit 0

sudo chmod +x /etc/ctdb/events.d/11.route
sudo service ctdb restart
sudo service smbd restart
sudo ctdb status
sudo ctdb ip
sudo ctdb lvs status

AWS EC2测试,机器之间要打开防火墙,不然2个nodes无法通讯,具体端口如下,测试时我将内网段全部放开。

为ctdb放开防火墙限制
# firewall-cmd --add-port=4379/tcp

debug smb.conf 文件可以使用这个命令:testparm

CTDB+Samba实现高可用 ----一次失败的尝试_samba_02

 

ctdb log

CTDB+Samba实现高可用 ----一次失败的尝试_高可用_03