OpenStack雲計算口袋書-第一章-開始OpenStack之旅(二)

二、操作系統配置

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

Image

4.4 檢查網絡配置

openstack@localhost:~$ ip addr sh

2013-09-14_17-29-17

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章