1. 程式人生 > 實用技巧 >搭建OpenStack基礎服務

搭建OpenStack基礎服務

一、OpenStack硬體需求

OpenStack架構需要至少2個(主機)節點來啟動基礎服務。

控制器

控制節點上執行身份認證服務,映象服務,計算服務的管理部分,網路服務的管理部分,多種網路代理以及儀表板。也需要包含一些支援服務,例如:SQL資料庫,term:訊息佇列and NTP服務。

計算

計算節點上執行計算服務中管理例項的管理程式部分。預設情況下,計算服務使用 KVM

可選的,可以在計算節點上執行部分塊儲存,物件儲存,Orchestration 和 Telemetry 服務

計算節點上需要至少兩塊網絡卡。

塊裝置儲存

可選的塊儲存節點上包含了磁碟,塊儲存服務和共享檔案系統會向例項提供這些磁碟

為了簡單起見,計算節點和本節點之間的服務流量使用管理網路。生產環境中應該部署一個單獨的儲存網路以增強效能和安全。

可以部署超過一個塊儲存節點。每個塊儲存節點要求至少一塊網絡卡。

物件儲存

可選的物件儲存節點包含了磁碟。物件儲存服務用這些磁碟來儲存賬號,容器和物件。

為了簡單起見,計算節點和本節點之間的服務流量使用管理網路。生產環境中應該部署一個單獨的儲存網路以增強效能和安全。

這個服務要求兩個節點。每個節點要求最少一塊網絡卡。可以部署超過兩個物件儲存節點

網路

公有網路

公有網路選項使用盡可能簡單的方式主要通過layer-2(網橋/交換機)服務以及VLAN網路的分割來部署OpenStack網路服務。本質上,它建立虛擬網路到物理網路的橋,依靠物理網路基礎設施提供layer-3服務(路由)

私有網路

