MariaDB 由 MySQL 的创始人 Michael Widenius 主导开发,是 MySQL 的一个分支,主要由开源社区在维护,采用 GPL 授权许可。MariaDB 的目的是完全兼容 MySQL,包括 API 和命令行,使之能轻松成为 MySQL 的代替品。在存储引擎方面,使用 XtraDB 来代替 MySQL 的 InnoDB。 MariaDB 的 API 和协议兼容 MySQL,另外又添加了一些功能,以支持本地的非阻塞操作和进度报告。这意味着,所有使用 MySQL 的连接器、库和应用程序也将会在 MariaDB 下工作。 安装 MariaDB: sudo apt install mariadb-server mariadb-client 检查 MariaDB 的状态 systemctl status mariadb 输出: ● mariadb.service - MariaDB 10.6.12 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2023-12-11 17:13:04 UTC; 59s ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Process: 21940 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS) Process: 21941 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 21943 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl> Process: 21982 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Process: 21984 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS) Main PID: 21972 (mariadbd) Status: "Taking your SQL requests now..." Tasks: 8 (limit: 2220) Memory: 60.8M CPU: 1.084s CGroup: /system.slice/mariadb.service └─21972 /usr/sbin/mariadbd 如果 MariaDB 未处于活动状态,则启动它: systemctl start mariadb 使用以下命令在启动时自动启动 MariaDB: systemctl enable mariadb 数据库安全相关初始化: sudo 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 haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] n #是否切换 unix_socket 身份验证 ... skipping. You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] y #是否更改 root 登录密码 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 #是否禁止 root 远程登录 ... 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] y #是否删除测试数据库 - Dropping test database... ... Success! - Removing privileges on test database... ... Success! 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! 登录 MariaDB: mariadb -u root -p 退出 MariaDB: exit 检查 MariaDB 版本: mariadb --version 输出: mariadb Ver 15.1 Distrib 10.6.12-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrappe...
包含 Ubuntu 标签的文章
Ubuntu 20.04 的 Cron 不支持 MAILFROM
Ubuntu 20.04 的 Cron 竟然不支持 MAILFROM,而且查了一下,之前的版本据说也不支持,有人说 22.04 开始支持了。好吧,但是我的 R740 服务器不能正常安装这个月才刚发布的 22.04,真是尴尬呀。cron 直接使用系统账户作为发件人 root@gitlab,直接被邮件服务器退信了,不能发邮件。 gitlab@example.com: host smtp.qiye.aliyun.com[59.82.14.215] said: 500 Error: bad syntax (in reply to MAIL FROM command) 当然如果每个任务通过重定向到 mail 客户端也可以发信,不过不能像在 CentOS 中那样在开头指定收发信人了。搜索了一番,可以安装 cronie,它是 CentOS 等发行版系统选择的 cron 实现程序。 卸载掉 cron,安装 cronie cronie 下载地址:https://github.com/cronie-crond/cronie/releases 下载后编译: ./configure --prefix= #注意为空 make make install 安装服务: vim /usr/lib/systemd/system/crond.service [Unit] Description=Command Scheduler After=auditd.service systemd-user-sessions.service time-sync.target [Service] EnvironmentFile=/etc/crond.sysconfig ExecStart=/usr/sbin/crond -n $CRONDARGS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=30s [Install] WantedBy=multi-user.target 从程序根目录拷贝 crond.sysconfig 到 /etc systemctl enable crond.service systemctl start crond OK,又可以像在 CentOS 中那样用 cron 的 MAILFROM 了。 后记: 发现与 at 的目录结构有冲突(都混在 /var/spool/cron/ 中,而 Ubuntu 自带的 cron 文件夹是在 /var/spool/cron/crontabs/),所以还是换成了系统原装的 cron。 暂时就不用 crontab 自带的发信功能了,改用 ssmtp: 删除 postfix apt install ssmtp ssmtp 也提供了 sendmail 供 cron 使用。 配置: vim /etc/ssmtp/ssmtp.conf mailhub=smtp.qiye.aliyun.com:465 AuthUser=gitlab@example.com AuthPass=xxx AuthMethod=LOGIN UseTLS=YES FromLineOverride=NO #Debug=YES vim /etc/ssmtp/revaliases root:gitlab@example.com:smtp.qiye.aliyun.com:46...
Ubuntu 20.04 SWAP 分区扩容
系统安装后自动从镜像文件挂载的分区: /etc/fstab /swap.img none swap sw 0 0 swapon --show NAME TYPE SIZE USED PRIO /swap.img file 1.9G 0B -2 停止 SWAP 分区: swapoff /swap.img 调整大小: fallocate -l 16G /swap.img 或: dd if=/dev/zero of=/swap.img bs=1G count=16(蜗牛一样的速度) # fallocate 是预分配,所以速度比 dd 快的多得多。 chmod 600 /swap.img 格式化: mkswap /swap.img Setting up swapspace version 1, size = 16 GiB (17179865088 bytes) no label, UUID=f65b4da2-53cd-46a7-a782-aee321cd4329 # mkswap 可将磁盘分区或文件设为 Linux 的交换区 启用 SWAP 分区: swapon /swap.img swapon --show NAME TYPE SIZE USED PRIO /swap.img file 16G 0B -2 free -h total used free shared buff/cache available Mem: 31Gi 265Mi 23Gi 1.0Mi 7.6Gi 30Gi Swap: 15Gi 0B 15G...
Ubuntu 20.04 启动时等待网络配置时间过久问题的解决方法
Ubuntu 20.04 启动过程太长,发现启动时长时间等在这里: A start job is running for wait for network to be configured. 启动后进入系统,执行 Linux 系统启动性能统计分析命令: systemd-analyze blame 2min 126ms systemd-networkd-wait-online.service 2.774s systemd-udev-settle.service ... systemd-networkd-wait-online.service 这里等待了持续两分钟 解决方法: Edit /etc/netplan/01-netcfg.yaml and add optional: true to any devices that may not always be available. sudo netplan appl...
Ubuntu 16.04 FTP 服务程序 vsftpd
安装: sudo apt install vsftpd 其配置文件为 /etc/vsftpd.conf write_enable=YES #允许写文件操作 useradd -M -s /sbin/nologin ftp1 #创建一个本地 ftp 用户 ftp1 sudo passwd ftp1 sudo service vsftpd restart 530 Login incorrect : 修改 /etc/pam.d/vsftpd: 将 auth required pam_shells.so 修改为 auth required pam_nologin.so 或者将 auth required pam_shells.so 注释 创建虚拟用户: 虚拟用户的文件读写需要一个真实用户配合,先创建一个真实用户(在配置文件中关联guest_username) sudo useradd -m -d /home/vsftpd vsftpd sudo usermod -s /sbin/nologin vsftpd 启用匿名用户 anonymous 匿名用户使用的是系统的 ftp 用户 sudo vim /etc/vsftpd.conf write_enable=YES #允许写文件操作 anonymous_enable=YES anon_upload_enable=YES #匿名用户上传使能 anon_mkdir_write_enable=YES #匿名用户创建文件夹使能 #anon_root=/home/ftp #匿名用户根目录,默认为/srv/ftp sudo service vsftpd restart 关于根目录写权限: 从 2.3.5 之后,vsftpd 增强了安全检查,如果用户被限定在了其主目录下,则该用户的主目录不能再具有写权限了!如果检查发现还有写权限,就会报错误: vsftpd: refusing to run with writable root inside chroot () 解决方法:去除用户主目录的写权限 chmod a-w /srv/ftp 在根目录创建一个ftp用户可以写的目录 sudo mkdir /srv/ftp/public sudo chmod 777 /srv/ftp/public 或者修改配置 allow_writeable_chroot=YES #允许根目...
Ubuntu 安装 PHP
安装: sudo apt-get install php Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline Suggested packages: php-pear The following NEW packages will be installed: php php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json php7.0-opcache php7.0-readline 0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded. Need to get 3,532 kB of archives. After this operation, 14.1 MB of additional disk space will be used. Do you want to continue? [Y/n] 除了自动安装的 php7.0-cli php7.0-common php7.0-fpm 等,再安装一些模块: sudo apt-get install php7.0-mysql php7.0-curl php7.0-mcrypt php7.0-mbstring php7.0-xml 测试: php -v PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.32-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies php7.0-fpm 服务控制: sudo service php7.0-fpm stop sudo service php7.0-fpm start sudo service php7.0-fpm restart sudo service php7.0-fpm statu...
Ubuntu 安装 Nginx
apt-get install nginx # 安装 service nginx status # 查看服务运行状态 netstat -nap |grep nginx # 查看服务所使用的端口 网页浏览器访问服务器 IP 显示: Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx...
Ubuntu 下载内核源码
方法 1 uname -r apt-cache search linux-source //搜索内核版本 sudo apt-get install linux-source-4.15.0 会将内核源码包下载到 /usr/src 方法 2 apt-get source linux-image-$(uname -r) 可以下载到当前目录 我的测试结果是获取不到内核源码(源的配置没有问题)。 方法 3 git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<release>.git git clone git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git (16.04) git tag -l Ubuntu-* 下载的源码很大,速度很慢(git 浅克隆可以解决太大的问题)。 安装编译内核可能依赖的库或工具 sudo apt-get install libncurses5-dev libssl-dev sudo apt-get install build-essential openssl sudo apt-get install zlibc minizip sudo apt-get install libidn11-dev libidn11 编译 #sudo make mrproper sudo make menuconfig sudo make -j4 安装内核 sudo make modules_install #安装内核模块 sudo make install #安装内核 内核用户手册 man sudo apt-get install xmlto make mandocs -j4 #编译用户手册 sudo make installmandocs man print...