2.4. 以非 root 用户身份设置新实例
如果您没有 root 权限,您可以以非 root 用户身份执行 Directory Server 安装。使用此方法测试目录服务器和开发 LDAP 应用程序。但请注意,非 root 用户运行的实例存在限制,例如:
- 它们不支持简单网络管理协议(SNMP)。
- 它们只能使用大于或等于 1024 的端口。
2.4.1. 准备环境以以非 root 用户身份安装目录服务器 复制链接链接已复制到粘贴板!
作为非 root 用户,在您可以创建和管理目录服务器实例之前,您需要使用 dscreate ds-root 命令准备正确的环境。
前提条件
-
您以
root用户身份安装了 Directory Server 软件包。
流程
确保 PATH 变量中有
$HOME/bin。如果没有:在
~/.bash_profile文件中附加以下内容:PATH="$HOME/bin:$PATH"重新读取
~/bash_profile文件:$ source ~/.bash_profile
配置实例创建的环境以使用自定义位置:
$ dscreate ds-root $HOME/dsroot $HOME/bin此命令将标准安装路径替换为
$HOME/dsroot/,并在$HOME/bin/目录中创建标准目录服务器管理工具的副本。要使 shell 使用新路径:
清除缓存:
$ hash -r dscreate验证 shell 是否使用正确的命令路径:
$ which dscreate ~/bin/dscreate
对于 dscreate 命令,shell 现在使用 $HOME/bin/dscreate 而不是 /usr/bin/dscreate。
2.4.2. 以非 root 用户身份安装新实例 复制链接链接已复制到粘贴板!
要在没有 root 权限的情况下安装目录服务器,您可以使用交互式安装程序。安装后,Directory 服务器会在自定义位置创建一个实例,用户可以像常一样运行 dscreate、dsctl、dsconf 实用程序。
前提条件
- 为非 root 安装准备了环境。
-
您有
sudo权限来使用firewall-cmd工具,如果要从外部提供目录服务器实例。
流程
使用互动安装程序创建实例
启动交互式安装程序:
$ dscreate interactive回答交互式安装程序的问题。
要使用安装程序中大部分问题后面的方括号中显示的默认值,请按 Enter 键,而无需输入值。
注意在安装过程中,您必须选择实例端口和安全端口号 大于 1024 (例如 1389 和 1636)。否则,用户没有绑定到特权端口(1-1023)的权限。
Install Directory Server (interactive mode) =========================================== Non privileged user cannot use semanage, will not relabel ports or files. Selinux support will be disabled, continue? [yes]: yes Enter system's hostname [server.example.com]: Enter the instance name [server]: instance_name Enter port number [389]: 1389 Create self-signed certificate database [yes]: Enter secure port number [636]: 1636 Enter Directory Manager DN [cn=Directory Manager]: Enter the Directory Manager password: password Confirm the Directory Manager Password: password Choose whether mdb or bdb is used. [bdb]:注意默认情况下,Directory 服务器创建带有 Berkeley 数据库(BDB)的实例。要安装一个技术预览的 LMDB 实例,从 Directory Server 12.5 开始,请在下一步中设置
mdb和设置 LMDB 数据库大小。Enter the database suffix (or enter "none" to skip) [dc=server,dc=example,dc=com]: dc=example,dc=com Create sample entries in the suffix [no]: Create just the top suffix entry [no]: yes Do you want to start the instance after the installation? [yes]: Are you ready to install? [no]: yes注意您可以设置由
pwdhash生成的{algorithm}hash字符串来设置密码,而不是使用明文密码。例如:Enter the Directory Manager password: {PBKDF2-SHA512}100000$Haw7UDcBKUBejEjOTVHbiefT6cokHLo2$PeoP7W3B92Jzby7DGRkicovTN4LDGhnsC4EWCsv6crA2KA0Xn6rxPePX9UXhlM2utOPSQHeVpZzscNTx+fGi7A==
可选:如果要使目录服务器实例从外部可用:
在防火墙中打开端口:
# sudo firewall-cmd --permanent --add-port={1389/tcp,1636/tcp}重新载入防火墙配置:
# sudo firewall-cmd --reload
验证
运行
ldapsearch命令来测试用户可以连接到实例:$ ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com:1389 -b "dc=example,dc=com" -s sub -x "(objectclass=*)"