二、操作系统配置
1. 添加用户
root@localhost:~# useradd openstack -m -d /home/openstack -s /bin/bash
2. 添加特权用户
在口袋书中都是使用openstack非特权用户操作的,这也比较符合生产环境中的安全策略。
root@localhost:~# echo "openstack ALL=(ALL: ALL) ALL" > \
/etc/sudoers.d/xiaoyuwang_sudoers
为了操作方便我这里为openstack用户添加了免密码执行特权命令。注意这只建议在实验环境中使用。
root@localhost:~# echo "openstack ALL=(ALL)NOPASSWD: ALL" > \
/etc/sudoers.d/xiaoyuwang_sudoers
root@localhost:
3. 配置apt-get 下载源
3.1 配置源文件变量
openstack@localhost:~$ echo ${SOURCE_CONF:="/etc/apt/sources.list"}
/etc/apt/sources.list
3.2 修改前备份
openstack@localhost:~$ sudo cp -av ${SOURCE_CONF}{,.bak}
`/etc/apt/sources.list' -> `/etc/apt/sources.list
3.3 建立模板源文件
这里以debian.ustc.edu.cn/ubuntu这个源为例子
openstack@localhost:~$ cat <<EOF |sudo tee ${SOURCE_CONF}
deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse
deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse
END
3.4.1 可根据实际需要修改这个模板
3.4.1.1 使用mirrors.163.com
#sed -i 's/debian.ustc.edu.cn/mirrors.163.com/g' ${SOURCE_CONF}
4. 网络配置
4.1 配置前备份网卡配置文件
openstack@localhost:~$ sudo cp -av /etc/network/interfaces{,.origin}
`/etc/network/interfaces' -> `/etc/network/interfaces.origin'
openstack@localhost:~$
4.2 重写网卡配置文件
openstack@localhost:~$ sed 's/^\t//g' <<EOF |sudo tee /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
# Public Interface
auto eth1
iface eth1 inet static
address 172.16.0.1
netmask 255.255.0.0
network 172.16.0.0
broadcast 172.16.255.255
# Private Interface
auto eth2
iface eth2 inet manual
up ifconfig eth2 up
EOF
4.3 重启动网络,使配置生效
openstack@localhost:~$ sudo /etc/init.d/networking restart
4.4 检查网络配置
openstack@localhost:~$ ip addr sh
本文转自xiaoyuwang 51CTO博客,原文链接:http://blog.51cto.com/wangxiaoyu/1297730,如需转载请自行联系原作者