OpenStack云计算口袋书-第一章-开始OpenStack之旅(二)

2、操做系统配置ubuntu

1. 添加用户安全

root@localhost:~# useradd openstack -m -d /home/openstack -s /bin/bashbash

2. 添加特权用户网络

在口袋书中都是使用openstack非特权用户操做的,这也比较符合生产环境中的安全策略。ide

root@localhost:~# echo "openstack ALL=(ALL: ALL) ALL" > \oop

/etc/sudoers.d/xiaoyuwang_sudoers操作系统

为了操做方便我这里为openstack用户添加了免密码执行特权命令。注意这只建议在实验环境中使用。3d

root@localhost:~# echo "openstack ALL=(ALL)NOPASSWD: ALL" > \rest

/etc/sudoers.d/xiaoyuwang_sudoersblog

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

Image

4.4 检查网络配置

openstack@localhost:~$ ip addr sh

2013-09-14_17-29-17

相关文章
相关标签/搜索