私有網路選項擴充套件了公有網路選項,增加了啟用self-service`覆蓋分段方法的layer-3(路由)服務

二、OpenStack搭建環境準備

注:提前已經制作好openstack模板機,並匯出檔案openstack.ova

1. 以vmware station方式開啟openstack.ova,匯入成功後如圖所示

2. 編輯虛擬機器設定

設定虛擬化

設定iso檔案

3. 克隆虛擬機器

設定完成後,克隆一臺機器

啟動虛擬機器,修改克隆機器的ip地址,主機名和host解析

[root@controller ~]# ifconfig eth0
eth0: flags=4163
<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.0.11 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::20c:29ff:fe73:28a2 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:73:28:a2 txqueuelen 1000 (Ethernet) RX packets 173 bytes 16421 (16.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 140 bytes 15393 (15.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@controller ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.0.11 controller 10.0.0.12 computer1
[root@computer1 ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.12  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::20c:29ff:fecb:31af  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:cb:31:af  txqueuelen 1000  (Ethernet)
        RX packets 68  bytes 8151 (7.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 81  bytes 9053 (8.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@computer1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.11   controller
10.0.0.12   computer1

準備環境初步完成!!!

三、搭建OpenStack基礎服務

1. 配置yum源(包括控制節點和計算節點)

以控制節點為例:操作步驟如下

#掛載光碟
[root@controller ~]# mount /dev/cdrom /mnt mount: /dev/sr0 is write-protected, mounting read-only [root@controller ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 48G 1.5G 47G 4% / devtmpfs 2.0G 0 2.0G 0% /dev tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 2.0G 8.6M 2.0G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs 394M 0 394M 0% /run/user/0 /dev/sr0 4.1G 4.1G 0 100% /mnt [root@controller ~]# ll /mnt total 654 -rw-r--r-- 1 root root 14 Dec 5 2016 CentOS_BuildTag drwxr-xr-x 3 root root 2048 Dec 5 2016 EFI -rw-r--r-- 1 root root 215 Dec 10 2015 EULA -rw-r--r-- 1 root root 18009 Dec 10 2015 GPL drwxr-xr-x 3 root root 2048 Dec 5 2016 images drwxr-xr-x 2 root root 2048 Dec 5 2016 isolinux drwxr-xr-x 2 root root 2048 Dec 5 2016 LiveOS drwxrwxr-x 2 root root 630784 Dec 5 2016 Packages drwxrwxr-x 2 root root 4096 Dec 5 2016 repodata -rw-r--r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7 -rw-r--r-- 1 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7 -r--r--r-- 1 root root 2883 Dec 5 2016 TRANS.TBL

上傳openstack_rpm.tar.gz至/opt目錄下

[root@controller ~]# ll /opt
total 241672
-rw-r--r-- 1 root root 247468369 Sep  9 01:08 openstack_rpm.tar.gz
[root@controller ~]# scp /opt/openstack_rpm.tar.gz 10.0.0.12:/opt/
The authenticity of host '10.0.0.12 (10.0.0.12)' can't be established.
ECDSA key fingerprint is SHA256:GYtp4W43k6E/1PUlY9PGAT6HR+oI6j4E4HJF19ZuCHU.
ECDSA key fingerprint is MD5:3f:b3:8b:8e:21:38:6f:51:ba:f4:67:ca:2a:bc:e1:34.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.12' (ECDSA) to the list of known hosts.
root@10.0.0.12's password: 
openstack_rpm.tar.gz                                                                                   100%  236MB  17.6MB/s   00:13    
[root@controller ~]# cd /opt
[root@controller opt]# tar -zxvf openstack_rpm.tar.gz 

生成repo配置檔案

[root@controller opt]# echo '[local]
> name=local
> baseurl=file:///mnt
> gpgcheck=0
> [openstack]
> name=openstack
> baseurl=file:///opt/repo
> gpgcheck=0' >/etc/yum.repos.d/local.repo
[root@controller opt]# cat /etc/yum.repos.d/local.repo 
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
[openstack]
name=openstack
baseurl=file:///opt/repo
gpgcheck=0
[root@controller opt]# yum makecache
Loaded plugins: fastestmirror
local                                                                                                             | 3.6 kB  00:00:00     
Not using downloaded local/repomd.xml because it is older than what we have:
  Current   : Tue Sep  5 21:43:04 2017
  Downloaded: Mon Dec  5 21:37:18 2016
openstack                                                                                                         | 2.9 kB  00:00:00     
(1/3): openstack/filelists_db                                                                                     | 465 kB  00:00:00     
(2/3): openstack/other_db                                                                                         | 211 kB  00:00:00     
(3/3): openstack/primary_db                                                                                       | 398 kB  00:00:00     
Determining fastest mirrors
Metadata Cache Created
[root@controller opt]# echo 'mount /dev/cdrom /mnt' >>/etc/rc.local
[root@controller opt]# chmod +x /etc/rc.d/rc.local

2. 時間同步(控制節點和計算節點)

控制節點:控制節點作為一個時間同步伺服器,其他節點都去和控制節點進行時間同步

[root@controller opt]# rpm -qa |grep chrony
chrony-3.1-2.el7.centos.x86_64
[root@controller opt]# vim /etc/chrony.conf
[root@controller opt]# grep 'allow' /etc/chrony.conf 
allow 10.0.0.0/24
[root@controller opt]# systemctl restart chronyd
[root@controller opt]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-11-12 22:20:11 CST; 11s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 15676 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 15672 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 15674 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─15674 /usr/sbin/chronyd

Nov 12 22:20:11 controller systemd[1]: Starting NTP client/server...
Nov 12 22:20:11 controller chronyd[15674]: chronyd version 3.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHA...+DEBUG)
Nov 12 22:20:11 controller chronyd[15674]: Frequency -1.301 +/- 2.107 ppm read from /var/lib/chrony/drift
Nov 12 22:20:11 controller systemd[1]: Started NTP client/server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@controller opt]# netstat -lntup 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1128/sshd           
tcp6       0      0 :::22                   :::*                    LISTEN      1128/sshd           
udp        0      0 0.0.0.0:123             0.0.0.0:*                           15674/chronyd       
udp        0      0 127.0.0.1:323           0.0.0.0:*                           15674/chronyd       
udp6       0      0 ::1:323                 :::*                                15674/chronyd       

可以看出服務端監聽的埠為123和323

計算節點:

[root@computer1 opt]# rpm -qa |grep chrony
chrony-3.1-2.el7.centos.x86_64
#編輯``/etc/chrony.conf`` 檔案並註釋除``server`` 值外的所有內容。修改它引用控制節點: [root@computer1 opt]# vim
/etc/chrony.conf [root@computer1 opt]# grep server /etc/chrony.conf # Use public servers from the pool.ntp.org project. server 10.0.0.11 iburst #server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst [root@computer1 opt]# systemctl restart chronyd [root@computer1 opt]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-11-12 22:38:21 CST; 4s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 15695 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS) Process: 15692 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 15694 (chronyd) CGroup: /system.slice/chronyd.service └─15694 /usr/sbin/chronyd Nov 12 22:38:21 computer1 systemd[1]: Starting NTP client/server... Nov 12 22:38:21 computer1 chronyd[15694]: chronyd version 3.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHAS...+DEBUG) Nov 12 22:38:21 computer1 chronyd[15694]: Frequency -6.299 +/- 16.148 ppm read from /var/lib/chrony/drift Nov 12 22:38:21 computer1 systemd[1]: Started NTP client/server. Hint: Some lines were ellipsized, use -l to show in full. [root@computer1 opt]# netstat -lntup Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1144/sshd tcp6 0 0 :::22 :::* LISTEN 1144/sshd udp 0 0 127.0.0.1:323 0.0.0.0:* 15694/chronyd udp6 0 0 ::1:323 :::* 15694/chronyd

客戶端監聽埠為323

3. OpenStack包(控制節點和計算節點)

參考文件:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/environment-packages.html

在CentOS中,``extras``倉庫提供用於啟用 OpenStack 倉庫的RPM包。 CentOS 預設啟用``extras``倉庫,因此你可以直接安裝用於啟用OpenStack倉庫的包

yum install centos-release-openstack-mitaka

安裝包獲取地址:https://mirrors.aliyun.com/centos/7.8.2003/extras/x86_64/Packages/

1)在主機上升級包

[root@controller opt]# yum upgrade

2)安裝 OpenStack 客戶端

[root@controller ~]# yum install python-openstackclient -y

3)安裝openstack-selinux軟體包(自動管理 OpenStack 服務的安全策略)

[root@controller ~]# yum install openstack-selinux -y

4, 安裝資料庫(安裝配置mariadb)

大多數 OpenStack 服務使用 SQL 資料庫來儲存資訊。 典型地,資料庫執行在控制節點上。

1)安裝軟體包

[root@controller ~]# yum install mariadb mariadb-server python2-PyMySQL -y

2)建立並編輯/etc/my.cnf.d/openstack.cnf,然後完成如下動作

在[mysqld]部分,設定``bind-address``值為控制節點的管理網路IP地址以使得其它節點可以通過管理網路訪問資料庫和以下鍵值來啟用一起有用的選項和 UTF-8 字符集

[root@controller ~]# echo '[mysqld]
> bind-address = 10.0.0.11
> default-storage-engine = innodb
> innodb_file_per_table
> max_connections = 4096
> collation-server = utf8_general_ci
> character-set-server = utf8'  >/etc/my.cnf.d/openstack.cnf
[root@controller ~]# cat /etc/my.cnf.d/openstack.cnf 
[mysqld]
bind-address = 10.0.0.11
default-storage-engine = innodb
innodb_file_per_table
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8

3)啟動資料庫服務,並將其配置為開機自啟:

[root@controller ~]# systemctl start mariadb.service
[root@controller ~]# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-11-13 11:55:30 CST; 6s ago
  Process: 66078 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 65891 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 65869 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 66050 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─66050 /usr/libexec/mysqld --basedir=/usr

Nov 13 11:55:26 controller mysql-prepare-db-dir[65891]: 2020-11-13 11:55:26 140308555983040 [Note] /usr/libexec/mysqld (mysqld 1...20 ...
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: To do so, start the server, then issue the following commands:
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: '/usr/bin/mysqladmin' -u root password 'new-password'
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: '/usr/bin/mysqladmin' -u root -h controller password 'new-password'
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: Alternatively you can run:
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: '/usr/bin/mysql_secure_installation'
Nov 13 11:55:29 controller mysql-prepare-db-dir[65891]: which will also give you the option of removing the test
Nov 13 11:55:30 controller mysqld[66050]: 2020-11-13 11:55:29 140150481619136 [Note] /usr/libexec/mysqld (mysqld 10.1.20-MariaD...050 ...
Nov 13 11:55:30 controller systemd[1]: Started MariaDB 10.1 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@controller ~]# netstat -lntup 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      31823/sshd          
tcp        0      0 10.0.0.11:3306          0.0.0.0:*               LISTEN      66050/mysqld        
tcp6       0      0 :::22                   :::*                    LISTEN      31823/sshd          
udp        0      0 0.0.0.0:123             0.0.0.0:*                           32062/chronyd       
udp        0      0 127.0.0.1:323           0.0.0.0:*                           32062/chronyd       
udp6       0      0 ::1:323                 :::*                                32062/chronyd       

4)為了保證資料庫服務的安全性,執行``mysql_secure_installation``指令碼。特別需要說明的是,為資料庫的root使用者設定一個適當的密碼

[root@controller ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

5)測試登入資料庫

[root@controller ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.1.20-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.05 sec)

5. 訊息佇列(安裝RabbitMQ)

OpenStack 使用message queue協調操作和各服務的狀態資訊。訊息佇列服務一般執行在控制節點上。OpenStack支援好幾種訊息佇列服務包括RabbitMQ, Qpid, 和 ZeroMQ。本文安裝RabbitMQ訊息佇列服務,因為大部分發行版本都支援它。

1)安裝包

[root@controller ~]# yum install rabbitmq-server -y

2)啟動訊息佇列服務並將其配置為隨系統啟動:

[root@controller ~]# systemctl enable rabbitmq-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/rabbitmq-server.service to /usr/lib/systemd/system/rabbitmq-server.service.
[root@controller ~]# systemctl start rabbitmq-server.service
[root@controller ~]# systemctl status rabbitmq-server.service
● rabbitmq-server.service - RabbitMQ broker
   Loaded: loaded (/usr/lib/systemd/system/rabbitmq-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-11-13 14:33:34 CST; 6s ago
 Main PID: 81485 (beam)
   Status: "Initialized"
   CGroup: /system.slice/rabbitmq-server.service
           ├─81485 /usr/lib64/erlang/erts-7.3.1.2/bin/beam -W w -A 64 -P 1048576 -t 5000000 -stbt db -K true -- -root /usr/lib64/erlan...
           ├─81667 inet_gethost 4
           └─81668 inet_gethost 4

Nov 13 14:33:32 controller systemd[1]: Starting RabbitMQ broker...
Nov 13 14:33:33 controller rabbitmq-server[81485]: RabbitMQ 3.6.5. Copyright (C) 2007-2016 Pivotal Software, Inc.
Nov 13 14:33:33 controller rabbitmq-server[81485]: ##  ##      Licensed under the MPL.  See http://www.rabbitmq.com/
Nov 13 14:33:33 controller rabbitmq-server[81485]: ##  ##
Nov 13 14:33:33 controller rabbitmq-server[81485]: ##########  Logs: /var/log/rabbitmq/[email protected]
Nov 13 14:33:33 controller rabbitmq-server[81485]: ######  ##        /var/log/rabbitmq/rabbit@controller-sasl.log
Nov 13 14:33:33 controller rabbitmq-server[81485]: ##########
Nov 13 14:33:33 controller rabbitmq-server[81485]: Starting broker...
Nov 13 14:33:34 controller systemd[1]: Started RabbitMQ broker.
Nov 13 14:33:34 controller rabbitmq-server[81485]: completed with 0 plugins.

3)新增openstack使用者

使用者為openstack,密碼為123456

[root@controller ~]# rabbitmqctl add_user openstack 123456
Creating user "openstack" ...

4)給``openstack``使用者配置寫和讀許可權

[root@controller ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...

5)開啟rabbitmq的web介面,來監控rabbitmq的執行狀態

[root@controller ~]# rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
  mochiweb
  webmachine
  rabbitmq_web_dispatch
  amqp_client
  rabbitmq_management_agent
  rabbitmq_management

Applying plugin configuration to rabbit@controller... started 6 plugins.
[root@controller ~]# netstat -lntup |grep 15672
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      81485/beam          

6)web頁面檢視

輸入:控制節點ip地址:15672

6.快取服務memecached安裝

認證服務認證快取使用Memcached快取令牌。快取服務memecached執行在控制節點。在生產部署中,推薦聯合啟用防火牆、認證和加密保證它的安全。

1)安裝包

[root@controller ~]# yum install memcached python-memcached -y

2)修改配置檔案

[root@controller ~]# sed -i 's#127.0.0.1#10.0.0.11#g' /etc/sysconfig/memcached
[root@controller ~]# cat /etc/sysconfig/memcached 
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 10.0.0.11,::1"

3)啟動Memcached服務,並且配置它隨機啟動

[root@controller ~]# systemctl enable memcached.service
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
[root@controller ~]# systemctl start memcached.service
[root@controller ~]# systemctl status memcached.service
● memcached.service - memcached daemon
   Loaded: loaded (/usr/lib/systemd/system/memcached.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2020-11-13 14:54:40 CST; 9s ago
 Main PID: 82414 (memcached)
   CGroup: /system.slice/memcached.service
           └─82414 /usr/bin/memcached -p 11211 -u memcached -m 64 -c 1024 -l 10.0.0.11,::1

Nov 13 14:54:40 controller systemd[1]: Started memcached daemon.
[root@controller ~]# netstat -lntup |grep 11211
tcp        0      0 10.0.0.11:11211         0.0.0.0:*               LISTEN      82414/memcached     
tcp6       0      0 ::1:11211               :::*                    LISTEN      82414/memcached     
udp        0      0 10.0.0.11:11211         0.0.0.0:*                           82414/memcached     
udp6       0      0 ::1:11211               :::*                                82414/memcached