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
4.4 檢查網絡配置
openstack@localhost:~$ ip addr sh